|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help! Gyro Not Helping With Strafing!!
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.... |
|
#2
|
||||||
|
||||||
|
Re: Help! Gyro Not Helping With Strafing!!
Given that you reset the gyro immediately before using it, I'm not sure how this code could have worked.
|
|
#3
|
|||
|
|||
|
Re: Help! Gyro Not Helping With Strafing!!
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. Last edited by cstelter : 08-02-2015 at 16:27. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|