Integrating Custom Path Generators with WPILib SwerveController

Hi everyone,
We are trying to figure out how to generate and use trajectories that benefit from the holonomic possibilities of a swerve drive. As far as I have researched, I either couldn’t wrap my head around undocumented code or could not find a lot of generators.

The only one I saw that was documented well and I was able to get running was the Swerve Path Planner from team 6831 A05annex.

So, I was wondering if there is any way to use the output JSON file from this generator with the WPILib Trajectory class. I have examined 6831’s code, but as far as I’ve seen, they haven’t implemented the PID controllers for each module. Any further guidance is appreciated. (This generator apparently uses "an implementation of Kochanek-Bartels Spline " which I am not sure if WPILib supports)

If there are any other ways, generators or things that I could use, read or watch to benefit from the holonomic features would be very helpful.

1 Like

Here’s one example that I’d worked out in simulation a little while back:

The Holonomic drive controller

Where other classes inject commands

The core idea:

  1. Some trajectory generator emits a series of Trajectory.State objects, which represent a reasonable sequence of motions the robot could mechanically accomplish. If you can get 6831’s tool to emit a .json file describing a ~20ms-sampled description of the path, there’s a good chance it could be parsed into a sequence of Trajectory.State's
  2. Trajectory.State's are compared to the current robot estimated Pose/state. The Holonomic Drive Controller emits a chassis speeds to correct for errors between desired/estimated.
  3. New desired module states are calculated from the chassis speeds command.

FWIW #1 - WPILib’s built in trajectory generation worked pretty well.

FWIW #2 - This is all simulation, not yet tried on any real hardware. Currently seeking real hardware.

4 Likes

I happened to notice this evening that 2767s code for IR was released. This class may be of interest to you: infiniterecharge/PathDriveCommand.java at master · strykeforce/infiniterecharge · GitHub

I haven’t digested this fully myself, but flagged it as something to look at in the future.

2 Likes

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