Two Speeds Auto?

Hi. We are planning to use a two speed gearbox in our drivetrain, and we would like to use them in the auto with the WPILib trajectories. Is this possible (relatively simple to implement in build season)? Do you have any example code that can help us?

1 Like

Depending on your paths and what your two speeds are, you may be able to use just a single speed (most likely the low one). Someone else who is more familiar with using the WPILib trajectories would have to chime in but if there isn’t a designated two-speed trajectory generator, you could wrap an auto-shifting function on top of the output? Again depending on the spread, you might need to look at gain scheduling - changing control loop gains (like for a PID) based on different states the robot is in.

1 Like

In any case, I’d focus on getting the auto routine to run in low speed before folding in a gear shift. If you do intend to shift, it becomes even more important that you measure your speed on the wheel side of the gearbox rather than the motor side because the shift doesn’t happen exactly when you ask for it.

1 Like

Thanks, we already consider that. We are more concern about the control system and what changes would need if any.

If you use the trajectory generator and know at what point in time during the trajectory you want to shift, it should be relatively straight forward.

Let’s say you are wanting to follow the below trajectory from point A to point C and want to shift from low to high gear at point B.

Instead of this being on trajectory, break it into 2 trajectories. When using the WPILIB trajectory generator:

  1. Set the max velocity and max acceleration accordingly to the respective gear.
  2. Make sure to convert the speed at B (i.e. if you ended the trajectory at B going 7 fps in low gear and go twice as fast in high gear, make sure to start the second trajectory at 14fps, not 7)
  3. Create a series command group that takes the first trajectory, then a command to shift, then the second trajectory.

I think it should work out pretty smoothly. Feel free to ask if you have any questions!

1 Like

That doesn’t sound too hard. We would try it.


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