Skip to content

Commit

Permalink
rename moveToOld to moveToPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Nov 17, 2023
1 parent c576e0b commit d87047e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/lemlib/chassis/chassis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ class Chassis {
* @param x x location
* @param y y location
* @param timeout longest time the robot can spend moving
* @param async whether the function should be run asynchronously. false by default
* @param maxSpeed the maximum speed the robot can move at. 127 by default
* @param async whether the function should be run asynchronously. true by default
*/
void moveToOld(float x, float y, int timeout, bool forwards = true, bool async = false, float maxSpeed = 127);
void moveToPoint(float x, float y, int timeout, bool forwards = true, float maxSpeed = 127, bool async = true);
/**
* @brief Move the chassis along a path
*
Expand Down
11 changes: 5 additions & 6 deletions src/lemlib/chassis/chassis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,15 @@ void lemlib::Chassis::moveToPose(float x, float y, float theta, int timeout, boo
* @param x x location
* @param y y location
* @param timeout longest time the robot can spend moving
* @param async whether the function should be run asynchronously. false by default
* @param maxSpeed the maximum speed the robot can move at. 127 by default
* @param async whether the function should be run asynchronously. true by default
*/
void lemlib::Chassis::moveToOld(float x, float y, int timeout, bool forwards, bool async, float maxSpeed) {
// try to take the mutex
// if its unsuccessful after 10ms, return
if (!mutex.take(10)) return;
void lemlib::Chassis::moveToPoint(float x, float y, int timeout, bool forwards, float maxSpeed, bool async) {
// take the mutex
mutex.take(TIMEOUT_MAX);
// if the function is async, run it in a new task
if (async) {
pros::Task task([&]() { moveToOld(x, y, timeout, forwards, false, maxSpeed); });
pros::Task task([&]() { moveToPoint(x, y, timeout, forwards, maxSpeed, false); });
mutex.give();
pros::delay(10); // delay to give the task time to start
return;
Expand Down

0 comments on commit d87047e

Please sign in to comment.