okapi::ChassisControllerIntegrated class

Base classes

class ChassisController

Constructors, destructors, conversion operators

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.

Public functions

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.
auto isSettled() -> bool 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.
auto getChassisScales() const -> ChassisScales override
Get the ChassisScales.
auto getGearsetRatioPair() const -> AbstractMotor::GearsetRatioPair override
Get the GearsetRatioPair.
auto getModel() -> std::shared_ptr<ChassisModel> override
auto model() -> ChassisModel& override
void setMaxVelocity(double imaxVelocity) override
Sets a new maximum velocity in RPM [0-600].
auto getMaxVelocity() const -> double override

Protected variables

std::shared_ptr<Logger> logger
bool normalTurns
std::shared_ptr<ChassisModel> chassisModel
TimeUtil timeUtil
std::unique_ptr<AsyncPosIntegratedController> leftController
std::unique_ptr<AsyncPosIntegratedController> rightController
int lastTarget
ChassisScales scales
AbstractMotor::GearsetRatioPair gearsetRatioPair

Function documentation

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.

Parameters
itimeUtil The TimeUtil.
imodel The ChassisModel used to read from sensors/write to motors.
ileftController The controller used for the left side motors.
irightController The controller used for the right side motors.
igearset The internal gearset and external ratio used on the drive motors.
iscales The ChassisScales.
ilogger The logger this instance will log to.

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.

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

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

Parameters
itarget distance to travel
// Drive forward 6 inches
chassis->moveDistance(6_in);

// Drive backward 0.2 meters
chassis->moveDistance(-0.2_m);

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

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

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

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

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

Parameters
itarget distance to travel

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

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

Parameters
itarget distance to travel in motor degrees

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

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

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

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

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

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

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

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

Parameters
idegTarget angle to turn for

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

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

Parameters
idegTarget angle to turn for in motor degrees

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

Sets whether turns should be mirrored.

Parameters
ishouldMirror whether turns should be mirrored

bool okapi::ChassisControllerIntegrated::isSettled() override

Checks whether the internal controllers are currently settled.

Returns Whether this ChassisController is settled.

std::shared_ptr<ChassisModel> okapi::ChassisControllerIntegrated::getModel() override

Returns The internal ChassisModel.

ChassisModel& okapi::ChassisControllerIntegrated::model() override

Returns The internal ChassisModel.

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

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

Parameters
imaxVelocity The new maximum velocity.

double okapi::ChassisControllerIntegrated::getMaxVelocity() const override

Returns The maximum velocity in RPM [0-600].