Driving the trajectory in reverse?

My team have been using the Ramsete Controller with WPILIB’s Trajectory classes to drive our autonomous paths. It works awesome!

I have wondered however:

Is there any functionality built in to then drive the trajectory in reverse? Say I got to the end point of my trajectory, and I want to then backtrack (maybe even in reverse) back to where I came from, as accurate to my original trajectory?

Another concept I’ve thought about, is our autonomous uses a camera to line up to balls. This is probably overkill for most cases because of bang bang reckoning is probably good enough. But I’ve thought about the more advanced concept of tracking movements of robot (when it is driven by a camera based loop), and then being able to backtrack more accurately.

I think this is covered in the wpilib docs here: Trajectory Generation — FIRST Robotics Competition documentation

I also find it useful to search github and look for other team’s implementations from past years, for example: https://github.com/search?q=reversed+RamseteCommand&type=code you can even filter by language

oh wow, cool so you can just reverse the trajectory. Thanks for that. guess I just need to figure out a way to log and create trajectories dynamically.

Might be as simple as generating Pose2D Points

Here is our bounce path from last year. You just generate the trajectory and then add a setReversed to the trajectory config. Since bounce had forward and reversed paths we used two configs. There maybe some newer ways to construct this all since last year fair warning. The path waypoints are in the deploy folder. https://github.com/frc1108/BabyAckbar/blob/master/src/main/java/frc/robot/commands/auto/Bounce.java

Thanks for all help!

We currently read our paths in from the path weaver. We might stop doing that because that does not seem to work to the same scale.

Is there a way to read in directly to a ‘Trajectory’ object and then modify the ‘TrajectoryConfig’

I couldn’t see a way to do it in the paths

1 Like

Not really that I see already written.

The trajectory generator uses start, interior waypoints, and end, and the config. I expect it is possible to deconstruct the trajectory to reapply a different config, but don’t see a method for doing that in the trajectory classes.

I think using pathweaver trajectories without config modifying can be done here: Importing a PathWeaver JSON — FIRST Robotics Competition documentation

Using the reversed config flag lets you follow the path A to B facing the other way, but it doesn’t mean you go from B to A.
You could do something like this to create a new, inverted(?) trajectory based on an existing one given you also set the new config to reverse the original.

ah. yeah thats what we do. I was hoping I could then modify the config of that (say in testing to bump our speeds, doesn’t look like it supports that though).

Looks like I’ll have to make the paths in code. Pathweaver was great for the visualization. Although the scale seemed off.

good to know! So I guess I could just update the trajectory in place. Thats great.

Can you expand on the issues you had with Pathweaver?

Its possible its our robot, but we uploaded a field image of the current game and plotted some points. The scale does not seem correct. I need to rerrun the characterization system with our robot to be sure thought that it is pathweaver.

So could completely be specific to us

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