|
LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
|
#include <chassisControllerPid.hpp>
Public Member Functions | |
| ChassisControllerPID (TimeUtil itimeUtil, std::shared_ptr< ChassisModel > imodel, std::unique_ptr< IterativePosPIDController > idistanceController, std::unique_ptr< IterativePosPIDController > iturnController, std::unique_ptr< IterativePosPIDController > iangleController, const AbstractMotor::GearsetRatioPair &igearset=AbstractMotor::gearset::green, const ChassisScales &iscales=ChassisScales({1, 1}, imev5GreenTPR), std::shared_ptr< Logger > ilogger=Logger::getDefaultLogger()) | |
| ChassisController using PID control. | |
| ChassisControllerPID (const ChassisControllerPID &)=delete | |
| ChassisControllerPID (ChassisControllerPID &&other)=delete | |
| ChassisControllerPID & | operator= (const ChassisControllerPID &other)=delete |
| ChassisControllerPID & | operator= (ChassisControllerPID &&other)=delete |
| ~ChassisControllerPID () override | |
| void | moveDistance (QLength itarget) override |
| Drives the robot straight for a distance (using closed-loop control). | |
| void | moveRaw (double itarget) override |
| Drives the robot straight for a distance (using closed-loop control). | |
| void | moveDistanceAsync (QLength itarget) override |
| Sets the target distance for the robot to drive straight (using closed-loop control). | |
| void | moveRawAsync (double itarget) override |
| Sets the target distance for the robot to drive straight (using closed-loop control). | |
| void | turnAngle (QAngle idegTarget) override |
| Turns the robot clockwise in place (using closed-loop control). | |
| void | turnRaw (double idegTarget) override |
| Turns the robot clockwise in place (using closed-loop control). | |
| void | turnAngleAsync (QAngle idegTarget) override |
| Sets the target angle for the robot to turn clockwise in place (using closed-loop control). | |
| void | turnRawAsync (double idegTarget) override |
| Sets the target angle for the robot to turn clockwise in place (using closed-loop control). | |
| void | setTurnsMirrored (bool ishouldMirror) override |
| Sets whether turns should be mirrored. | |
| bool | isSettled () override |
| Checks whether the internal controllers are currently settled. | |
| void | waitUntilSettled () override |
| Delays until the currently executing movement completes. | |
| ChassisScales | getChassisScales () const override |
| Gets the ChassisScales. | |
| AbstractMotor::GearsetRatioPair | getGearsetRatioPair () const override |
| Gets the GearsetRatioPair. | |
| void | setVelocityMode (bool ivelocityMode) |
| Sets the velocity mode flag. | |
| void | setGains (const IterativePosPIDController::Gains &idistanceGains, const IterativePosPIDController::Gains &iturnGains, const IterativePosPIDController::Gains &iangleGains) |
| Sets the gains for all controllers. | |
| std::tuple< IterativePosPIDController::Gains, IterativePosPIDController::Gains, IterativePosPIDController::Gains > | getGains () const |
| Gets the current controller gains. | |
| void | startThread () |
| Starts the internal thread. | |
| CrossplatformThread * | getThread () const |
| Returns the underlying thread handle. | |
| void | stop () override |
| Interrupts the current movement to stop the robot. | |
| void | setMaxVelocity (double imaxVelocity) override |
| Sets a new maximum velocity in RPM [0-600]. | |
| double | getMaxVelocity () const override |
| std::shared_ptr< ChassisModel > | getModel () override |
| ChassisModel & | model () override |
Public Member Functions inherited from okapi::ChassisController | |
| ChassisController ()=default | |
| A ChassisController adds a closed-loop layer on top of a ChassisModel. | |
| virtual | ~ChassisController ()=default |
Protected Types | |
| enum | modeType { distance , angle , none } |
Protected Member Functions | |
| void | loop () |
| bool | waitForDistanceSettled () |
| Wait for the distance setup (distancePid and anglePid) to settle. | |
| bool | waitForAngleSettled () |
| Wait for the angle setup (anglePid) to settle. | |
| void | stopAfterSettled () |
| Stops all the controllers and the ChassisModel. | |
Static Protected Member Functions | |
| static void | trampoline (void *context) |
Protected Attributes | |
| std::shared_ptr< Logger > | logger |
| bool | normalTurns {true} |
| std::shared_ptr< ChassisModel > | chassisModel |
| TimeUtil | timeUtil |
| std::unique_ptr< IterativePosPIDController > | distancePid |
| std::unique_ptr< IterativePosPIDController > | turnPid |
| std::unique_ptr< IterativePosPIDController > | anglePid |
| ChassisScales | scales |
| AbstractMotor::GearsetRatioPair | gearsetRatioPair |
| bool | velocityMode {true} |
| std::atomic_bool | doneLooping {true} |
| std::atomic_bool | doneLoopingSeen {true} |
| std::atomic_bool | newMovement {false} |
| std::atomic_bool | dtorCalled {false} |
| QTime | threadSleepTime {10_ms} |
| modeType | mode {none} |
| CrossplatformThread * | task {nullptr} |
Definition at line 18 of file chassisControllerPid.hpp.
|
protected |
| Enumerator | |
|---|---|
| distance | |
| angle | |
| none | |
Definition at line 270 of file chassisControllerPid.hpp.
| okapi::ChassisControllerPID::ChassisControllerPID | ( | TimeUtil | itimeUtil, |
| std::shared_ptr< ChassisModel > | imodel, | ||
| std::unique_ptr< IterativePosPIDController > | idistanceController, | ||
| std::unique_ptr< IterativePosPIDController > | iturnController, | ||
| std::unique_ptr< IterativePosPIDController > | iangleController, | ||
| const AbstractMotor::GearsetRatioPair & | igearset = AbstractMotor::gearset::green, |
||
| const ChassisScales & | iscales = ChassisScales({1, 1}, imev5GreenTPR), |
||
| std::shared_ptr< Logger > | ilogger = Logger::getDefaultLogger() |
||
| ) |
ChassisController using PID control.
Puts the motors into encoder count units. Throws a std::invalid_argument exception if the gear ratio is zero.
| itimeUtil | The TimeUtil. |
| imodel | The ChassisModel used to read from sensors/write to motors. |
| idistanceController | The PID controller that controls chassis distance for driving straight. |
| iturnController | The PID controller that controls chassis angle for turning. |
| iangleController | The PID controller that controls chassis angle for driving straight. |
| igearset | The internal gearset and external ratio used on the drive motors. |
| iscales | The ChassisScales. |
| ilogger | The logger this instance will log to. |
|
delete |
|
delete |
|
override |
|
overridevirtual |
Gets the ChassisScales.
Implements okapi::ChassisController.
| std::tuple< IterativePosPIDController::Gains, IterativePosPIDController::Gains, IterativePosPIDController::Gains > okapi::ChassisControllerPID::getGains | ( | ) | const |
Gets the current controller gains.
|
overridevirtual |
Gets the GearsetRatioPair.
Implements okapi::ChassisController.
|
overridevirtual |
Implements okapi::ChassisController.
|
overridevirtual |
Implements okapi::ChassisController.
| CrossplatformThread * okapi::ChassisControllerPID::getThread | ( | ) | const |
Returns the underlying thread handle.
|
overridevirtual |
Checks whether the internal controllers are currently settled.
Implements okapi::ChassisController.
|
protected |
|
overridevirtual |
Implements okapi::ChassisController.
|
overridevirtual |
Drives the robot straight for a distance (using closed-loop control).
| itarget | distance to travel |
Implements okapi::ChassisController.
|
overridevirtual |
Sets the target distance for the robot to drive straight (using closed-loop control).
| itarget | distance to travel |
Implements okapi::ChassisController.
|
overridevirtual |
Drives the robot straight for a distance (using closed-loop control).
| itarget | distance to travel in motor degrees |
Implements okapi::ChassisController.
|
overridevirtual |
Sets the target distance for the robot to drive straight (using closed-loop control).
| itarget | distance to travel in motor degrees |
Implements okapi::ChassisController.
|
delete |
|
delete |
| void okapi::ChassisControllerPID::setGains | ( | const IterativePosPIDController::Gains & | idistanceGains, |
| const IterativePosPIDController::Gains & | iturnGains, | ||
| const IterativePosPIDController::Gains & | iangleGains | ||
| ) |
Sets the gains for all controllers.
| idistanceGains | The distance controller gains. |
| iturnGains | The turn controller gains. |
| iangleGains | The angle controller gains. |
|
overridevirtual |
Sets a new maximum velocity in RPM [0-600].
In voltage mode, the max velocity is ignored and a max voltage should be set on the underlying ChassisModel instead.
| imaxVelocity | The new maximum velocity. |
Implements okapi::ChassisController.
|
overridevirtual |
Sets whether turns should be mirrored.
| ishouldMirror | whether turns should be mirrored |
Implements okapi::ChassisController.
| void okapi::ChassisControllerPID::setVelocityMode | ( | bool | ivelocityMode | ) |
Sets the velocity mode flag.
When the controller is in velocity mode, the control loop will set motor velocities. When the controller is in voltage mode (ivelocityMode = false), the control loop will set motor voltages. Additionally, when the controller is in voltage mode, it will not obey maximum velocity limits.
| ivelocityMode | Whether the controller should be in velocity or voltage mode. |
| void okapi::ChassisControllerPID::startThread | ( | ) |
Starts the internal thread.
This method is called by the ChassisControllerBuilder when making a new instance of this class.
|
overridevirtual |
Interrupts the current movement to stop the robot.
Implements okapi::ChassisController.
|
protected |
Stops all the controllers and the ChassisModel.
|
staticprotected |
|
overridevirtual |
Turns the robot clockwise in place (using closed-loop control).
| idegTarget | angle to turn for |
Implements okapi::ChassisController.
|
overridevirtual |
Sets the target angle for the robot to turn clockwise in place (using closed-loop control).
| idegTarget | angle to turn for |
Implements okapi::ChassisController.
|
overridevirtual |
Turns the robot clockwise in place (using closed-loop control).
| idegTarget | angle to turn for in motor degrees |
Implements okapi::ChassisController.
|
overridevirtual |
Sets the target angle for the robot to turn clockwise in place (using closed-loop control).
| idegTarget | angle to turn for in motor degrees |
Implements okapi::ChassisController.
|
protected |
Wait for the angle setup (anglePid) to settle.
|
protected |
Wait for the distance setup (distancePid and anglePid) to settle.
|
overridevirtual |
Delays until the currently executing movement completes.
Implements okapi::ChassisController.
|
protected |
Definition at line 238 of file chassisControllerPid.hpp.
|
protected |
Definition at line 234 of file chassisControllerPid.hpp.
|
protected |
Definition at line 236 of file chassisControllerPid.hpp.
|
protected |
Definition at line 242 of file chassisControllerPid.hpp.
|
protected |
Definition at line 243 of file chassisControllerPid.hpp.
|
protected |
Definition at line 245 of file chassisControllerPid.hpp.
|
protected |
Definition at line 240 of file chassisControllerPid.hpp.
|
protected |
Definition at line 232 of file chassisControllerPid.hpp.
Definition at line 271 of file chassisControllerPid.hpp.
|
protected |
Definition at line 244 of file chassisControllerPid.hpp.
|
protected |
Definition at line 233 of file chassisControllerPid.hpp.
|
protected |
Definition at line 239 of file chassisControllerPid.hpp.
|
protected |
Definition at line 273 of file chassisControllerPid.hpp.
|
protected |
Definition at line 246 of file chassisControllerPid.hpp.
|
protected |
Definition at line 235 of file chassisControllerPid.hpp.
|
protected |
Definition at line 237 of file chassisControllerPid.hpp.
|
protected |
Definition at line 241 of file chassisControllerPid.hpp.