Trajectory generation on robot to vary velocities using pathweaver paths

We are currently generating trajectories at different velocities on pathweaver and importing them. This makes things a bit unwieldy since I need to set up output directories for each velocity. It would be nice to generate trajectories on the fly with a variable velocity (for simulation testing).

I’ve done this with generateTrajectory​(List<Pose2d> waypoints, TrajectoryConfig config) and the other translation based wpilib generators from the waypoints. The pathweaver trajectories are better since they use the Tangent X, Tangent Y parameters controlling the curvature.

Do we have a way to generate the same pathweaver trajectories from the pathweaver path on the robot? I don’t mind the speed hit since this is all for optimizing with simulation at the moment. Having to import and manipulate the raw data is not a problem if necessary. Thanks!

Yes. See the following two generateTrajectory() overloads.,java.util.List,edu.wpi.first.wpilibj.spline.Spline.ControlVector,edu.wpi.first.wpilibj.trajectory.TrajectoryConfig),edu.wpi.first.wpilibj.trajectory.TrajectoryConfig)

PathWeaver uses these internally to generate the trajectories.

Thank you. It took me a while to get the Spline5.ControlVector class to initialize (I kept trying to pass it only a 0th and 1st derivative, not realizing it required a second as well). And I had a bit of a stumble before I noticed Pathweaver has the origin at the top left instead of bottom left.
But I can verify code like

wpimath.trajectory.TrajectoryGenerator.generateTrajectory(control_vector_list, config)

generates trajectories identical to Pathweaver in robotpy.
I’m happy - now my students can just save a new path and test it with whatever velocity they like w/o restarting the sim.

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