"Remember Angle" In Swerve Drive?

Thanks to the help I received on this site, I was able to get my team’s swerve drive working successfully. However, I’m facing another problem so I’m coming back to ask again. When I point my joystick in a direction, the wheel is able to point the same way. This is exactly what I want. However, when I let go of the joystick, the wheels reset back to their “zero position”. Here is my code
Swerve Code
x1 is the Left X axis, y1 is the Left Y axis, and x2 is the Right X axis. The motor is basically being set to the value of the joystick (with a deadband), so by letting the joystick go I’m setting my value of x1, y1, and x2 to zero. I could use some help seeing how other team’s program their swerve drive in order to “remember” the last angle and not move when the joysticks are set to 0.

The “error” is probably in the trig where you calculate the angle. When the joystick is in the deadzone it calculates that resting angle.

You just need to do a check to see if you are in the deadzone or not. If not in deadzone: update angle to what the trig says. If in deadzone: use the last angle stored in a higher scope variable.

Perhaps someone more knowledgeable can fill in spicifics.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.