
21-04-2015, 19:05
|
 |
Programmer
AKA: Will Ness
 FRC #4944 (The Hi Fives)
Team Role: Programmer
|
|
Join Date: Apr 2014
Rookie Year: 2014
Location: United States
Posts: 90
|
|
|
Re: Getting Gyro Working w/ Mecanum Drive
How do I set the robotdrive to the MecanumDrive method?
Quote:
Originally Posted by GeeTwo
I recommend using one of the WPIlib MecanumDrive methods, and just make corrections to the "twist" input when you want to go straight based on the error. Do not use the fourth "gyroscope" input to MecanumDrive_cartesian; this is only used for "field coordinates".
The correction could be a full PID, but because of the amount of friction in a mecanum drive system, you should be able to get away with a simple proportional correction; D will be mechanical, and I is usually not needed when seeking a position.
To do this, you will need to create a numeric variable to hold the desired heading, say azi.
In your joystick-reading loop:
- When the joystick values indicate that you do not wish to hold a constant facing, set azi to NaN, or some number outside of the valid range.
- When the joystick values indicate that you do wish to hold a constant facing:
- If isnan(azi), set azi =gyro.getAngle()
- otherwise, add a correction of the form prop * (azi - gyro.getAngle()) to the "twist" value. You will have to tune the value of prop.
Debugging tip: If the robot starts spinning faster and faster, do a quick shut down, change the sign of "prop" and try again.
|
__________________
Outreach Lead // Lead Programmer // Junior

2014 FRC:
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Utah
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Colorado
2015 FRC:
Creativity In Engineering & Semifinalist @ Arizona West
|