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

Turn Only Braking Method #96

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Turn Only Braking Method #96

wants to merge 4 commits into from

Conversation

CodingPotatoes
Copy link

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

else{
bt = BrakeType::None;
}
if(bt == BrakeType::None){
Copy link
Collaborator

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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)){
Copy link
Collaborator

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?

Copy link
Author

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;
Copy link
Collaborator

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?

Copy link
Author

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>
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@Rabinvic Rabinvic left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants