-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SwerveModule drive motor has jittery velocity setpoints #93
Comments
Something else to note is that this jitter is not always present, but once it happens it will not go away on its own. For example, sometimes when applying zero chassis speeds, there will be no jitter. But if we drive around for a second to get things moving, the jitter will usually start happening when we come to a stop. Switching to a static zero speeds swerve request while the jitter is happening does not stop it, and it will continue to jitter indefinitely until we move again. It also usually only happens on 1 or 2 modules at a time, with the modules that jitter changing seemingly randomly. We have seen all of them jitter together sometimes, however. |
There are two sources of compensation we apply to the drive motors based on the azimuth:
If the jitter you're seeing is primarily caused by 2, then it should go away by setting the coupling ratio to 0 (note that this will introduce more error into odometry, this is just for testing). Otherwise, you should verify that your module azimuth is tracking well. Note that none of this has changed from last season, the only thing that has changed is support for module force feedforwards. If you're currently using that, then I would first test without them so there's fewer variables involved. Any jittering from module force feedforwards would likely be the same as cosine compensation, assuming the feedforwards are correct to begin with. |
We are not using any force feedforwards at the moment, and our azimuth is tracking very well, down to <0.02 rotations. I can verify this by setting the coupling ratio to zero next time I have access to the robot, but based on your description, I believe 2 is creating a feedback loop that causes jitter based on the behavior I’ve seen. When the jitter happens, our logging shows very small changes in the steer position and velocity (setpoint remains constant) of the modules that are jittering. This steer velocity leads to drive jitter, which leads to more steer jitter, and so on. We’ve noticed giving the robot a kick can start and stop this jitter as well. This makes sense as it could be stopping or introducing a small amount of steer velocity that starts or stops this feedback loop. I would argue that these setpoint changes should only be applied if the steer velocity is over a certain threshold (preferably configurable and fairly high by default). I see why coupling ratio helps odometry, but I can’t imagine changing the setpoints based on it making much of a difference that the PID loops can’t compensate for, especially at lower steer velocities. We would like to keep coupling ratio configured for odometry accuracy, but the amount of jitter we’re seeing is pretty excessive and very loud. |
Also, we’ve seen this jitter happen with zeroed out PID constants for the steer motors, which is how we discovered it was the drive jittering in the first place. So this endless feedback loop is not really contributed to by the steer motors and their PID tuning. |
Changing the coupling ratio to 0 does stop the jitter. Would definitely like the ability to disable those setpoint changes or have a threshold for them. |
We just released Phoenix 6 25.2.2, which addresses this issue: https://api.ctr-electronics.com/changelog#20250206 |
Tried the latest release and it definitely makes it a lot better, but it can still occur sometimes. It will eventually stop on its own now after a second or two. |
Interesting. Just to confirm, you're seeing this with the robot on carpet? I'm surprised that's not enough friction to stop it after our changes; that sounds more like one of the sets of PID gains (or feedforwards) are a bit too strong. |
Yeah. It’s really rare now, so not really something I’m concerned about anymore. We will take another pass at our PID tuning when we get a chance. The jitter seems to just be in the backlash of the gears, as the wheels don’t actually move. So carpet friction probably doesn’t have much to do with it. |
So we just tried a custom swerve request that applies |
There seems to be some severe jitter in swerve module drive velocity setpoints introduced by various SwerveRequests. We tested
ApplyRobotSpeeds
andFieldCentric
and they both introduced the same jitter. The jitter is in the setpoint itself, not just the output of the motor, which we see by logging the drive motor'sgetClosedLoopReference()
signal.We have verified that this jitter is not introduced by our code or a poorly tuned PID controller with the following testing:
ApplyChassisSpeeds
orFieldCentric
with static, zeroed speeds.NeutralOut
to rotation motors andVelocityTorqueCurrentFOC
with velocity 0 to drive motors.Our exact setup is Mk4i modules with L2 ratio, KrakenX60s running torque current output for both drive and steer which are set to Velocity and Position control respectively. Using java, latest firmware and Phoenix. I'll be happy to provide further information if needed.
The text was updated successfully, but these errors were encountered: