For this years game, we have decided to use custom trajectories through a Ramsete controller, and this works well for the barrel and slalom paths. But to optimize the bounce path we need reverse a part of the trajectories, and keep others going straight. In the Ramsete controller, there only is one input for a trajectory, so I have no idea how to feed a regular trajectory then a reversed one. The only way I can think of achieving this is to create multiple Ramsete Commands, then call them sequentially. Does anyone know of a better way?
I don’t have a better way, but the way we’ve done it is to string together multiple RamseteCommands with configs that alternate between reversed and not reversed. That works, if a little verbose.
You are correct that each time you switch between forwards and reverse you need a new trajectory. I don’t think 4 trajectories is that bad.
There was a merged PR to allow you to concatenate trajectories together recently but it hasn’t made it into a release yet. I’m curious if forward and reverse trajectories joined together will still work with RamseteCommand.
While you can concatenate trajectories and then follow along the concatenated result with one RamseteCommand, there’s likely no practical advantage over separate RamseteCommands as long as each trajectory starts and ends with zero speed. If you tweak the concatenation to continue across the transition between the original trajectories while keeping the speed up, you’d have an advantage. That’s possible when you keep going ‘forward’ or keep going ‘reverse’, but when you need to change from ‘forward’ to ‘reverse’ it’ll be hard to avoid a point with zero speed…
How does one actually specify start and end speed in the generator? We’re trying to do that.
TrajectoryConfig you pass in to the
TrajectoryGenerator lets you specify
setEndVelocity(), which by default are both zero.
I am trying to use multiple trajectories in autonomous for the Romi mini-bot. Did you figure out how to do it?
As far as I know, the Romi should be able to run ramsete fine. Is there a problem with running ramsete commands sequentially as mentioned earlier?
In the example code, the Ramsete command is part of GenerateRamseteCommand and is within the RobotContainer file. I am new to Java so I am not understanding how to call it more than once from outside that file, like from an autonomous routine within Commands? Total beginner here.
Honestly, the practice of creating the Ramsete command in RobotContainer is (IMHO) limiting and kind of messy. I think you are better off creating a separate Command class, and creating the needed Ramsete command in there.
If you want to run multiple Ramsete trajectories in sequence, you create each one and then sequence them in a SequentialCommandGroup:
Then just run the one (composite) command.
It will help to go through the command-based docs and understand how commands function.
The ramsete command creates a command for following the given trajectory, and you can combine them together sequentially to follow multiple paths in order.
For example, here’s what we did for bounce:
StandardRamseteCommandis just a wrapper for
RamseteCommandthat makes it a bit less verbose, and automatically constructs a
RamseteCommandusing the drivetrain.
paths.bouncexpoints to a generated trajectory. All those commands, when combined like this with decorators, create a
CommandGroupthat functions as a
fullAutoOptions.addOptionrelates to adding that command to a
SendableChooserwhich displays multiple commands on the dashboard and can return which is selected.
You can get the command selected from the same chooser like this:
Which we can then schedule on autonomous init.
Okay this is starting to make sense! Thank you so much!
I tried and failed for hours to create a new Command that did what I wanted to do. So within the example AutonomousDistanceCommand, I added the code shown below. I can run multiple Ramsete commands with different trajectories OR I can run combinations of the DriveDistance () and TurnDegrees() Commands. However, if I try to run what is shown below, it never finishes the DriveDistance Command and just continues on forever. If I put a TurnDegrees() Command at the start or end it turns infinitely in a circle. I am sure I am missing something about resetting the odometry but no matter what I try, I am getting something wrong. Help? (A few things are cut off in the screen captures but I think it will not affect the understanding.)
Without seeing the rest of your project it os difficult to say why this is hapenning, but I have a hypothesis. If each of these use the drivebase, they cannot all use the drivebase at the same time.
it never finishes the DriveDistance Command
it turns infinitely in a circle
I am assuming your
AutonomousDistance command is a
SequentialCommandGroup. Nothing looks immediately off to me for the ramsete commands.
It would be helpful to see your other commands and odometry. Is one of these repositories correct/could you push your current code?
Not sure if I did this correctly. But if I did:
You’re missing the folders. It should be everything under the main project directory you use in VSCode.
E.g. all these:
I need to learn how to do this from VS Code.