![]() |
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
Code:
RobotMap.driveRobotDrive41.mecanumDrive_Cartesian(OI.joystick0.getX(), OI.joystick0.getY(), OI.joystick0.getZ(), 0); |
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
Quote:
Quote:
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
The code is not particularly well documented, but here's the code we used this year:
https://github.com/CopperBots/Copper...obot.java#L632 We pass in the rotation joystick value that has already been deadband'ed. If the joystick is at zero rotation, we use a proportional controller to keep the robot straight. If the joystick is not at zero, we update the current heading of the robot and pass the joystick value back to the drive system unchanged. We also have the option to disable gyro mode at any time in case something goes wrong like a bad calibration, or a loose cable. There is also an option to update the kP value from the smart dashboard and some diagnostic information sent back to help troubleshoot when things go wrong. |
Re: Getting Gyro Working w/ Mecanum Drive
Well what I'm asking is what do I put in for the fourth parameter, because I have to put something in it.
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Thanks, this helps a BUNCH! The problem is mixing mecanum drive with your code
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Quote:
Code:
public void mecanumDrive_Cartesian(double x, double y, double rotation, double gyroAngle) {Now look at the WPILib code for rotateVector(): Code:
/** |
Re: Getting Gyro Working w/ Mecanum Drive
Thank you Ether, that helps tons.
Quote:
|
Re: Getting Gyro Working w/ Mecanum Drive
Do you think this will work? (I only included the drive code)
Code:
public void teleopInit(){ |
Re: Getting Gyro Working w/ Mecanum Drive
I believe I have gotten gyro code to work! It is a little tricky while strafing, but for every other use it works great, and it really does help limit the turning while strafing according to our driver. So here you go, FYI: I only included code related to the driving, don't replace whole sections with this code:
Code:
One thing I might try to do in the future is make the correction only read [-180,180] because when we set our heading to 0, we could rotate around 3-4 times and instead of going to the nearest "0" it would rotate back the exact amount. The reason this could help is that if the game is in a year with a goal, you could press a button and the robot would rotate to face the goal exactly, but this wouldn't work if maybe you had spun around several times before. Thanks to: GeeTwo, Ether, and dawonn |
| All times are GMT -5. The time now is 11:13. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi