Help with multiple c++ SwerveControllerCommands and PID Controllers

Hi,
Setup:- C++ Swerve Drive Robot, loosely based off Sample Code for SwerveControllerCommand project that has been modified to use Path Planner Trajectories.
Link to Sample Code
Do you need multiple instances of the theta, x and y PID controllers if you are creating multiple Autos, that have multiple paths segments to follow during these autos, and these paths are being loaded and converted into trajectories when the robot container is constructed and the all of the various auto CommandGroups are declared before auto starts.

You can only be following one trajectory at any one point in time, so in reality only one lot of the three PID controllers should be needed. I don’t fully understand move semantics, but from what I understand, you are moving the ownership/scope of objects, which effects when they are released and memory is handed back to system.

The SwerveControllerCommand class creates a HolonomicDriveController object using the 3 PID controller you give to the constructor of the SwerveControllerCommand, then later on you are moving the newly created SwerveControllerCommand object into a commandgroup with a std::move(), does this move effect/change the scope of the PID controllers (If they were not defined inline like the theta controller is in the sample code)

In Summary, are you able to define just one instance of the X, Y and Theta PID controllers and then use the same instance for every SwerveControllerCommand you create?

Thanks again.
Warren

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