Road Runner
Search…
Trajectories
Now it's time to combine paths with the motion profiles from earlier. Road Runner calls this composition a trajectory. Trajectories take time values and output the corresponding field frame kinematic state (i.e., real positions, velocities, and acceleration). This state can be transformed to the robot frame and fed directly into the feedforward component of the controller.
Here's a sample for planning a Trajectory from a Path:
Java
Kotlin
1
TrajectoryVelocityConstraint velConstraint = new MinVelocityConstraint(Arrays.asList(
2
new TranslationalVelocityConstraint(20),
3
new AngularVelocityConstraint(1)
4
));
5
TrajectoryAccelerationConstraint accelConstraint = new ProfileAccelerationConstraint(40);
6
Trajectory traj = TrajectoryGenerator.generateTrajectory(path, velConstraint, accelConstraint);
Copied!
1
val velConstraint = MinVelocityConstraint(listOf(
2
TranslationalVelocityConstraint(20.0),
3
AngularVelocityConstraint(1.0)
4
))
5
val accelConstraint = ProfileAccelerationConstraint(40.0)
6
val traj = TrajectoryGenerator.generateTrajectory(path, velConstraint, accelConstraint)
Copied!
As indicated by their names, the constraints limit translational velocity, angular velocity, and profile acceleration. It's common to replace the translational velocity constraint with a stronger constraint that limits wheel velocities. These constraints are named according to the drive types (e.g., MecanumVelocityConstraint).
There is also a TrajectoryBuilder class that replicates the API of PathBuilder with a few additions.
Once a trajectory is finally generated, one of the TrajectoryFollowers can be used to generate the actual DriveSignals that are sent to the Drive class. The PIDVA followers are usually suitable, although RamseteFollower has noticeably better performance for tank drives.
Following a trajectory is as simple as creating a follower, calling TrajectoryFollower.followTrajectory(), and repeatedly querying TrajectoryFollower.update():
Java
Kotlin
1
PIDCoefficients translationalPid = new PIDCoefficients(5, 0, 0);
2
PIDCoefficients headingPid = new PIDCoefficients(2, 0, 0);
3
HolonomicPIDVAFollower follower = new HolonomicPIDVAFollower(translationalPid, translationalPid, headingPid);
4
5
follower.followTrajectory(traj);
6
7
// call in loop
8
DriveSignal signal = follower.update(poseEstimate);
Copied!
1
val translationalPid = PIDCoefficients(5.0, 0.0, 0.0)
2
val headingPid = PIDCoefficients(2.0, 0.0, 0.0)
3
val follower = HolonomicPIDVAFollower(translationalPid, translationalPid, headingPid)
4
5
follower.followTrajectory(traj)
6
7
// call in loop
8
val signal = follower.update(poseEstimate)
Copied!
Last modified 11mo ago
Copy link