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

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

#include <chassisModel.hpp>

Inheritance diagram for okapi::ChassisModel:
okapi::ReadOnlyChassisModel okapi::HDriveModel okapi::SkidSteerModel okapi::XDriveModel okapi::ThreeEncoderSkidSteerModel okapi::ThreeEncoderXDriveModel

Public Member Functions

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

Detailed Description

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.

Definition at line 21 of file chassisModel.hpp.

Constructor & Destructor Documentation

◆ ChassisModel() [1/2]

okapi::ChassisModel::ChassisModel ( )
explicitdefault

◆ ChassisModel() [2/2]

okapi::ChassisModel::ChassisModel ( const ChassisModel )
delete

Member Function Documentation

◆ arcade()

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

Drive the robot with an arcade drive layout.

Uses voltage mode.

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

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ curvature()

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

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

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ driveVector()

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

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

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

Parameters
iforwadSpeedspeed in the forward direction
iyawspeed around the vertical axis

Implemented in okapi::XDriveModel, okapi::HDriveModel, and okapi::SkidSteerModel.

◆ driveVectorVoltage()

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

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

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ forward()

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

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

Uses velocity mode.

Parameters
ipowermotor power

Implemented in okapi::XDriveModel, okapi::HDriveModel, and okapi::SkidSteerModel.

◆ getMaxVelocity()

virtual double okapi::ChassisModel::getMaxVelocity ( ) const
pure virtual
Returns
The current maximum velocity.

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ getMaxVoltage()

virtual double okapi::ChassisModel::getMaxVoltage ( ) const
pure virtual
Returns
The maximum voltage in mV [0-12000].

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ left()

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

Power the left side motors.

Uses velocity mode.

Parameters
ipowermotor power

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ operator=()

ChassisModel & okapi::ChassisModel::operator= ( const ChassisModel )
delete

◆ resetSensors()

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

◆ right()

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

Power the right side motors.

Uses velocity mode.

Parameters
ipowermotor power

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ rotate()

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

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

Uses velocity mode.

Parameters
ispeedmotor power

Implemented in okapi::XDriveModel, okapi::HDriveModel, and okapi::SkidSteerModel.

◆ setBrakeMode()

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

Set the brake mode for each motor.

Parameters
modenew brake mode

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ setEncoderUnits()

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

Set the encoder units for each motor.

Parameters
unitsnew motor encoder units

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ setGearing()

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

Set the gearset for each motor.

Parameters
gearsetnew motor gearset

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ setMaxVelocity()

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

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.

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ setMaxVoltage()

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

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

Parameters
imaxVoltageThe new maximum voltage.

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ stop()

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

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

Uses velocity mode.

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.

◆ tank()

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

Drive the robot with a tank drive layout.

Uses voltage mode.

Parameters
ileftSpeedleft side speed
irightSpeedright side speed
ithresholddeadband on joystick values

Implemented in okapi::HDriveModel, okapi::SkidSteerModel, and okapi::XDriveModel.


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