okapi::ChassisModel class

A version of the ReadOnlyChassisModel that also supports write methods, such as setting motor speed.

Because this class can write to motors, there can only be one owner and as such copying is disabled.

Base classes

class ReadOnlyChassisModel
A version of the ChassisModel that only supports read methods, such as querying sensor values.

Derived classes

class HDriveModel
class SkidSteerModel
class XDriveModel

Constructors, destructors, conversion operators

ChassisModel() defaulted explicit
ChassisModel(const ChassisModel&) deleted

Public functions

auto operator=(const ChassisModel&) -> ChassisModel& deleted
void forward(double ispeed) pure virtual
Drive the robot forwards (using open-loop control).
void driveVector(double iforwardSpeed, double iyaw) pure virtual
Drive the robot in an arc (using open-loop control).
void driveVectorVoltage(double iforwardSpeed, double iyaw) pure virtual
Drive the robot in an arc.
void rotate(double ispeed) pure virtual
Turn the robot clockwise (using open-loop control).
void stop() pure virtual
Stop the robot (set all the motors to 0).
void tank(double ileftSpeed, double irightSpeed, double ithreshold = 0) pure virtual
Drive the robot with a tank drive layout.
void arcade(double iforwardSpeed, double iyaw, double ithreshold = 0) pure virtual
Drive the robot with an arcade drive layout.
void curvature(double iforwardSpeed, double icurvature, double ithreshold = 0) pure virtual
Drive the robot with a curvature drive layout.
void left(double ispeed) pure virtual
Power the left side motors.
void right(double ispeed) pure virtual
Power the right side motors.
void resetSensors() pure virtual
Reset the sensors to their zero point.
void setBrakeMode(AbstractMotor::brakeMode mode) pure virtual
Set the brake mode for each motor.
void setEncoderUnits(AbstractMotor::encoderUnits units) pure virtual
Set the encoder units for each motor.
void setGearing(AbstractMotor::gearset gearset) pure virtual
Set the gearset for each motor.
void setMaxVelocity(double imaxVelocity) pure virtual
Sets a new maximum velocity in RPM.
auto getMaxVelocity() const -> double pure virtual
void setMaxVoltage(double imaxVoltage) pure virtual
Sets a new maximum voltage in mV in the range [0-12000].
auto getMaxVoltage() const -> double pure virtual

Function documentation

void okapi::ChassisModel::forward(double ispeed) pure virtual

Drive the robot forwards (using open-loop control).

Uses velocity mode.

void okapi::ChassisModel::driveVector(double iforwardSpeed, double iyaw) pure virtual

Drive the robot in an arc (using open-loop control).

Parameters
iforwardSpeed
iyaw speed around the vertical axis

Uses velocity mode. The algorithm is (approximately): leftPower = forwardSpeed + yaw rightPower = forwardSpeed - yaw

void okapi::ChassisModel::driveVectorVoltage(double iforwardSpeed, double iyaw) pure virtual

Drive the robot in an arc.

Parameters
iforwardSpeed
iyaw speed around the vertical axis

Uses voltage mode. The algorithm is (approximately): leftPower = forwardSpeed + yaw rightPower = forwardSpeed - yaw

void okapi::ChassisModel::rotate(double ispeed) pure virtual

Turn the robot clockwise (using open-loop control).

Parameters
ispeed motor power

Uses velocity mode.

void okapi::ChassisModel::stop() pure virtual

Stop the robot (set all the motors to 0).

Uses velocity mode.

void okapi::ChassisModel::tank(double ileftSpeed, double irightSpeed, double ithreshold = 0) pure virtual

Drive the robot with a tank drive layout.

Parameters
ileftSpeed left side speed
irightSpeed right side speed
ithreshold deadband on joystick values

Uses voltage mode.

void okapi::ChassisModel::arcade(double iforwardSpeed, double iyaw, double ithreshold = 0) pure virtual

Drive the robot with an arcade drive layout.

Parameters
iforwardSpeed speed forward direction
iyaw speed around the vertical axis
ithreshold deadband on joystick values

Uses voltage mode.

void okapi::ChassisModel::curvature(double iforwardSpeed, double icurvature, double ithreshold = 0) pure virtual

Drive the robot with a curvature drive layout.

Parameters
iforwardSpeed speed in the forward direction
icurvature curvature (inverse of radius) to drive in
ithreshold deadband on joystick values

The robot drives in constant radius turns where you control the curvature (inverse of radius) you drive in. This is advantageous because the forward speed will not affect the rate of turning. The algorithm switches to arcade if the forward speed is 0. Uses voltage mode.

void okapi::ChassisModel::left(double ispeed) pure virtual

Power the left side motors.

Uses velocity mode.

void okapi::ChassisModel::right(double ispeed) pure virtual

Power the right side motors.

Uses velocity mode.

void okapi::ChassisModel::setBrakeMode(AbstractMotor::brakeMode mode) pure virtual

Set the brake mode for each motor.

Parameters
mode new brake mode

void okapi::ChassisModel::setEncoderUnits(AbstractMotor::encoderUnits units) pure virtual

Set the encoder units for each motor.

Parameters
units new motor encoder units

void okapi::ChassisModel::setGearing(AbstractMotor::gearset gearset) pure virtual

Set the gearset for each motor.

Parameters
gearset new motor gearset

void okapi::ChassisModel::setMaxVelocity(double imaxVelocity) pure virtual

Sets a new maximum velocity in RPM.

Parameters
imaxVelocity The new maximum velocity.

The usable maximum depends on the maximum velocity of the currently installed gearset. If the configured maximum velocity is greater than the attainable maximum velocity from the currently installed gearset, the ChassisModel will still scale to that velocity.

double okapi::ChassisModel::getMaxVelocity() const pure virtual

Returns The current maximum velocity.

void okapi::ChassisModel::setMaxVoltage(double imaxVoltage) pure virtual

Sets a new maximum voltage in mV in the range [0-12000].

Parameters
imaxVoltage The new maximum voltage.

double okapi::ChassisModel::getMaxVoltage() const pure virtual

Returns The maximum voltage in mV [0-12000].