Greetings, my team just got a MAXSwerve and I have used the template code in order to make it drive. The robot orientation works but when it comes to using the gyroscope to drive relative to the field the robot seems to get lost or not be able to drive towards where the gyroscope is facing. I tried using the command from 0 to autonomous but also seems to not work. I have attached the src file.
Any suggestions work. Thanks in advanced.
Are you holding down button 1 on the joystick? This is just a hunch, of course, but perhaps fieldOrientedControl is returning false in the command.
Specifically here:
Which would make the code not take this branch:
The NavX heading needs to be inverted. In WPILib, rotation is counter-clockwise positive. The NavX is clockwise positive.
public double getHeading() {
return Math.IEEEremainder(-gyro.getAngle(), 360.0d);
}
I would also use the result of getHeading()
for odometry instead of the raw value from the NavX (if you choose to stick with the raw value, it also needs to be inverted.)
Yes I was holding button 1 down to turn the field oriented function Thanks.
Thank you so much this worked for us. We greatly appreciate it.
1 Like
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.