LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::ChassisControllerIntegrated Class Reference

#include <chassisControllerIntegrated.hpp>

Inheritance diagram for okapi::ChassisControllerIntegrated:
okapi::ChassisController

Public Member Functions

 ChassisControllerIntegrated (const TimeUtil &itimeUtil, std::shared_ptr< ChassisModel > imodel, std::unique_ptr< AsyncPosIntegratedController > ileftController, std::unique_ptr< AsyncPosIntegratedController > irightController, const AbstractMotor::GearsetRatioPair &igearset=AbstractMotor::gearset::green, const ChassisScales &iscales=ChassisScales({1, 1}, imev5GreenTPR), std::shared_ptr< Logger > ilogger=Logger::getDefaultLogger())
 ChassisController using the V5 motor's integrated control.
 
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.
 
void stop () override
 Interrupts the current movement to stop the robot.
 
ChassisScales getChassisScales () const override
 Get the ChassisScales.
 
AbstractMotor::GearsetRatioPair getGearsetRatioPair () const override
 Get the GearsetRatioPair.
 
std::shared_ptr< ChassisModelgetModel () override
 
ChassisModelmodel () override
 
void setMaxVelocity (double imaxVelocity) override
 Sets a new maximum velocity in RPM [0-600].
 
double getMaxVelocity () const 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 Attributes

std::shared_ptr< Loggerlogger
 
bool normalTurns {true}
 
std::shared_ptr< ChassisModelchassisModel
 
TimeUtil timeUtil
 
std::unique_ptr< AsyncPosIntegratedControllerleftController
 
std::unique_ptr< AsyncPosIntegratedControllerrightController
 
int lastTarget
 
ChassisScales scales
 
AbstractMotor::GearsetRatioPair gearsetRatioPair
 

Detailed Description

Definition at line 14 of file chassisControllerIntegrated.hpp.

Constructor & Destructor Documentation

◆ ChassisControllerIntegrated()

okapi::ChassisControllerIntegrated::ChassisControllerIntegrated ( const TimeUtil itimeUtil,
std::shared_ptr< ChassisModel imodel,
std::unique_ptr< AsyncPosIntegratedController ileftController,
std::unique_ptr< AsyncPosIntegratedController irightController,
const AbstractMotor::GearsetRatioPair igearset = AbstractMotor::gearset::green,
const ChassisScales iscales = ChassisScales({1, 1}, imev5GreenTPR),
std::shared_ptr< Logger ilogger = Logger::getDefaultLogger() 
)

ChassisController using the V5 motor's integrated control.

Puts the motors into encoder count units. Throws a std::invalid_argument exception if the gear ratio is zero. The initial model's max velocity will be propagated to the controllers.

Parameters
itimeUtilThe TimeUtil.
imodelThe ChassisModel used to read from sensors/write to motors.
ileftControllerThe controller used for the left side motors.
irightControllerThe controller used for the right side motors.
igearsetThe internal gearset and external ratio used on the drive motors.
iscalesThe ChassisScales.
iloggerThe logger this instance will log to.

Member Function Documentation

◆ getChassisScales()

ChassisScales okapi::ChassisControllerIntegrated::getChassisScales ( ) const
overridevirtual

◆ getGearsetRatioPair()

AbstractMotor::GearsetRatioPair okapi::ChassisControllerIntegrated::getGearsetRatioPair ( ) const
overridevirtual

Get the GearsetRatioPair.

Implements okapi::ChassisController.

◆ getMaxVelocity()

double okapi::ChassisControllerIntegrated::getMaxVelocity ( ) const
overridevirtual
Returns
The maximum velocity in RPM [0-600].

Implements okapi::ChassisController.

◆ getModel()

std::shared_ptr< ChassisModel > okapi::ChassisControllerIntegrated::getModel ( )
overridevirtual
Returns
The internal ChassisModel.

Implements okapi::ChassisController.

◆ isSettled()

bool okapi::ChassisControllerIntegrated::isSettled ( )
overridevirtual

Checks whether the internal controllers are currently settled.

Returns
Whether this ChassisController is settled.

Implements okapi::ChassisController.

◆ model()

ChassisModel & okapi::ChassisControllerIntegrated::model ( )
overridevirtual
Returns
The internal ChassisModel.

Implements okapi::ChassisController.

◆ moveDistance()

void okapi::ChassisControllerIntegrated::moveDistance ( QLength  itarget)
overridevirtual

Drives the robot straight for a distance (using closed-loop control).

// Drive forward 6 inches
chassis->moveDistance(6_in);
// Drive backward 0.2 meters
chassis->moveDistance(-0.2_m);
Drive chassis
The drive chassis, configured in main.cpp and used everywhere else.
Parameters
itargetdistance to travel

Implements okapi::ChassisController.

◆ moveDistanceAsync()

