VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex::smartdrive Class Reference
Inheritance diagram for vex::smartdrive:
vex::drivetrain

Public Member Functions

 smartdrive (motor_group &l, motor_group &r, vex::gyro &g, double wheelTravel=200, double trackWidth=200, double wheelBase=50, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
 smartdrive (vex::motor &l, vex::motor &r, vex::gyro &g, double wheelTravel=200, double trackWidth=200, double wheelBase=50, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
void setTurnThreshold (double t)
 
void setTurnConstant (double kp)
 
smartdrivesetTurnDirectionReverse (bool value)
 
bool turnToHeading (double angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate to a heading at the default velocity.
 
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.
 
bool turnToRotation (double angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate to an angle at the default velocity.
 
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.
 
virtual bool turnFor (turnType dir, double angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate an angle at the default velocity.
 
virtual bool turnFor (double angle, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and rotate an angle at the default velocity.
 
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.
 
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.
 
void setHeading (double value, rotationUnits units)
 set the gyro sensor heading to angle
 
double heading (rotationUnits units=rotationUnits::deg)
 Gets the heading (angle) of the gyro sensor.
 
double rotation (rotationUnits units=rotationUnits::deg)
 Gets the rotation (absolute angle) of the gyro sensor.
 
void setRotation (double value, rotationUnits units)
 set the gyro sensor rotation to angle
 
bool isTurning ()
 Checks to see if the turnToHeading, turnToRotation or turnFor function is still running.
 
virtual bool isMoving ()
 Checks to see if any of the motors are rotating to a specific target.
 
- Public Member Functions inherited from vex::drivetrain
 drivetrain (motor_group &l, motor_group &r, double wheelTravel=200, double trackWidth=200, double wheelBase=50, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
 drivetrain (vex::motor &l, vex::motor &r, double wheelTravel=200, double trackWidth=200, double wheelBase=50, distanceUnits unit=distanceUnits::mm, double externalGearRatio=1.0)
 
void setGearRatio (double ratio)
 
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 motor. Any subsequent call that does not contain a specified motor velocity will use this value.
 
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.
 
void setTurnVelocity (double velocity, percentUnits units)
 
void setTimeout (int32_t 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.
 
void setStopping (brakeType mode)
 Sets the stopping mode of the motor group by passing a brake mode as a parameter.
 
void drive (directionType dir)
 Turns the motors on, and drive in the specified direction.
 
void drive (directionType dir, double velocity, velocityUnits units)
 Turn on the motors and drive in the specified direction and a specified velocity.
 
bool driveFor (double distance, distanceUnits units, bool waitForCompletion=true)
 Turn on the motors and drive a distance at the default velocity.
 
bool driveFor (directionType dir, double distance, distanceUnits units, bool waitForCompletion=true)
 
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.
 
bool driveFor (directionType dir, double distance, distanceUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
 
void turn (turnType dir)
 Turns the motors on, and rotate in the specified direction.
 
void turn (turnType dir, double velocity, velocityUnits units)
 Turns the motors on, and rotate in the specified direction and a specified velocity.
 
bool isDone (void)
 Checks to see if all the motor are done rotating to a specific target.
 
void stop ()
 Stops the drive using the default brake mode.
 
void stop (brakeType mode)
 Stops the drive using a specified brake mode.
 
void arcade (double drivePower, double turnPower, percentUnits units=percentUnits::pct)
 
double velocity (velocityUnits units)
 Gets the average velocity of the drivetrain;.
 
double velocity (percentUnits units)
 
double current (currentUnits units=currentUnits::amp)
 Gets the total current of the drivetrain;.
 
double current (percentUnits units)
 Gets the electrical current of the drivetrain as percentage of maximum.
 
double voltage (voltageUnits units=voltageUnits::volt)
 Gets the average voltage of the drivetrain;.
 
double power (powerUnits units=powerUnits::watt)
 Gets the average power of the drivetrain;.
 
double torque (torqueUnits units=torqueUnits::Nm)
 Gets the average torque of the drivetrain;.
 
double efficiency (percentUnits units=percentUnits::pct)
 Gets the average efficiency of the drivetrain;.
 
double temperature (percentUnits units)
 Gets the average temperature of the drivetrain;.
 

Additional Inherited Members

- Protected Member Functions inherited from vex::drivetrain
double distanceToMm (double distance, distanceUnits units)
 
double angleToDeg (double angle, rotationUnits units)
 
int32_t timeoutGet ()
 
- Protected Attributes inherited from vex::drivetrain
double _turnvelocity
 
velocityUnits _turnvelocityUnits
 
uint8_t _turnmode
 

Detailed Description

Definition at line 24 of file vex_smartdrive.h.

Member Function Documentation

◆ heading()

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

Gets the heading (angle) of the gyro 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.

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

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

◆ rotation()

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

Gets the rotation (absolute angle) of the gyro 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 sensor heading to angle

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

◆ setRotation()

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

set the gyro sensor rotation to angle

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

◆ turnFor() [1/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() [2/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.

◆ turnFor() [3/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() [4/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.

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

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

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

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

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