VEX V5 C++ API
|
Inherited by vex::smartdrive.
Public Member Functions | |
drivetrain (motor_group &leftMotors, motor_group &rightMotors, double wheelTravel=319.1764, double trackWidth=292.1, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0) | |
Creates a new drivetrain object. More... | |
drivetrain (vex::motor &leftMotor, vex::motor &rightMotor, double wheelTravel=319.1764, double trackWidth=292.1, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0) | |
~drivetrain () | |
void | setGearRatio (double ratio) |
Sets the external gear ratio of the drivetrain. More... | |
void | setDriveVelocity (double velocity, velocityUnits units) |
Sets the velocity of the drive based on the parameters set in the command. This command will not run the motors. Any subsequent call that does not contain a specified motor velocity will use this value. More... | |
void | setDriveVelocity (double velocity, percentUnits units) |
void | setTurnVelocity (double velocity, velocityUnits units) |
Sets the turn velocity of the drive based on the parameters set in the command. This command will not run the motor. More... | |
void | setTurnVelocity (double velocity, percentUnits units) |
void | setTimeout (double time, timeUnits units) |
Sets the timeout for the drivetrain. If the drivetrain does not reach its' commanded position prior to the completion of the timeout, the motors will stop. More... | |
double | timeout (timeUnits units) |
bool | didTimeout () |
void | setStopping (brakeType mode) |
Sets the stopping mode of the motor group by passing a brake mode as a parameter. More... | |
void | drive (directionType dir) |
Turns the motors on, and drive in the specified direction. More... | |
void | drive (directionType dir, double velocity, velocityUnits units) |
Turn on the motors and drive in the specified direction and a specified velocity. More... | |
bool | driveFor (double distance, distanceUnits units, bool waitForCompletion=true) |
Turn on the motors and drive a distance at the default velocity. More... | |
bool | driveFor (directionType dir, double distance, distanceUnits units, bool waitForCompletion=true) |
Turn on the motors and drive a distance at a specified velocity. More... | |
bool | driveFor (double distance, distanceUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true) |
Turn on the motors and drive a distance at a specified velocity. More... | |
bool | driveFor (directionType dir, double distance, distanceUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true) |
Turn on the motors and drive a distance at a specified velocity. More... | |
void | startDriveFor (double distance, distanceUnits distUnit) |
Start driving a distance at a pre-set velocity. More... | |
void | startDriveFor (directionType dir, double distance, distanceUnits distUnit) |
Start driving a distance at a pre-set velocity. More... | |
void | startDriveFor (double distance, distanceUnits distUnit, double velocity, velocityUnits velUnit) |
Start driving a distance at a specified velocity. More... | |
void | startDriveFor (directionType dir, double distance, distanceUnits distUnit, float velocity, velocityUnits velUnit) |
Start driving a distance at a specified velocity. More... | |
void | turn (turnType dir) |
Turns the motors on, and rotate in the specified direction. More... | |
void | turn (turnType dir, double velocity, velocityUnits units) |
Turns the motors on, and rotate in the specified direction and a specified velocity. More... | |
virtual bool | turnFor (double angle, rotationUnits units, bool waitForCompletion=true) |
Turn on the motors and rotate an angle at the default velocity. More... | |
virtual bool | turnFor (turnType dir, double angle, rotationUnits units, bool waitForCompletion=true) |
Turn on the motors and rotate an angle at the default velocity. More... | |
virtual bool | turnFor (double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true) |
Turn on the motors and rotate an angle at a specified velocity. More... | |
virtual bool | turnFor (turnType dir, double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true) |
Turn on the motors and rotate an angle at a specified velocity. More... | |
virtual void | startTurnFor (double angle, rotationUnits angleUnit) |
Start turning the drivetrain for a given angle. More... | |
virtual void | startTurnFor (turnType dir, double angle, rotationUnits angleUnit) |
Start turning the drivetrain for a given angle. More... | |
virtual void | startTurnFor (double angle, rotationUnits angleUnit, double velocity, velocityUnits velUnit) |
Start turning the drivetrain for a given angle at a given velocity. More... | |
virtual void | startTurnFor (turnType dir, double angle, rotationUnits angleUnit, float velocity, velocityUnits velUnit) |
Start turning the drivetrain for a given angle at a given velocity. More... | |
void | arcade (double drivePower, double turnPower, percentUnits units=percentUnits::pct) |
Drive in arcade mode, normally corresponding to two controller joystick axis values. More... | |
virtual bool | isMoving (void) |
Checks to see if any of the motors are rotating to a specific target. More... | |
bool | isDone (void) |
Checks to see if all the motor are done rotating to a specific target. More... | |
void | stop () |
Stops the drive using the default brake mode. More... | |
void | stop (brakeType mode) |
Stops the drive using a specified brake mode. More... | |
double | velocity (velocityUnits units) |
Gets the average velocity of the drivetrain;. More... | |
double | velocity (percentUnits units) |
double | current (currentUnits units=currentUnits::amp) |
Gets the total current of the drivetrain;. More... | |
double | power (powerUnits units=powerUnits::watt) |
Gets the average power of the drivetrain;. More... | |
double | torque (torqueUnits units=torqueUnits::Nm) |
Gets the average torque of the drivetrain;. More... | |
double | efficiency (percentUnits units=percentUnits::pct) |
Gets the average efficiency of the drivetrain;. More... | |
double | temperature (percentUnits units) |
Gets the average temperature of the drivetrain;. More... | |
Protected Attributes | |
double | _turnVelocity |
velocityUnits | _turnVelUnit |
vex::drivetrain::drivetrain | ( | motor_group & | leftMotors, |
motor_group & | rightMotors, | ||
double | wheelTravel = 319.1764 , |
||
double | trackWidth = 292.1 , |
||
double | wheelBase = 130 , |
||
distanceUnits | unit = distanceUnits::mm , |
||
double | externalGearRatio = 1.0 |
||
) |
Creates a new drivetrain object.
leftMotors | motor group driving the left side of the drivetrain |
rightMotors | motor group driving the right side of the drivetrain |
wheelTravel | circumference of the wheel type used |
trackWidth | distance between the wheels on opposite sides |
wheelBase | |
unit | distance unit for wheelTravel and trackWith |
externalGearRatio | external gear ratio, usually 1.0 |
vex::drivetrain::drivetrain | ( | vex::motor & | leftMotor, |
vex::motor & | rightMotor, | ||
double | wheelTravel = 319.1764 , |
||
double | trackWidth = 292.1 , |
||
double | wheelBase = 130 , |
||
distanceUnits | unit = distanceUnits::mm , |
||
double | externalGearRatio = 1.0 |
||
) |
vex::drivetrain::~drivetrain | ( | ) |
void vex::drivetrain::setGearRatio | ( | double | ratio | ) |
Sets the external gear ratio of the drivetrain.
ratio | gear ratio value, usually 1.0 |
void vex::drivetrain::setDriveVelocity | ( | double | velocity, |
velocityUnits | units | ||
) |
Sets the velocity of the drive based on the parameters set in the command. This command will not run the motors. Any subsequent call that does not contain a specified motor velocity will use this value.
velocity | Sets the amount of velocity. |
units | The measurement unit for the velocity value. |
void vex::drivetrain::setDriveVelocity | ( | double | velocity, |
percentUnits | units | ||
) |
void vex::drivetrain::setTurnVelocity | ( | double | velocity, |
velocityUnits | units | ||
) |
Sets the turn velocity of the drive based on the parameters set in the command. This command will not run the motor.
velocity | Sets the amount of velocity. |
units | The measurement unit for the velocity value. |
void vex::drivetrain::setTurnVelocity | ( | double | velocity, |
percentUnits | units | ||
) |
void vex::drivetrain::setTimeout | ( | double | time, |
timeUnits | units | ||
) |
Sets the timeout for the drivetrain. If the drivetrain does not reach its' commanded position prior to the completion of the timeout, the motors will stop.
time | Sets the amount of time. |
units | The measurement unit for the time value. |
double vex::drivetrain::timeout | ( | timeUnits | units | ) |
bool vex::drivetrain::didTimeout | ( | ) |
void vex::drivetrain::setStopping | ( | brakeType | mode | ) |
Sets the stopping mode of the motor group by passing a brake mode as a parameter.
mode | The stopping mode can be set to coast, brake, or hold. |
void vex::drivetrain::drive | ( | directionType | dir | ) |
Turns the motors on, and drive in the specified direction.
dir | The direction to drive. |
void vex::drivetrain::drive | ( | directionType | dir, |
double | velocity, | ||
velocityUnits | units | ||
) |
Turn on the motors and drive in the specified direction and a specified velocity.
dir | The direction to drive. |
velocity | Sets the amount of velocity. |
units | The measurement unit for the velocity value. |
bool vex::drivetrain::driveFor | ( | double | distance, |
distanceUnits | units, | ||
bool | waitForCompletion = true |
||
) |
Turn on the motors and drive a distance at the default velocity.
distance | Sets the distance to drive. |
units | The measurement unit for the distance value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
bool vex::drivetrain::driveFor | ( | directionType | dir, |
double | distance, | ||
distanceUnits | units, | ||
bool | waitForCompletion = true |
||
) |
Turn on the motors and drive a distance at a specified velocity.
dir | The direction to drive in. |
distance | Sets the distance to drive. |
units | The measurement unit for the distance value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
bool vex::drivetrain::driveFor | ( | double | distance, |
distanceUnits | units, | ||
double | velocity, | ||
velocityUnits | units_v, | ||
bool | waitForCompletion = true |
||
) |
Turn on the motors and drive a distance at a specified velocity.
distance | Sets the distance to drive. |
units | The measurement unit for the distance value. |
velocity | Sets the amount of velocity. |
units_v | The measurement unit for the velocity value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
bool vex::drivetrain::driveFor | ( | directionType | dir, |
double | distance, | ||
distanceUnits | units, | ||
double | velocity, | ||
velocityUnits | units_v, | ||
bool | waitForCompletion = true |
||
) |
Turn on the motors and drive a distance at a specified velocity.
dir | The direction to drive in. |
distance | Sets the distance to drive. |
units | The measurement unit for the distance value. |
velocity | Sets the amount of velocity. |
units_v | The measurement unit for the velocity value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
void vex::drivetrain::startDriveFor | ( | double | distance, |
distanceUnits | distUnit | ||
) |
Start driving a distance at a pre-set velocity.
distance | Sets the distance to drive. |
distUnit | The measurement unit for the distance value. |
void vex::drivetrain::startDriveFor | ( | directionType | dir, |
double | distance, | ||
distanceUnits | distUnit | ||
) |
Start driving a distance at a pre-set velocity.
dir | The direction to drive in. |
distance | Sets the distance to drive. |
distUnit | The measurement unit for the distance value. |
void vex::drivetrain::startDriveFor | ( | double | distance, |
distanceUnits | distUnit, | ||
double | velocity, | ||
velocityUnits | velUnit | ||
) |
Start driving a distance at a specified velocity.
distance | Sets the distance to drive. |
distUnit | The measurement unit for the distance value. |
velocity | Sets the amount of velocity. |
velUnit | The measurement unit for the velocity value. |
void vex::drivetrain::startDriveFor | ( | directionType | dir, |
double | distance, | ||
distanceUnits | distUnit, | ||
float | velocity, | ||
velocityUnits | velUnit | ||
) |
Start driving a distance at a specified velocity.
dir | The direction to drive in. |
distance | Sets the distance to drive. |
distUnit | The measurement unit for the distance value. |
velocity | Sets the amount of velocity. |
velUnit | The measurement unit for the velocity value. |
void vex::drivetrain::turn | ( | turnType | dir | ) |
Turns the motors on, and rotate in the specified direction.
dir | The direction to rotate the robot. |
void vex::drivetrain::turn | ( | turnType | dir, |
double | velocity, | ||
velocityUnits | units | ||
) |
Turns the motors on, and rotate in the specified direction and a specified velocity.
dir | The direction to rotate the robot. |
velocity | Sets the amount of velocity. |
units | The measurement unit for the velocity value. |
|
virtual |
Turn on the motors and rotate an angle at the default velocity.
angle | Sets the angle to turn. |
units | The measurement unit for the angle value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
Reimplemented in vex::smartdrive.
|
virtual |
Turn on the motors and rotate an angle at the default velocity.
dir | Direction to turn in, left or right. |
angle | Sets the angle to turn. |
units | The measurement unit for the angle value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
Reimplemented in vex::smartdrive.
|
virtual |
Turn on the motors and rotate an angle at a specified velocity.
angle | Sets the angle to turn. |
units | The measurement unit for the angle value. |
velocity | Sets the amount of velocity. |
units_v | The measurement unit for the velocity value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
Reimplemented in vex::smartdrive.
|
virtual |
Turn on the motors and rotate an angle at a specified velocity.
dir | Direction to turn in, left or right. |
angle | Sets the angle to turn. |
units | The measurement unit for the angle value. |
velocity | Sets the amount of velocity. |
units_v | The measurement unit for the velocity value. |
waitForCompletion | (Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true. |
Reimplemented in vex::smartdrive.
|
virtual |
Start turning the drivetrain for a given angle.
angle | Sets the angle to turn. |
angleUnit | The measurement unit for the angle value. |
Reimplemented in vex::smartdrive.
|
virtual |
Start turning the drivetrain for a given angle.
dir | Direction to turn in, left or right. |
angle | Sets the angle to turn. |
angleUnit | The measurement unit for the angle value. |
Reimplemented in vex::smartdrive.
|
virtual |
Start turning the drivetrain for a given angle at a given velocity.
angle | Sets the angle to turn. |
angleUnit | The measurement unit for the angle value. |
velocity | Sets the amount of velocity. |
velUnit | The measurement unit for the velocity value. |
Reimplemented in vex::smartdrive.
|
virtual |
Start turning the drivetrain for a given angle at a given velocity.
dir | Direction to turn in, left or right. |
angle | Sets the angle to turn. |
angleUnit | The measurement unit for the angle value. |
velocity | Sets the amount of velocity. |
velUnit | The measurement unit for the velocity value. |
Reimplemented in vex::smartdrive.
void vex::drivetrain::arcade | ( | double | drivePower, |
double | turnPower, | ||
percentUnits | units = percentUnits::pct |
||
) |
Drive in arcade mode, normally corresponding to two controller joystick axis values.
drivePower | percent power to apply to driving, -100..100 |
turnPower | percent power to apply to turning, -100..100 |
units | percent |
|
virtual |
Checks to see if any of the motors are rotating to a specific target.
Reimplemented in vex::smartdrive.
bool vex::drivetrain::isDone | ( | void | ) |
Checks to see if all the motor are done rotating to a specific target.
void vex::drivetrain::stop | ( | ) |
Stops the drive using the default brake mode.
void vex::drivetrain::stop | ( | brakeType | mode | ) |
Stops the drive using a specified brake mode.
mode | The brake mode can be set to coast, brake, or hold. |
double vex::drivetrain::velocity | ( | velocityUnits | units | ) |
Gets the average velocity of the drivetrain;.
units | The measurement unit for the velocity. |
|
inline |
double vex::drivetrain::current | ( | currentUnits | units = currentUnits::amp | ) |
Gets the total current of the drivetrain;.
units | The measurement unit for the current. |
double vex::drivetrain::power | ( | powerUnits | units = powerUnits::watt | ) |
Gets the average power of the drivetrain;.
units | The measurement unit for the power. |
double vex::drivetrain::torque | ( | torqueUnits | units = torqueUnits::Nm | ) |
Gets the average torque of the drivetrain;.
units | The measurement unit for the torque. |
double vex::drivetrain::efficiency | ( | percentUnits | units = percentUnits::pct | ) |
Gets the average efficiency of the drivetrain;.
units | (Optional) The measurement unit for the efficiency. By default, this parameter is a percentage. |
double vex::drivetrain::temperature | ( | percentUnits | units | ) |
Gets the average temperature of the drivetrain;.
units | The measurement unit for the temperature. |
|
protected |
|
protected |