Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set brake mode bug fix #106

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 6 additions & 6 deletions src/VOSS/chassis/DiffChassis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ DiffChassis::DiffChassis(std::initializer_list<int8_t> left_motors,

this->slew_step = slew_step > 0 ? slew_step : 200;
this->brakeMode = brakeMode;
this->left_motors->set_brake_mode(this->brakeMode);
this->right_motors->set_brake_mode(this->brakeMode);
this->left_motors->set_brake_mode_all(this->brakeMode);
this->right_motors->set_brake_mode_all(this->brakeMode);
this->prev_voltages = {0, 0};
}

Expand All @@ -55,8 +55,8 @@ void DiffChassis::arcade(double forward_speed, double turn_speed) {

void DiffChassis::set_brake_mode(pros::motor_brake_mode_e mode) {
this->brakeMode = mode;
this->left_motors->set_brake_mode(mode);
this->right_motors->set_brake_mode(mode);
this->left_motors->set_brake_mode_all(mode);
this->right_motors->set_brake_mode_all(mode);
}

// Evoke the chassis to move according to how it was set up using the
Expand Down Expand Up @@ -114,7 +114,7 @@ bool DiffChassis::execute(DiffChassisCommand cmd, double max) {
[this, max](diff_commands::Swing& v) {
double v_max = std::max(fabs(v.left), fabs(v.right));
if (v.right == 0) {
this->right_motors->set_brake_mode(pros::MotorBrake::hold);
this->right_motors->set_brake_mode_all(pros::MotorBrake::hold);
this->right_motors->brake();
if (v_max > max) {
v.left = v.left * max / v_max;
Expand All @@ -124,7 +124,7 @@ bool DiffChassis::execute(DiffChassisCommand cmd, double max) {
this->prev_voltages = {v.left, 0.0};

} else if (v.left == 0) {
this->left_motors->set_brake_mode(pros::MotorBrake::hold);
this->left_motors->set_brake_mode_all(pros::MotorBrake::hold);
this->left_motors->brake();
if (v_max > max) {
v.right = v.right * max / v_max;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ auto ec = voss::controller::ExitConditions::new_conditions()
return master.get_digital(pros::E_CONTROLLER_DIGITAL_UP);
});

auto chassis = voss::chassis::DiffChassis(LEFT_MOTORS, RIGHT_MOTORS, pid, ec,
auto chassis = voss::chassis::DiffChassis(LEFT_MOTORS, RIGHT_MOTORS, pid, ec, 8,
pros::E_MOTOR_BRAKE_COAST);

pros::IMU imu(16);
Expand Down