Note
In C++, it is important that the feedforward constants be entered as the correct unit type. For more information on C++ units, see docs/software/basic-programming/cpp-units:The C++ Units Library
.
Now that we have our system constants, it is time to place them in our code. The recommended place for this is the Constants
file of the standard command-based project structure <docs/software/commandbased/structuring-command-based-project:Constants>
.
The relevant parts of the constants file from the RamseteCommand Example Project (Java, C++) can be seen below.
Firstly, we must enter the feedforward and feedback gains which we obtained from the identification tool.
Note
Feedforward and feedback gains do not, in general, transfer across robots. Do not use the gains from this tutorial for your own robot.
Additionally, we must create an instance of the DifferentialDriveKinematics
class, which allows us to use the trackwidth (i.e. horizontal distance between the wheels) of the robot to convert from chassis speeds to wheel speeds. As elsewhere, we keep our units in meters.
We must also decide on a nominal max acceleration and max velocity for the robot during path-following. The maximum velocity value should be set somewhat below the nominal free-speed of the robot. Due to the later use of the DifferentialDriveVoltageConstraint
, the maximum acceleration value is not extremely crucial.
Finally, we must include a pair of parameters for the RAMSETE controller. The values shown below should work well for most robots, provided distances have been correctly measured in meters - for more information on tuning these values (if it is required), see docs/software/advanced-controls/trajectories/ramsete:Constructing the Ramsete Controller Object
.