Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/VOSS/chassis/AbstractChassis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AbstractChassis {
controller_ptr default_controller;
ec_ptr default_ec;
std::unique_ptr<pros::Task> task = nullptr;
bool task_running = false;
std::atomic_bool task_running = false;
pros::motor_brake_mode_e brakeMode;

void move_task(controller_ptr controller, ec_ptr ec, double max,
Expand All @@ -39,6 +39,9 @@ class AbstractChassis {
virtual bool execute(DiffChassisCommand cmd, double max) = 0;
virtual void set_brake_mode(pros::motor_brake_mode_e mode) = 0;

void wait_until_settled() const;
bool is_settled() const;

void move(double distance, double max = 100.0,
voss::Flags flags = voss::Flags::NONE);

Expand Down
12 changes: 11 additions & 1 deletion src/VOSS/chassis/AbstractChassis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void AbstractChassis::turn_to(Point target, controller_ptr controller,
ec_ptr ec, double max, voss::Flags flags,
voss::AngularDirection direction) {
while (this->task_running) {
pros::delay(10);
pros::delay(constants::MOTOR_UPDATE_DELAY);
}
this->task_running = true;

Expand All @@ -165,4 +165,14 @@ void AbstractChassis::turn_to(Point target, controller_ptr controller,
direction);
}

void AbstractChassis::wait_until_settled() const {
while (this->task_running) {
pros::delay(constants::MOTOR_UPDATE_DELAY);
}
}

bool AbstractChassis::is_settled() const {
return this->task_running;
}

} // namespace voss::chassis
Loading