How to tune heading and translation controllers for swerve

Since the heading and translation of the robot is changing simultaneously during a trajectory, I find it difficult to decouple these motions and tune the controllers in a trajectory command for swerve. Is there any strategy towards tuning the x, y, and theta controllers, or do you guys just do it by eye? Perhaps I starting with a straight trajectory where the robot is always facing one direction is a good strategy? Thanks in advance

3 Likes

This is a good strategy.

The best way to tune your x,y, theta controllers, is to run sysid. The tool will spit out pretty good kP values.

Edit:. Instructions on this are found here:

Disclaimer: swerve is not OFFICIALLY supported in path planning, but it can still be achieved by treating your drive train like a differential drive

1 Like

Finally, highly suggest looking into path planner:

It’s a great tool, especially for swerve drives

1 Like

I’m just curious, how would you use sysID to tune the theta controller? I think I can use sysID to better tune the velocity PID on my drive motors, but since my steering is a positional control, I don’t think it would apply. Would you use sysID for the actual drive and azimuthal controllers onboard the swerve module, or for the controllers within the Swerve trajectory command, as these are separated by my understanding.

We carefully tuned the underlying velocity , swivel position and heading loops for basic teleop control.

Once we had that we just used the constants provided in the wpilib example for the swervecontrollercommand example: kp = 1, and everything else zero for the x,y, and theta loops when running a trajectory.

We use Path Planner 2 to generate a path and the wpilib trajectory generator to create the trajectory. Works great !

Used frc characterization for the tuning - haven’t dug into sysid yet - that’s on the to list .

I’m going to second that recommendation for path planner - it’s fabulous and let’s us easily specify x,y, and heading independently with its holonomic mode .

So did you use frc characterization to better tune your drive velocity PID? For this process, I am thinking of locking my azimuthal motors to 0 degrees and running the robot like a typical differential drive.

2 Likes

Yes - we need dec characterization to tune velocity and azimuthal module angle separately.

We constantly run a heading pid loop to maintain desired heading - we tuned that one by hand

1 Like

Yes - lock wheels forward when tuning velocity

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