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

#include <hDriveModel.hpp>

Inheritance diagram for okapi::HDriveModel:
okapi::ChassisModel okapi::ReadOnlyChassisModel

Public Member Functions

 HDriveModel (std::shared_ptr< AbstractMotor > ileftSideMotor, std::shared_ptr< AbstractMotor > irightSideMotor, std::shared_ptr< AbstractMotor > imiddleMotor, std::shared_ptr< ContinuousRotarySensor > ileftEnc, std::shared_ptr< ContinuousRotarySensor > irightEnc, std::shared_ptr< ContinuousRotarySensor > imiddleEnc, double imaxVelocity, double imaxVoltage)
 Model for an h-drive (wheels parallel with robot's direction of motion, with an additional wheel perpendicular to those).
 
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.
 
virtual void hArcade (double irightSpeed, double iforwardSpeed, double iyaw, double ithreshold=0)
 Drive the robot with an arcade drive layout.
 
virtual void hCurvature (double irightSpeed, double iforwardSpeed, double icurvature, double ithreshold=0)
 Drive the robot with an curvature drive layout.
 
void left (double ispeed) override
 Power the left side motors.
 
void right (double ispeed) override
 Power the right side motors.
 
virtual void middle (double ispeed)
 Power the middle 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.
 
std::shared_ptr< AbstractMotorgetMiddleMotor () const
 
- 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< AbstractMotormiddleMotor
 
std::shared_ptr< ContinuousRotarySensorleftSensor
 
std::shared_ptr< ContinuousRotarySensorrightSensor
 
std::shared_ptr< ContinuousRotarySensormiddleSensor
 

Detailed Description

Definition at line 13 of file hDriveModel.hpp.

Constructor & Destructor Documentation

◆ HDriveModel()

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

Model for an h-drive (wheels parallel with robot's direction of motion, with an additional wheel perpendicular to those).

When the left and right side motors are powered +100%, the robot should move forward in a straight line. When the middle motor is powered +100%, the robot should strafe right in a straight line.

Parameters
ileftSideMotorThe left side motor.
irightSideMotorThe right side motor.
imiddleMotorThe middle (perpendicular) motor.
ileftEncThe left side encoder.
irightEncThe right side encoder.
imiddleEncThe middle encoder.

Member Function Documentation

◆ arcade()

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

Drive the robot with an arcade drive layout.

Uses voltage mode. Sets the middle motor to zero velocity.

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

Implements okapi::ChassisModel.

◆ curvature()

void okapi::HDriveModel::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. Sets the middle motor to zero velocity.

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

Implements okapi::ChassisModel.

◆ driveVector()

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

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

Uses velocity mode. Sets the middle motor to zero velocity.

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::HDriveModel::driveVectorVoltage ( double  iforwardSpeed,
double  iyaw 
)
overridevirtual

Drive the robot in an arc.

Uses voltage mode. Sets the middle motor to zero velocity.

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::HDriveModel::forward ( double  ispeed)
overridevirtual

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

Uses velocity mode. Sets the middle motor to zero velocity.

Parameters
ispeedmotor power

Implements okapi::ChassisModel.

◆ getLeftSideMotor()

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

Returns the left side motor.

Returns
the left side motor

◆ getMaxVelocity()

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

Implements okapi::ChassisModel.

◆ getMaxVoltage()

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

Implements okapi::ChassisModel.

◆ getMiddleMotor()

std::shared_ptr< AbstractMotor > okapi::HDriveModel::getMiddleMotor ( ) const
Returns
The middle motor.

◆ getRightSideMotor()

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

Returns the left side motor.

Returns
the left side motor

◆ getSensorVals()

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

Read the sensors.

Returns
sensor readings in the format {left, right, middle}

Implements okapi::ReadOnlyChassisModel.

◆ hArcade()

virtual void okapi::HDriveModel::hArcade ( double  irightSpeed,
double  iforwardSpeed,
double  iyaw,
double  ithreshold = 0 
)
virtual

Drive the robot with an arcade drive layout.

Uses voltage mode.

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

◆ hCurvature()

virtual void okapi::HDriveModel::hCurvature ( double  irightSpeed,
double  iforwardSpeed,
double  icurvature,
double  ithreshold = 0 
)
virtual

Drive the robot with an curvature drive layout.

Uses voltage mode.

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

◆ left()

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

Power the left side motors.

Uses velocity mode.

Parameters
ispeedThe motor power.

Implements okapi::ChassisModel.

◆ middle()

virtual void okapi::HDriveModel::middle ( double  ispeed)
virtual

Power the middle motors.

Uses velocity mode.

Parameters
ispeedThe motor power.

◆ resetSensors()

void okapi::HDriveModel::resetSensors ( )
overridevirtual

Reset the sensors to their zero point.

Implements okapi::ChassisModel.

◆ right()

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

Power the right side motors.

Uses velocity mode.

Parameters
ispeedThe motor power.

Implements okapi::ChassisModel.

◆ rotate()

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

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

Uses velocity mode. Sets the middle motor to zero velocity.

Parameters
ispeedmotor power

Implements okapi::ChassisModel.

◆ setBrakeMode()

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

Set the brake mode for each motor.

Parameters
modenew brake mode

Implements okapi::ChassisModel.

◆ setEncoderUnits()

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

Set the encoder units for each motor.

Parameters
unitsnew motor encoder units

Implements okapi::ChassisModel.

◆ setGearing()

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

Set the gearset for each motor.

Parameters
gearsetnew motor gearset

Implements okapi::ChassisModel.

◆ setMaxVelocity()

void okapi::HDriveModel::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::HDriveModel::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::HDriveModel::stop ( )
overridevirtual

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

Uses velocity mode.

Implements okapi::ChassisModel.

◆ tank()

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

Drive the robot with a tank drive layout.

Uses voltage mode. Sets the middle motor to zero velocity.

Parameters
ileftSpeedleft side speed
irightSpeedright side speed
ithresholddeadband on joystick values

Implements okapi::ChassisModel.

Member Data Documentation

◆ leftSensor

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

Definition at line 243 of file hDriveModel.hpp.

◆ leftSideMotor

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

Definition at line 240 of file hDriveModel.hpp.

◆ maxVelocity

double okapi::HDriveModel::maxVelocity
protected

Definition at line 238 of file hDriveModel.hpp.

◆ maxVoltage

double okapi::HDriveModel::maxVoltage
protected

Definition at line 239 of file hDriveModel.hpp.

◆ middleMotor

std::shared_ptr<AbstractMotor> okapi::HDriveModel::middleMotor
protected

Definition at line 242 of file hDriveModel.hpp.

◆ middleSensor

std::shared_ptr<ContinuousRotarySensor> okapi::HDriveModel::middleSensor
protected

Definition at line 245 of file hDriveModel.hpp.

◆ rightSensor

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

Definition at line 244 of file hDriveModel.hpp.

◆ rightSideMotor

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

Definition at line 241 of file hDriveModel.hpp.


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