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

#include <skidSteerModel.hpp>

Inheritance diagram for okapi::SkidSteerModel:
okapi::ChassisModel okapi::ReadOnlyChassisModel okapi::ThreeEncoderSkidSteerModel

Public Member Functions

 SkidSteerModel (std::shared_ptr< AbstractMotor > ileftSideMotor, std::shared_ptr< AbstractMotor > irightSideMotor, std::shared_ptr< ContinuousRotarySensor > ileftEnc, std::shared_ptr< ContinuousRotarySensor > irightEnc, double imaxVelocity, double imaxVoltage)
 Model for a skid steer drive (wheels parallel with robot's direction of motion).
 
void forward (double ispeed) override
 Drive the robot forwards (using open-loop control).
 
void driveVector (double iySpeed, double izRotation) override
 Drive the robot in an arc (using open-loop control).
 
void driveVectorVoltage (double iforwardSpeed, double iyaw) override
 Drive the robot in an arc.
 
void rotate (double ispeed) override
 Turn the robot clockwise (using open-loop control).
 
void stop () override
 Stop the robot (set all the motors to 0).
 
void tank (double ileftSpeed, double irightSpeed, double ithreshold=0) override
 Drive the robot with a tank drive layout.
 
void arcade (double iforwardSpeed, double iyaw, double ithreshold=0) override
 Drive the robot with an arcade drive layout.
 
void curvature (double iforwardSpeed, double icurvature, double ithreshold=0) override
 Drive the robot with a curvature drive layout.
 
void left (double ispeed) override
 Power the left side motors.
 
void right (double ispeed) override
 Power the right side motors.
 
std::valarray< std::int32_t > getSensorVals () const override
 Read the sensors.
 
void resetSensors () override
 Reset the sensors to their zero point.
 
void setBrakeMode (AbstractMotor::brakeMode mode) override
 Set the brake mode for each motor.
 
void setEncoderUnits (AbstractMotor::encoderUnits units) override
 Set the encoder units for each motor.
 
void setGearing (AbstractMotor::gearset gearset) override
 Set the gearset for each motor.
 
void setMaxVelocity (double imaxVelocity) override
 Sets a new maximum velocity in RPM.
 
double getMaxVelocity () const override
 
void setMaxVoltage (double imaxVoltage) override
 Sets a new maximum voltage in mV in the range [0-12000].
 
double getMaxVoltage () const override
 
std::shared_ptr< AbstractMotorgetLeftSideMotor () const
 Returns the left side motor.
 
std::shared_ptr< AbstractMotorgetRightSideMotor () const
 Returns the left side motor.
 
- Public Member Functions inherited from okapi::ChassisModel
 ChassisModel ()=default
 
 ChassisModel (const ChassisModel &)=delete
 
ChassisModeloperator= (const ChassisModel &)=delete
 
- Public Member Functions inherited from okapi::ReadOnlyChassisModel
virtual ~ReadOnlyChassisModel ()=default
 

Protected Attributes

double maxVelocity
 
double maxVoltage
 
std::shared_ptr< AbstractMotorleftSideMotor
 
std::shared_ptr< AbstractMotorrightSideMotor
 
std::shared_ptr< ContinuousRotarySensorleftSensor
 
std::shared_ptr< ContinuousRotarySensorrightSensor
 

Detailed Description

Definition at line 13 of file skidSteerModel.hpp.

Constructor & Destructor Documentation

◆ SkidSteerModel()

okapi::SkidSteerModel::SkidSteerModel ( std::shared_ptr< AbstractMotor ileftSideMotor,
std::shared_ptr< AbstractMotor irightSideMotor,
std::shared_ptr< ContinuousRotarySensor ileftEnc,
std::shared_ptr< ContinuousRotarySensor irightEnc,
double  imaxVelocity,
double  imaxVoltage 
)

Model for a skid steer drive (wheels parallel with robot's direction of motion).

When all motors are powered +100%, the robot should move forward in a straight line.

Parameters
ileftSideMotorThe left side motor.
irightSideMotorThe right side motor.
ileftEncThe left side encoder.
irightEncThe right side encoder.

Member Function Documentation

◆ arcade()

void okapi::SkidSteerModel::arcade ( double  iforwardSpeed,
double  iyaw,
double  ithreshold = 0 
)
overridevirtual

Drive the robot with an arcade drive layout.

Uses voltage mode.

Parameters
iforwardSpeedspeed in the forward direction
iyawspeed around the vertical axis
ithresholddeadband on joystick values

Implements okapi::ChassisModel.

◆ curvature()

void okapi::SkidSteerModel::curvature ( double  iforwardSpeed,
double  icurvature,
double  ithreshold = 0 
)
overridevirtual

Drive the robot with a curvature drive layout.

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.

Parameters
iforwardSpeedspeed in the forward direction
icurvaturecurvature (inverse of radius) to drive in
ithresholddeadband on joystick values

Implements okapi::ChassisModel.

◆ driveVector()

void okapi::SkidSteerModel::driveVector ( double  iySpeed,
double  izRotation 
)
overridevirtual

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

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

Parameters
iySpeedspeed on y axis (forward)
izRotationspeed around z axis (up)

Implements okapi::ChassisModel.

◆ driveVectorVoltage()

void okapi::SkidSteerModel::driveVectorVoltage ( double  iforwardSpeed,
double  iyaw 
)
overridevirtual

Drive the robot in an arc.

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

Parameters
iforwadSpeedspeed in the forward direction
iyawspeed around the vertical axis

Implements okapi::ChassisModel.

◆ forward()

void okapi::SkidSteerModel::forward ( double  ispeed)
overridevirtual

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

Uses velocity mode.

Parameters
ispeedmotor power

Implements okapi::ChassisModel.

◆ getLeftSideMotor()

std::shared_ptr< AbstractMotor > okapi::SkidSteerModel::getLeftSideMotor ( ) const

Returns the left side motor.

Returns
the left side motor

◆ getMaxVelocity()

double okapi::SkidSteerModel::getMaxVelocity ( ) const
overridevirtual
Returns
The current maximum velocity.

Implements okapi::ChassisModel.

◆ getMaxVoltage()

double okapi::SkidSteerModel::getMaxVoltage ( ) const
overridevirtual
Returns
The maximum voltage in mV in the range [0-12000].

Implements okapi::ChassisModel.

◆ getRightSideMotor()

std::shared_ptr< AbstractMotor > okapi::SkidSteerModel::getRightSideMotor ( ) const

Returns the left side motor.

Returns
the left side motor

◆ getSensorVals()

std::valarray< std::int32_t > okapi::SkidSteerModel::getSensorVals ( ) const
overridevirtual

Read the sensors.

Returns
sensor readings in the format {left, right}

Implements okapi::ReadOnlyChassisModel.

Reimplemented in okapi::ThreeEncoderSkidSteerModel.

◆ left()

void okapi::SkidSteerModel::left ( double  ispeed)
overridevirtual

Power the left side motors.

Uses velocity mode.

Parameters
ispeedThe motor power.

Implements okapi::ChassisModel.

◆ resetSensors()

void okapi::SkidSteerModel::resetSensors ( )
overridevirtual

Reset the sensors to their zero point.

Implements okapi::ChassisModel.

Reimplemented in okapi::ThreeEncoderSkidSteerModel.

◆ right()

void okapi::SkidSteerModel::right ( double  ispeed)
overridevirtual

Power the right side motors.

Uses velocity mode.

Parameters
ispeedThe motor power.

Implements okapi::ChassisModel.

◆ rotate()

void okapi::SkidSteerModel::rotate ( double  ispeed)
overridevirtual

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

Uses velocity mode.

Parameters
ispeedmotor power

Implements okapi::ChassisModel.

◆ setBrakeMode()

void okapi::SkidSteerModel::setBrakeMode ( AbstractMotor::brakeMode  mode)
overridevirtual

Set the brake mode for each motor.

Parameters
modenew brake mode

Implements okapi::ChassisModel.

◆ setEncoderUnits()

void okapi::SkidSteerModel::setEncoderUnits ( AbstractMotor::encoderUnits  units)
overridevirtual

Set the encoder units for each motor.

Parameters
unitsnew motor encoder units

Implements okapi::ChassisModel.

◆ setGearing()

void okapi::SkidSteerModel::setGearing ( AbstractMotor::gearset  gearset)
overridevirtual

Set the gearset for each motor.

Parameters
gearsetnew motor gearset

Implements okapi::ChassisModel.

◆ setMaxVelocity()

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

Sets a new maximum velocity in RPM.

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.

Parameters
imaxVelocityThe new maximum velocity.

Implements okapi::ChassisModel.

◆ setMaxVoltage()

void okapi::SkidSteerModel::setMaxVoltage ( double  imaxVoltage)
overridevirtual

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

Parameters
imaxVoltageThe new maximum voltage.

Implements okapi::ChassisModel.

◆ stop()

void okapi::SkidSteerModel::stop ( )
overridevirtual

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

Uses velocity mode.

Implements okapi::ChassisModel.

◆ tank()

void okapi::SkidSteerModel::tank ( double  ileftSpeed,
double  irightSpeed,
double  ithreshold = 0 
)
overridevirtual

Drive the robot with a tank drive layout.

Uses voltage mode.

Parameters
ileftSpeedleft side speed
irightSpeedright side speed
ithresholddeadband on joystick values

Implements okapi::ChassisModel.

Member Data Documentation

◆ leftSensor

std::shared_ptr<ContinuousRotarySensor> okapi::SkidSteerModel::leftSensor
protected

Definition at line 195 of file skidSteerModel.hpp.

◆ leftSideMotor

std::shared_ptr<AbstractMotor> okapi::SkidSteerModel::leftSideMotor
protected

Definition at line 193 of file skidSteerModel.hpp.

◆ maxVelocity

double okapi::SkidSteerModel::maxVelocity
protected

Definition at line 191 of file skidSteerModel.hpp.

◆ maxVoltage

double okapi::SkidSteerModel::maxVoltage
protected

Definition at line 192 of file skidSteerModel.hpp.

◆ rightSensor

std::shared_ptr<ContinuousRotarySensor> okapi::SkidSteerModel::rightSensor
protected

Definition at line 196 of file skidSteerModel.hpp.

◆ rightSideMotor

std::shared_ptr<AbstractMotor> okapi::SkidSteerModel::rightSideMotor
protected

Definition at line 194 of file skidSteerModel.hpp.


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