Throttle Map

Hello everyone!

We’re interested in implementing a Throttle Map to tailor the control response to our drivers’ preferences. Has anyone here done something similar or have any advice on where to start? Any guidance or examples would be greatly appreciated! We’re currently using AdvantageKit. Here’s our current repository: TechMaker_Swerve_2024.

Thanks in advance!

1 Like

InterpolatingDoubleTreeMap (WPILib API 2024.3.2) is your friend for things like this.

Linear interpolation - Wikipedia and Piecewise linear function - Wikipedia for more background.

You can use that class to define a piecewise-linear function that maps joystick displacement into commanded speed. Add enough points, you can make it look like whatever function you want.

4 Likes

Thank you so much for the recommendation!

one suggestion: before you write the map function, look at the response of the controller itself. many controllers have a pretty big deadband in the middle. the big deadband and tiny sticks of most xbox-like controls makes it hard to exert fine control, which is why i generally encourage teams to investigate “RC” style controllers like the FlySky SM001 or Spektrum Interlink.

another suggestion, for swerve, you probably want to apply the throttle map to the radial component of the translation input. mapping the x and y dimensions separately won’t do the same thing.

4 Likes

Thank you for this, I will definitely take it into consideration.

We’ve got an example of a ThrottleMap in our library, PurpleLib.

6 Likes

This will help a lot! Thanks!