Log in

View Full Version : Help! Gyro Not Helping With Strafing!!


Arbalest007
08-02-2015, 15:45
Hi everyone. So our team tested this method on the practice bot with mecanum wheels to see if it would allow the bot to strafe perfectly straight during teleop in order to minimize driver error when strafing.

//This method is called during TeleopPeriodic()
public void driveStraight() {
while(stick.getRawButton(1)) {
double stickDegrees = 0;

if(Math.abs(stick.getDirectionDegrees() % 90) < 30 || Math.abs(stick.getDirectionDegrees() % 90 > 60) {
if(Math.abs(stick.getDirectionDegrees() > 60 && Math.abs(stick.getDirectionDegrees()) < 120) {
if(stick.getDirectionDegrees < 0)
stickDegrees = -90.0;
else
stickDegrees = 90.0;
}
}

gyro.reset();
wholeDrive.mecanumDrive_Polar(stick.getMagnitude() , -stickDegrees, -gyro.getAngle() * .05);
}

This code used to let our practice bot strafe perfectly (The robot would kinda curve back and forth to correct itself to still strafe straight). However, on our competition bot the robot strafes and then starts to curve inwards and I'm not sure what is going on....

Joe Ross
08-02-2015, 16:10
Given that you reset the gyro immediately before using it, I'm not sure how this code could have worked.

cstelter
08-02-2015, 16:24
Seems you are creating a 30 degree deadzone in each straight direction-- if the degrees are on 90 +/- 30? Then you use 0, +90 or -90 depending on which branch you go through. But then you negate it before sending it to direction-- this seems odd to me. Like it would go left when you push right and never be able to go backwards.

Or I overlooked something.