-
Notifications
You must be signed in to change notification settings - Fork 4
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
Turn Only Braking Method #96
base: main
Are you sure you want to change the base?
Conversation
src/subsystems/tank_drive.cpp
Outdated
else{ | ||
bt = BrakeType::None; | ||
} | ||
if(bt == BrakeType::None){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove these prints before merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
src/subsystems/tank_drive.cpp
Outdated
void TankDrive::drive_tank(double left, double right, int power, BrakeType bt) { | ||
|
||
left = modify_inputs(left, power); | ||
right = modify_inputs(right, power); | ||
double brake_threshold = 0.05; | ||
if(((left_motors.velocity(vex::velocityUnits::rpm) * (right_motors.velocity(vex::velocityUnits::rpm))) < 0)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be (if bt == TurnOnly && (left.vel * right.vel < 0)) that way it's turned off when not specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, should be fixed now
@@ -116,6 +117,8 @@ template <int WHEELS> class OdometryNWheel : public OdometryBase { | |||
|
|||
pose_t updated_pos = calculate_new_pos(radian_deltas, current_pos); | |||
|
|||
// std::cout << "x: " << updated_pos.x << " y: " << updated_pos.y << " rot: " << updated_pos.rot << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this print?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -9,6 +9,7 @@ | |||
#include "../core/include/subsystems/custom_encoder.h" | |||
#include "../core/include/subsystems/odometry/odometry_base.h" | |||
#include "../core/include/utils/math_util.h" | |||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed i dont think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I'd put some more comments just to make it clear what each branch of the if block is doing, but other than that it's good to go.
Description
A braking type that switches between the zerovelocity and None braking types depending on whether or not the robot is turning
Usage
Simply use TankDrive::BrakeType::TurnOnly when passing a braking type to the drive_arcade or drive_tank function
How to use this feature:
// A code sample for how to use the feature
drive_sys.drive_arcade(l, r * 0.7, 1, TankDrive::BrakeType::TurnOnly);
Set up:
Robot just needs to be set up how it usually is when driving
Testing:
Made sure it was braking for more precise movement when turning but not doing so when moving forwards and backwards