-
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?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
||
/** | ||
* OdometryNWheel | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
|
||
// if we do not pass in an IMU we use the wheels for rotation | ||
if (imu != nullptr) { | ||
angle = 0; | ||
|
@@ -186,7 +189,7 @@ template <int WHEELS> class OdometryNWheel : public OdometryBase { | |
* Gets the current position and rotation | ||
* @return the position that the odometry believes the robot is at | ||
*/ | ||
pose_t get_position(void) { | ||
pose_t get_position(void) override { | ||
pose_t unwrapped_radians = OdometryBase::get_position(); | ||
pose_t wrapped_degrees = {unwrapped_radians.x, unwrapped_radians.y, wrap_angle_deg((unwrapped_radians.rot / (2 * M_PI)) * 360)}; | ||
return wrapped_degrees; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,11 +142,24 @@ void TankDrive::drive_tank_raw(double left_norm, double right_norm) { | |
*/ | ||
bool captured_position = false; | ||
bool was_breaking = false; | ||
|
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, should be fixed now |
||
bt = BrakeType::ZeroVelocity; | ||
} | ||
else{ | ||
bt = BrakeType::None; | ||
} | ||
if(bt == BrakeType::None){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
printf("bt None \n"); | ||
} | ||
else if(bt == BrakeType::ZeroVelocity){ | ||
printf("bt zerovel \n"); | ||
} | ||
bool should_brake = (bt != BrakeType::None) && fabs(left) < brake_threshold && fabs(right) < brake_threshold; | ||
|
||
if (!should_brake) { | ||
|
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!