![]() |
Getting Gyro Working w/ Mecanum Drive
Although our season is over, the programming team is still tasked with completing several things before the start of the next season. One of the more difficult things (and something I struggled with implementing) during the build season was using a gyro to help the drivers. This is the code I've come up with so far, but I only included the drive code, nothing else:
Code:
teleopPeriodic(){ |
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
If your goal is to use the gyro to provide a field-centric driver interface, that's already part of the Java WPILib: Code:
... Or if your goal is to make the bot drive straight when the driver is commanding zero rotation, you could do something like this: http://www.chiefdelphi.com/forums/at...4&d=1420598437 ...Or here's an interesting optional (button-press selectable) driver interface mode for mec that your drivers might like: Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
Wait so I can just do RobotMap.robotDrive.mecanumDrive_Cartesian(OI.joys tick0.getX(), OI.joystick0.getY(), OI.joystick0.getZ(), RobotMap.driveGyro.getAngle()); in my teleopPeriodic and it'll do corrections for me? So if I'm driving w/o rotating it'll auto correct for me? |
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
Quote:
If you want the vehicle not to rotate when the driver rotate command is zero, you could do something like this: Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
Check out some of these links. |
Re: Getting Gyro Working w/ Mecanum Drive
I think I'm confused about what field-centric really is. To my understanding it's positioning based on the layout of the field. Could someone explain this to me?
|
Re: Getting Gyro Working w/ Mecanum Drive
1 Attachment(s)
|
Re: Getting Gyro Working w/ Mecanum Drive
Oh I see. That is not what I'm trying to accomplish. I am trying to get the robot not to rotate when the driver rotate command is zero. How do you accomplish this in Java, not in Labview?
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
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:
|
Re: Getting Gyro Working w/ Mecanum Drive
How do I set the robotdrive to the MecanumDrive method?
Quote:
|
| All times are GMT -5. The time now is 08:42 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi