VEX IQ 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, float wheelTravel=200, float trackWidth=176, float wheelBase=50, distanceUnits unit=distanceUnits::mm, float externalGearRatio=1.0)
 
 smartdrive (vex::motor &l, vex::motor &r, vex::gyro &g, float wheelTravel=200, float trackWidth=176, float wheelBase=50, distanceUnits unit=distanceUnits::mm, float externalGearRatio=1.0)
 
 ~smartdrive ()
 
bool turnToHeading (float angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate to a heading at the default velocity. More...
 
void startTurnToHeading (float angle, rotationUnits units)
 
bool turnToHeading (float angle, rotationUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and rotate to a heading at a specified velocity. More...
 
void startTurnToHeading (float angle, rotationUnits units, float velocity, velocityUnits units_v)
 
bool turnToRotation (float angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate to an angle at the default velocity. More...
 
void startTurnToRotation (float angle, rotationUnits units)
 
bool turnToRotation (float angle, rotationUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and rotate to an angle at a specified velocity. More...
 
void startTurnToRotation (float angle, rotationUnits units, float velocity, velocityUnits units_v)
 
virtual bool turnFor (turnType dir, float angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate an angle at the default velocity. More...
 
virtual void startTurnFor (turnType dir, float angle, rotationUnits units)
 Start turning the drivetrain for a given angle. More...
 
virtual bool turnFor (float angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate an angle at the default velocity. More...
 
virtual void startTurnFor (float angle, rotationUnits units)
 Start turning the drivetrain for a given angle. More...
 
virtual bool turnFor (turnType dir, float angle, rotationUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and rotate an angle at a specified velocity. More...
 
virtual void startTurnFor (turnType dir, float angle, rotationUnits units, float velocity, velocityUnits units_v)
 Start turning the drivetrain for a given angle at a given velocity. More...
 
virtual bool turnFor (float angle, rotationUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and rotate an angle at a specified velocity. More...
 
virtual void startTurnFor (float angle, rotationUnits units, float velocity, velocityUnits units_v)
 Start turning the drivetrain for a given angle at a given velocity. More...
 
void setHeading (float value, rotationUnits units)
 set the gyro sensor heading to angle More...
 
void setRotation (float value, rotationUnits units)
 set the gyro sensor rotation to angle More...
 
float heading (rotationUnits units=rotationUnits::deg)
 Gets the heading (angle) of the gyro sensor. More...
 
float rotation (rotationUnits units=rotationUnits::deg)
 Gets the rotation (absolute angle) of the gyro sensor. 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 (vex::motor_group &leftMotors, vex::motor_group &rightMotors, float wheelTravel=200, float trackWidth=176, float wheelBase=50, distanceUnits unit=distanceUnits::mm, float externalGearRatio=1.0)
 Creates a new drivetrain object. More...
 
 drivetrain (vex::motor &leftMotor, vex::motor &rightMotor, float wheelTravel=200, float trackWidth=176, float wheelBase=50, distanceUnits unit=distanceUnits::mm, float externalGearRatio=1.0)
 
 ~drivetrain ()
 
void setGearRatio (float ratio)
 Sets the external gear ratio of the drivetrain. More...
 
void setDriveVelocity (float velocity, velocityUnits units)
 Sets the velocity of the drive based on the parameters set in the command. This command will not run the motor. Any subsequent call that does not contain a specified motor velocity will use this value. More...
 
void setDriveVelocity (float velocity, percentUnits units)
 
void setTurnVelocity (float 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 (float velocity, percentUnits units)
 
void setTimeout (float time, timeUnits units)
 Sets the timeout for the motor group. If the motor group does not reach its commanded position prior to the completion of the timeout, the motors will stop. More...
 
float 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, float velocity, velocityUnits units)
 Turn on the motors and drive in the specified direction and a specified velocity. More...
 
bool driveFor (float distance, distanceUnits units, bool waitForCompletion=true)
 Turn on the motors and drive a distance at the default velocity. More...
 
bool driveFor (directionType dir, float distance, distanceUnits units, bool waitForCompletion=true)
 Turn on the motors and drive a distance at the default velocity. More...
 
bool driveFor (float distance, distanceUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and drive a distance at a specified velocity. More...
 
bool driveFor (directionType dir, float distance, distanceUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and drive a distance at a specified velocity. More...
 
void startDriveFor (float distance, distanceUnits distUnit)
 Start driving a distance at a pre-set velocity. More...
 
void startDriveFor (directionType dir, float distance, distanceUnits distUnit)
 Start driving a distance at a pre-set velocity. More...
 
void startDriveFor (float distance, distanceUnits distUnit, float velocity, velocityUnits velUnit)
 Start driving a distance at a specified velocity. More...
 
void startDriveFor (directionType dir, float 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, float velocity, velocityUnits units)
 Turns the motors on, and rotate in the specified direction and a specified velocity. 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...
 
void arcade (float drivePower, float turnPower, percentUnits units=percentUnits::pct)
 Drive in arcade mode, normally corresponding to two controller joystick axis values. More...
 
float velocity (velocityUnits units)
 Gets the average velocity of the drivetrain;. More...
 
float velocity (percentUnits units)
 
float current (currentUnits units=currentUnits::amp)
 Gets the total current of the drivetrain;. More...
 

Additional Inherited Members

- Protected Attributes inherited from vex::drivetrain
Drivetrain_t _dt
 

Constructor & Destructor Documentation

◆ smartdrive() [1/2]

vex::smartdrive::smartdrive ( motor_group l,
motor_group r,
vex::gyro g,
float  wheelTravel = 200,
float  trackWidth = 176,
float  wheelBase = 50,
distanceUnits  unit = distanceUnits::mm,
float  externalGearRatio = 1.0 
)

◆ smartdrive() [2/2]

vex::smartdrive::smartdrive ( vex::motor l,
vex::motor r,
vex::gyro g,
float  wheelTravel = 200,
float  trackWidth = 176,
float  wheelBase = 50,
distanceUnits  unit = distanceUnits::mm,
float  externalGearRatio = 1.0 
)

◆ ~smartdrive()

vex::smartdrive::~smartdrive ( )

Member Function Documentation

◆ turnToHeading() [1/2]

bool vex::smartdrive::turnToHeading ( float  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 ( float  angle,
rotationUnits  units 
)
inline

◆ turnToHeading() [2/2]

bool vex::smartdrive::turnToHeading ( float  angle,
rotationUnits  units,
float  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 ( float  angle,
rotationUnits  units,
float  velocity,
velocityUnits  units_v 
)
inline

◆ turnToRotation() [1/2]

bool vex::smartdrive::turnToRotation ( float  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 ( float  angle,
rotationUnits  units 
)
inline

◆ turnToRotation() [2/2]

bool vex::smartdrive::turnToRotation ( float  angle,
rotationUnits  units,
float  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 ( float  angle,
rotationUnits  units,
float  velocity,
velocityUnits  units_v 
)
inline

◆ turnFor() [1/4]

virtual bool vex::smartdrive::turnFor ( turnType  dir,
float  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.

◆ startTurnFor() [1/4]

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

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.

◆ turnFor() [2/4]

virtual bool vex::smartdrive::turnFor ( float  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.

◆ startTurnFor() [2/4]

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

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.

◆ turnFor() [3/4]

virtual bool vex::smartdrive::turnFor ( turnType  dir,
float  angle,
rotationUnits  units,
float  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.

◆ startTurnFor() [3/4]

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

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.

◆ turnFor() [4/4]

virtual bool vex::smartdrive::turnFor ( float  angle,
rotationUnits  units,
float  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() [4/4]

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

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.

◆ setHeading()

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

set the gyro sensor heading to angle

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

◆ setRotation()

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

set the gyro sensor rotation to angle

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

◆ heading()

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

Gets the heading (angle) of the gyro sensor.

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

◆ rotation()

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

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

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

◆ 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.