void okapi::ChassisControllerIntegrated::moveDistanceAsync ( QLength  itarget)
overridevirtual

Sets the target distance for the robot to drive straight (using closed-loop control).

Parameters
itargetdistance to travel

Implements okapi::ChassisController.

◆ moveRaw()

void okapi::ChassisControllerIntegrated::moveRaw ( double  itarget)
overridevirtual

Drives the robot straight for a distance (using closed-loop control).

// Drive forward by spinning the motors 400 degrees
chassis->moveRaw(400);
Parameters
itargetdistance to travel in motor degrees

Implements okapi::ChassisController.

◆ moveRawAsync()

void okapi::ChassisControllerIntegrated::moveRawAsync ( double  itarget)
overridevirtual

Sets the target distance for the robot to drive straight (using closed-loop control).

Parameters
itargetdistance to travel in motor degrees

Implements okapi::ChassisController.

◆ setMaxVelocity()

void okapi::ChassisControllerIntegrated::setMaxVelocity ( double  imaxVelocity)
overridevirtual

Sets a new maximum velocity in RPM [0-600].

Parameters
imaxVelocityThe new maximum velocity.

Implements okapi::ChassisController.

◆ setTurnsMirrored()

void okapi::ChassisControllerIntegrated::setTurnsMirrored ( bool  ishouldMirror)
overridevirtual

Sets whether turns should be mirrored.

Parameters
ishouldMirrorwhether turns should be mirrored

Implements okapi::ChassisController.

◆ stop()

void okapi::ChassisControllerIntegrated::stop ( )
overridevirtual

Interrupts the current movement to stop the robot.

Implements okapi::ChassisController.

◆ turnAngle()

void okapi::ChassisControllerIntegrated::turnAngle ( QAngle  idegTarget)
overridevirtual

Turns the robot clockwise in place (using closed-loop control).

// Turn 90 degrees clockwise
chassis->turnAngle(90_deg);
Parameters
idegTargetangle to turn for

Implements okapi::ChassisController.

◆ turnAngleAsync()

void okapi::ChassisControllerIntegrated::turnAngleAsync ( QAngle  idegTarget)
overridevirtual

Sets the target angle for the robot to turn clockwise in place (using closed-loop control).

Parameters
idegTargetangle to turn for

Implements okapi::ChassisController.

◆ turnRaw()

void okapi::ChassisControllerIntegrated::turnRaw ( double  idegTarget)
overridevirtual

Turns the robot clockwise in place (using closed-loop control).

// Turn clockwise by spinning the motors 200 degrees
chassis->turnRaw(200);
Parameters
idegTargetangle to turn for in motor degrees

Implements okapi::ChassisController.

◆ turnRawAsync()

void okapi::ChassisControllerIntegrated::turnRawAsync ( double  idegTarget)
overridevirtual

Sets the target angle for the robot to turn clockwise in place (using closed-loop control).

Parameters
idegTargetangle to turn for in motor degrees

Implements okapi::ChassisController.

◆ waitUntilSettled()

void okapi::ChassisControllerIntegrated::waitUntilSettled ( )
overridevirtual

Delays until the currently executing movement completes.

Implements okapi::ChassisController.

Member Data Documentation

◆ chassisModel

std::shared_ptr<ChassisModel> okapi::ChassisControllerIntegrated::chassisModel
protected

Definition at line 176 of file chassisControllerIntegrated.hpp.

◆ gearsetRatioPair

AbstractMotor::GearsetRatioPair okapi::ChassisControllerIntegrated::gearsetRatioPair
protected

Definition at line 182 of file chassisControllerIntegrated.hpp.

◆ lastTarget

int okapi::ChassisControllerIntegrated::lastTarget
protected

Definition at line 180 of file chassisControllerIntegrated.hpp.

◆ leftController

std::unique_ptr<AsyncPosIntegratedController> okapi::ChassisControllerIntegrated::leftController
protected

Definition at line 178 of file chassisControllerIntegrated.hpp.

◆ logger

std::shared_ptr<Logger> okapi::ChassisControllerIntegrated::logger
protected

Definition at line 174 of file chassisControllerIntegrated.hpp.

◆ normalTurns

bool okapi::ChassisControllerIntegrated::normalTurns {true}
protected

Definition at line 175 of file chassisControllerIntegrated.hpp.

◆ rightController

std::unique_ptr<AsyncPosIntegratedController> okapi::ChassisControllerIntegrated::rightController
protected

Definition at line 179 of file chassisControllerIntegrated.hpp.

◆ scales

ChassisScales okapi::ChassisControllerIntegrated::scales
protected

Definition at line 181 of file chassisControllerIntegrated.hpp.

◆ timeUtil

TimeUtil okapi::ChassisControllerIntegrated::timeUtil
protected

Definition at line 177 of file chassisControllerIntegrated.hpp.


The documentation for this class was generated from the following file: