VEX IQ C++ API
Classes | Public Member Functions | Friends | List of all members
vex::motor_group Class Reference

Public Member Functions

 motor_group ()
 
 ~motor_group ()
 
template<typename... Args>
 motor_group (vex::motor &m1, Args &... m2)
 
template<typename... Args>
void operator() (vex::motor &m1, Args &... m2)
 
int32_t count (void)
 return the number of motors in the motor group More...
 
void setVelocity (float velocity, velocityUnits units)
 Sets the velocity of the motor group 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 setVelocity (float velocity, percentUnits units)
 
void setStopping (brakeType mode)
 Sets the stopping mode of the motor group by passing a brake mode as a parameter. More...
 
void resetRotation (void)
 Resets all motor encoders to the value of zero. More...
 
void setRotation (float value, rotationUnits units)
 Sets the value of all motor encoders to the value specified in the parameter. More...
 
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. More...
 
void spin (directionType dir)
 Turns the motors on, and spins them in the specified direction. More...
 
void spin (directionType dir, float velocity, velocityUnits units)
 Turn on the motors and spins them in the specified direction and a specified velocity. More...
 
void spin (directionType dir, float velocity, percentUnits units)
 
bool spinTo (float rotation, rotationUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turns on the motors and spin them to an absolute target rotation value at a specified velocity. More...
 
bool spinTo (float rotation, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and spin them to an absolute target rotation value. More...
 
bool spinFor (float rotation, rotationUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and spin them to a relative target rotation value at a specified velocity. More...
 
bool spinFor (directionType dir, float rotation, rotationUnits units, float velocity, velocityUnits units_v, bool waitForCompletion=true)
 Turn on the motors and spin them to a relative target rotation value at a specified velocity. More...
 
bool spinFor (float rotation, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and spin them to a relative target rotation value. More...
 
bool spinFor (directionType dir, float rotation, rotationUnits units, bool waitForCompletion=true)
 Turn on the motors and spin them to a relative target rotation value. More...
 
void spinFor (float time, timeUnits units, float velocity, velocityUnits units_v)
 Turn on the motors and spin them to a relative target time value at a specified velocity. More...
 
void spinFor (directionType dir, float time, timeUnits units, float velocity, velocityUnits units_v)
 Turn on the motors and spin them to a relative target time value at a specified velocity. More...
 
void spinFor (float time, timeUnits units)
 Turn on the motors and spin them to a relative target time value. More...
 
void spinFor (directionType dir, float time, timeUnits units)
 Turn on the motors and spin them to a relative target time value. More...
 
void startSpinTo (float rotation, rotationUnits units, float velocity, velocityUnits units_v)
 Starts spinning a motor to an absolute target rotation but does not wait for the motor to reach that target. More...
 
void startSpinTo (float rotation, rotationUnits units)
 Starts spinning a motor to an absolute target rotation but does not wait for the motor to reach that target.. More...
 
void startSpinFor (float rotation, rotationUnits units, float velocity, velocityUnits units_v)
 Starts spinning a motor to a relative target rotation but does not wait for the motor to reach that target. More...
 
void startSpinFor (directionType dir, float rotation, rotationUnits units, float velocity, velocityUnits units_v)
 Starts spinning a motor to a relative target rotation but does not wait for the motor to reach that target. More...
 
void startSpinFor (float rotation, rotationUnits units)
 Starts spinning a motor to a relative target but does not wait for the motor to reach that target. More...
 
void startSpinFor (directionType dir, float rotation, rotationUnits units)
 Starts spinning a motor to a relative target but does not wait for the motor to reach that target. More...
 
bool isSpinning (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 (void)
 Stops all motors using the default brake mode. More...
 
void stop (brakeType mode)
 Stops all motors using a specified brake mode. More...
 
void setMaxTorque (float value, percentUnits units)
 Sets the max torque of the motors. More...
 
void setMaxTorque (float value, torqueUnits units)
 Sets the max torque of the motors. More...
 
void setMaxTorque (float value, currentUnits units)
 Sets the max torque of the motors. More...
 
directionType direction (void)
 Gets which direction the first motor in the group is spinning. More...
 
float rotation (rotationUnits units)
 Gets the current rotation of the first motor in the group's encoder. More...
 
float velocity (velocityUnits units)
 Gets the current velocity of the first motor in the group. More...
 
float velocity (percentUnits units)
 
float current (currentUnits units=currentUnits::amp)
 Gets the sum electrical current for all motors in the group. More...
 

Friends

class drivetrain
 

Constructor & Destructor Documentation

◆ motor_group() [1/2]

vex::motor_group::motor_group ( )

◆ ~motor_group()

vex::motor_group::~motor_group ( )

◆ motor_group() [2/2]

template<typename... Args>
vex::motor_group::motor_group ( vex::motor m1,
Args &...  m2 
)
inline

Member Function Documentation

◆ operator()()

template<typename... Args>
void vex::motor_group::operator() ( vex::motor m1,
Args &...  m2 
)
inline

◆ count()

int32_t vex::motor_group::count ( void  )

return the number of motors in the motor group

Returns
number of motors

◆ setVelocity() [1/2]

void vex::motor_group::setVelocity ( float  velocity,
velocityUnits  units 
)

Sets the velocity of the motor group 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.

Parameters
velocitySets the amount of velocity.
unitsThe measurement unit for the velocity value.

◆ setVelocity() [2/2]

void vex::motor_group::setVelocity ( float  velocity,
percentUnits  units 
)
inline

◆ setStopping()

void vex::motor_group::setStopping ( brakeType  mode)

Sets the stopping mode of the motor group by passing a brake mode as a parameter.

Parameters
modeThe stopping mode can be set to coast, brake, or hold.

◆ resetRotation()

void vex::motor_group::resetRotation ( void  )

Resets all motor encoders to the value of zero.

◆ setRotation()

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

Sets the value of all motor encoders to the value specified in the parameter.

Parameters
valueSets the amount of rotation.
unitsThe measurement unit for the rotation value.

◆ setTimeout()

void vex::motor_group::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.

Parameters
timeSets the amount of time.
unitsThe measurement unit for the time value.

◆ spin() [1/3]

void vex::motor_group::spin ( directionType  dir)

Turns the motors on, and spins them in the specified direction.

Parameters
dirThe direction to spin the motors.

◆ spin() [2/3]

void vex::motor_group::spin ( directionType  dir,
float  velocity,
velocityUnits  units 
)

Turn on the motors and spins them in the specified direction and a specified velocity.

Parameters
dirThe direction to spin the motors.
velocitySets the amount of velocity.
unitsThe measurement unit for the velocity value.

◆ spin() [3/3]

void vex::motor_group::spin ( directionType  dir,
float  velocity,
percentUnits  units 
)
inline

◆ spinTo() [1/2]

bool vex::motor_group::spinTo ( float  rotation,
rotationUnits  units,
float  velocity,
velocityUnits  units_v,
bool  waitForCompletion = true 
)

Turns on the motors and spin them to an absolute target rotation value at a specified velocity.

Returns
Returns a Boolean that signifies when the motors have reached the target rotation value.
Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation 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.

◆ spinTo() [2/2]

bool vex::motor_group::spinTo ( float  rotation,
rotationUnits  units,
bool  waitForCompletion = true 
)

Turn on the motors and spin them to an absolute target rotation value.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation 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.

◆ spinFor() [1/8]

bool vex::motor_group::spinFor ( float  rotation,
rotationUnits  units,
float  velocity,
velocityUnits  units_v,
bool  waitForCompletion = true 
)

Turn on the motors and spin them to a relative target rotation value at a specified velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation 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.

◆ spinFor() [2/8]

bool vex::motor_group::spinFor ( directionType  dir,
float  rotation,
rotationUnits  units,
float  velocity,
velocityUnits  units_v,
bool  waitForCompletion = true 
)

Turn on the motors and spin them to a relative target rotation value at a specified velocity.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
dirThe direction to spin the motors.
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation 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.

◆ spinFor() [3/8]

bool vex::motor_group::spinFor ( float  rotation,
rotationUnits  units,
bool  waitForCompletion = true 
)

Turn on the motors and spin them to a relative target rotation value.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation 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.

◆ spinFor() [4/8]

bool vex::motor_group::spinFor ( directionType  dir,
float  rotation,
rotationUnits  units,
bool  waitForCompletion = true 
)

Turn on the motors and spin them to a relative target rotation value.

Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.
Parameters
dirThe direction to spin the motors.
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation 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.

◆ spinFor() [5/8]

void vex::motor_group::spinFor ( float  time,
timeUnits  units,
float  velocity,
velocityUnits  units_v 
)

Turn on the motors and spin them to a relative target time value at a specified velocity.

Parameters
timeSets the amount of time.
unitsThe measurement unit for the time value.
velocitySets the amount of velocity.
units_vThe measurement unit for the velocity value.

◆ spinFor() [6/8]

void vex::motor_group::spinFor ( directionType  dir,
float  time,
timeUnits  units,
float  velocity,
velocityUnits  units_v 
)

Turn on the motors and spin them to a relative target time value at a specified velocity.

Parameters
dirThe direction to spin the motors.
timeSets the amount of time.
unitsThe measurement unit for the time value.
velocitySets the amount of velocity.
units_vThe measurement unit for the velocity value.

◆ spinFor() [7/8]

void vex::motor_group::spinFor ( float  time,
timeUnits  units 
)

Turn on the motors and spin them to a relative target time value.

Parameters
timeSets the amount of time.
unitsThe measurement unit for the time value.

◆ spinFor() [8/8]

void vex::motor_group::spinFor ( directionType  dir,
float  time,
timeUnits  units 
)

Turn on the motors and spin them to a relative target time value.

Parameters
dirThe direction to spin the motors.
timeSets the amount of time.
unitsThe measurement unit for the time value.

◆ startSpinTo() [1/2]

void vex::motor_group::startSpinTo ( float  rotation,
rotationUnits  units,
float  velocity,
velocityUnits  units_v 
)

Starts spinning a motor to an absolute target rotation but does not wait for the motor to reach that target.

Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation value.
velocitySets the amount of velocity.
units_vThe measurement unit for the velocity value.

◆ startSpinTo() [2/2]

void vex::motor_group::startSpinTo ( float  rotation,
rotationUnits  units 
)

Starts spinning a motor to an absolute target rotation but does not wait for the motor to reach that target..

Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation value.

◆ startSpinFor() [1/4]

void vex::motor_group::startSpinFor ( float  rotation,
rotationUnits  units,
float  velocity,
velocityUnits  units_v 
)

Starts spinning a motor to a relative target rotation but does not wait for the motor to reach that target.

Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation value.
velocitySets the amount of velocity.
units_vThe measurement unit for the velocity value.

◆ startSpinFor() [2/4]

void vex::motor_group::startSpinFor ( directionType  dir,
float  rotation,
rotationUnits  units,
float  velocity,
velocityUnits  units_v 
)

Starts spinning a motor to a relative target rotation but does not wait for the motor to reach that target.

Parameters
dirThe direction to spin the motor.
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation value.
velocitySets the amount of velocity.
units_vThe measurement unit for the velocity value.

◆ startSpinFor() [3/4]

void vex::motor_group::startSpinFor ( float  rotation,
rotationUnits  units 
)

Starts spinning a motor to a relative target but does not wait for the motor to reach that target.

Parameters
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation value.

◆ startSpinFor() [4/4]

void vex::motor_group::startSpinFor ( directionType  dir,
float  rotation,
rotationUnits  units 
)

Starts spinning a motor to a relative target but does not wait for the motor to reach that target.

Parameters
dirThe direction to spin the motor.
rotationSets the amount of rotation.
unitsThe measurement unit for the rotation value.

◆ isSpinning()

bool vex::motor_group::isSpinning ( void  )

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.

◆ isDone()

bool vex::motor_group::isDone ( void  )

Checks to see if all the motor are done rotating to a specific target.

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

◆ stop() [1/2]

void vex::motor_group::stop ( void  )

Stops all motors using the default brake mode.

◆ stop() [2/2]

void vex::motor_group::stop ( brakeType  mode)

Stops all motors using a specified brake mode.

Parameters
modeThe brake mode can be set to coast, brake, or hold.

◆ setMaxTorque() [1/3]

void vex::motor_group::setMaxTorque ( float  value,
percentUnits  units 
)

Sets the max torque of the motors.

Parameters
valueSets the amount of torque.
unitsThe measurement unit for the torque value.

◆ setMaxTorque() [2/3]

void vex::motor_group::setMaxTorque ( float  value,
torqueUnits  units 
)

Sets the max torque of the motors.

Parameters
valueSets the amount of torque.
unitsThe measurement unit for the torque value.

◆ setMaxTorque() [3/3]

void vex::motor_group::setMaxTorque ( float  value,
currentUnits  units 
)

Sets the max torque of the motors.

Parameters
valueSets the amount of torque.
unitsThe measurement unit for the torque value.

◆ direction()

directionType vex::motor_group::direction ( void  )

Gets which direction the first motor in the group is spinning.

Returns
Returns the direction that the motor is spinning.

◆ rotation()

float vex::motor_group::rotation ( rotationUnits  units)

Gets the current rotation of the first motor in the group's encoder.

Returns
Returns a float that represents the current rotation of the motor in the units defined in the parameter.
Parameters
unitsThe measurement unit for the rotation.

◆ velocity() [1/2]

float vex::motor_group::velocity ( velocityUnits  units)

Gets the current velocity of the first motor in the group.

Returns
Returns a float that represents the current velocity of the motor in the units defined in the parameter.
Parameters
unitsThe measurement unit for the velocity.

◆ velocity() [2/2]

float vex::motor_group::velocity ( percentUnits  units)
inline

◆ current()

float vex::motor_group::current ( currentUnits  units = currentUnits::amp)

Gets the sum electrical current for all motors in the group.

Returns
Returns a float that represents the electrical current of the motors in the units defined in the parameter.
Parameters
unitsThe measurement unit for the current.

Friends And Related Function Documentation

◆ drivetrain

friend class drivetrain
friend