VEX V5 C++ API
Public Member Functions | List of all members
vex::smartdrive Class Reference

Inherits vex::drivetrain.

Public Member Functions

 smartdrive (motor_group &l, motor_group &r, vex::gyro &g, double wheelTravel=319.1764, double trackWidth=292.1, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
 smartdrive (vex::motor &l, vex::motor &r, vex::gyro &g, double wheelTravel=319.1764, double trackWidth=292.1, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
 smartdrive (motor_group &l, motor_group &r, vex::inertial &g, double wheelTravel=319.1764, double trackWidth=292.1, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
 smartdrive (vex::motor &l, vex::motor &r, vex::inertial &g, double wheelTravel=319.1764, double trackWidth=292.1, double wheelBase=130, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
 ~smartdrive ()
 
void setTurnThreshold (double t)
 
bool turnToHeading (double angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate to a heading at the default velocity. More...
 
void startTurnToHeading (double angle, rotationUnits units)
 Start turning to a given heading without blocking the user program. More...
 
bool turnToHeading (double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and rotate to a heading at a specified velocity. More...
 
void startTurnToHeading (double angle, rotationUnits units, double velocity, velocityUnits units_v)
 Start turning to a given heading without blocking the user program. More...
 
bool turnToRotation (double angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate to an angle at the default velocity. More...
 
void startTurnToRotation (double angle, rotationUnits units)
 Start turning to a given rotation without blocking the user program. More...
 
bool turnToRotation (double angle, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and rotate to an angle at a specified velocity. More...
 
void startTurnToRotation (double angle, rotationUnits units, double velocity, velocityUnits units_v)
 Start turning to a given rotation without blocking the user program. 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, 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, double velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and rotate an angle at a specified 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 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...
 
double heading (rotationUnits units=rotationUnits::deg)
 Gets the heading (angle) of the gyro/inertial sensor. More...
 
void setHeading (double value, rotationUnits units)
 set the gyro/inertial sensor heading to angle More...
 
double rotation (rotationUnits units=rotationUnits::deg)
 Gets the rotation (absolute angle) of the gyro/inertial sensor. More...
 
void setRotation (double value, rotationUnits units)
 set the gyro/inertial sensor rotation to angle More...
 
bool isTurning ()
 Checks to see if the turnToHeading, turnToRotation or turnFor function is still running. More...
 
virtual bool isMoving ()
 Checks to see if any of the motors are rotating to a specific target. More...
 
- Public Member Functions inherited from 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. 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...
 
void arcade (double drivePower, double turnPower, percentUnits units=percentUnits::pct)
 Drive in arcade mode, normally corresponding to two controller joystick axis values. 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...
 

Additional Inherited Members

- Protected Attributes inherited from vex::drivetrain
double _turnVelocity
 
velocityUnits _turnVelUnit
 

Constructor & Destructor Documentation

◆ smartdrive() [1/4]

vex::smartdrive::smartdrive ( motor_group l,
motor_group r,
vex::gyro g,
double  wheelTravel = 319.1764,
double  trackWidth = 292.1,
double  wheelBase = 130,
distanceUnits  unit = distanceUnits::mm,
double  externalGearRatio = 1.0 
)

◆ smartdrive() [2/4]

vex::smartdrive::smartdrive ( vex::motor l,
vex::motor r,
vex::gyro g,
double  wheelTravel = 319.1764,
double  trackWidth = 292.1,
double  wheelBase = 130,
distanceUnits  unit = distanceUnits::mm,
double  externalGearRatio = 1.0 
)

◆ smartdrive() [3/4]

vex::smartdrive::smartdrive ( motor_group l,
motor_group r,
vex::inertial g,
double  wheelTravel = 319.1764,
double  trackWidth = 292.1,
double  wheelBase = 130,
distanceUnits  unit = distanceUnits::mm,
double  externalGearRatio = 1.0 
)

◆ smartdrive() [4/4]

vex::smartdrive::smartdrive ( vex::motor l,
vex::motor r,
vex::inertial g,
double  wheelTravel = 319.1764,
double  trackWidth = 292.1,
double  wheelBase = 130,
distanceUnits  unit = distanceUnits::mm,
double  externalGearRatio = 1.0 
)

◆ ~smartdrive()

vex::smartdrive::~smartdrive ( )

Member Function Documentation

◆ setTurnThreshold()

void vex::smartdrive::setTurnThreshold ( double  t)

◆ turnToHeading() [1/2]

bool vex::smartdrive::turnToHeading ( double  angle,
rotationUnits  units,
bool  waitForCompletion = true 
)

Turn on the motors and rotate to a heading at the default velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
angleSets the angle to turn.
unitsThe 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.

◆ startTurnToHeading() [1/2]

void vex::smartdrive::startTurnToHeading ( double  angle,
rotationUnits  units 
)
inline

Start turning to a given heading without blocking the user program.

Parameters
angleSets the angle to turn.
unitsThe measurement unit for the angle value.

◆ turnToHeading() [2/2]

bool vex::smartdrive::turnToHeading ( double  angle,
rotationUnits  units,
double  velocity,
velocityUnits  units_v,
bool  waitForCompletion = true 
)

Turn on the motors and rotate to a heading at a specified velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
angleSets the angle to turn.
unitsThe measurement unit for the angle value.
velocitySets the amount of velocity.
units_vThe 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.

◆ startTurnToHeading() [2/2]

void vex::smartdrive::startTurnToHeading ( double  angle,
rotationUnits  units,
double  velocity,
velocityUnits  units_v 
)
inline

Start turning to a given heading without blocking the user program.

Parameters
angleSets the angle to turn.
unitsThe measurement unit for the angle value.
velocitySets the amount of velocity.
units_vThe measurement unit for the velocity value.

◆ turnToRotation() [1/2]

bool vex::smartdrive::turnToRotation ( double  angle,
rotationUnits  units,
bool  waitForCompletion = true 
)

Turn on the motors and rotate to an angle at the default velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
angleSets the angle to turn.
unitsThe 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.

◆ startTurnToRotation() [1/2]

void vex::smartdrive::startTurnToRotation ( double  angle,
rotationUnits  units 
)
inline

Start turning to a given rotation without blocking the user program.

Parameters
angleSets the angle to turn.
unitsThe measurement unit for the angle value.

◆ turnToRotation() [2/2]

bool vex::smartdrive::turnToRotation ( double  angle,
rotationUnits  units,
double  velocity,
velocityUnits  units_v,
bool  waitForCompletion = true 
)

Turn on the motors and rotate to an angle at a specified velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
angleSets the angle to turn.
unitsThe measurement unit for the angle value.
velocitySets the amount of velocity.
units_vThe 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.

◆ startTurnToRotation() [2/2]

void vex::smartdrive::startTurnToRotation ( double  angle,
rotationUnits  units,
double  velocity,
velocityUnits  units_v 
)
inline

Start turning to a given rotation without blocking the user program.

Parameters
angleSets the angle to turn.
unitsThe measurement unit for the angle value.
velocitySets the amount of velocity.
units_vThe measurement unit for the velocity value.

◆ turnFor() [1/4]

virtual bool vex::smartdrive::turnFor ( turnType  dir,
double  angle,
rotationUnits  units,
bool  waitForCompletion = true 
)
virtual

Turn on the motors and rotate an angle at the default velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
dirSets the direction to turn.
angleSets the angle to turn.
unitsThe 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 from vex::drivetrain.

◆ turnFor() [2/4]

virtual bool vex::smartdrive::turnFor ( double  angle,
rotationUnits  units,
bool  waitForCompletion = true 
)
virtual

Turn on the motors and rotate an angle at the default velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
angleSets the angle to turn.
unitsThe 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 from vex::drivetrain.

◆ turnFor() [3/4]

virtual bool vex::smartdrive::turnFor ( turnType  dir,
double  angle,
rotationUnits  units,
double  velocity,
velocityUnits  units_v,
bool  waitForCompletion = true 
)
virtual

Turn on the motors and rotate an angle at a specified velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
dirSets the direction to turn.
angleSets the angle to turn.
unitsThe measurement unit for the angle value.
velocitySets the amount of velocity.
units_vThe 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 from vex::drivetrain.

◆ turnFor() [4/4]

virtual bool vex::smartdrive::turnFor ( double  angle,
rotationUnits  units,
double  velocity,
velocityUnits  units_v,
bool  waitForCompletion = true 
)
virtual

Turn on the motors and rotate an angle at a specified velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
angleSets the angle to turn.
unitsThe measurement unit for the angle value.
velocitySets the amount of velocity.
units_vThe 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 from vex::drivetrain.

◆ startTurnFor() [1/4]

virtual void vex::smartdrive::startTurnFor ( double  angle,
rotationUnits  angleUnit 
)
virtual

Start turning the drivetrain for a given angle.

Parameters
angleSets the angle to turn.
angleUnitThe measurement unit for the angle value.

Reimplemented from vex::drivetrain.

◆ startTurnFor() [2/4]

virtual void vex::smartdrive::startTurnFor ( turnType  dir,
double  angle,
rotationUnits  angleUnit 
)
virtual

Start turning the drivetrain for a given angle.

Parameters
dirDirection to turn in, left or right.
angleSets the angle to turn.
angleUnitThe measurement unit for the angle value.

Reimplemented from vex::drivetrain.

◆ startTurnFor() [3/4]

virtual void vex::smartdrive::startTurnFor ( double  angle,
rotationUnits  angleUnit,
double  velocity,
velocityUnits  velUnit 
)
virtual

Start turning the drivetrain for a given angle at a given velocity.

Parameters
angleSets the angle to turn.
angleUnitThe measurement unit for the angle value.
velocitySets the amount of velocity.
velUnitThe measurement unit for the velocity value.

Reimplemented from vex::drivetrain.

◆ startTurnFor() [4/4]

virtual void vex::smartdrive::startTurnFor ( turnType  dir,
double  angle,
rotationUnits  angleUnit,
float  velocity,
velocityUnits  velUnit 
)
virtual

Start turning the drivetrain for a given angle at a given velocity.

Parameters
dirDirection to turn in, left or right.
angleSets the angle to turn.
angleUnitThe measurement unit for the angle value.
velocitySets the amount of velocity.
velUnitThe measurement unit for the velocity value.

Reimplemented from vex::drivetrain.

◆ heading()

double vex::smartdrive::heading ( rotationUnits  units = rotationUnits::deg)

Gets the heading (angle) of the gyro/inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.

◆ setHeading()

void vex::smartdrive::setHeading ( double  value,
rotationUnits  units 
)

set the gyro/inertial sensor heading to angle

Parameters
valueThe new heading for the gyro
unitsThe rotation unit for the angle

◆ rotation()

double vex::smartdrive::rotation ( rotationUnits  units = rotationUnits::deg)

Gets the rotation (absolute angle) of the gyro/inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.

◆ setRotation()

void vex::smartdrive::setRotation ( double  value,
rotationUnits  units 
)

set the gyro/inertial sensor rotation to angle

Parameters
valueThe new absolute angle for the gyro
unitsThe rotation unit for the angle

◆ isTurning()

bool vex::smartdrive::isTurning ( )

Checks to see if the turnToHeading, turnToRotation or turnFor function is still running.

Returns
Returns a true Boolean if the motor is on and is rotating to a target. Returns a false Boolean if the motor is done rotating to a target.

◆ isMoving()

virtual bool vex::smartdrive::isMoving ( )
virtual

Checks to see if any of the motors are rotating to a specific target.

Returns
Returns a true Boolean if the motor is on and is rotating to a target. Returns a false Boolean if the motor is done rotating to a target.

Reimplemented from vex::drivetrain.