VEX V5 Python API
Public Member Functions | List of all members
motor_group.MotorGroup Class Reference

Public Member Functions

def __init__ (self, motors)
 
def count (self)
 return the number of motors in the motor group More...
 
def set_velocity (self, velocity, velocityUnits=VelocityUnits.PCT)
 Sets the velocity of the motor group based on the parameters set in the command. More...
 
def set_stopping (self, brakeType)
 Sets the stopping mode of the motor group by passing a brake mode as a parameter. More...
 
def reset_rotation (self)
 Resets all motor encoders to the value of zero. More...
 
def set_rotation (self, value, rotationUnits=RotationUnits.DEG)
 Sets the value of all motor encoders to the value specified in the parameter. More...
 
def set_timeout (self, time, timeUnits=TimeUnits.SEC)
 Sets the timeout for the motor group. More...
 
def spin (self, dir, velocity=None, velocityUnits=VelocityUnits.PCT)
 Turn on the motors and spins them in the specified direction and a specified velocity. More...
 
def spin_with_voltage (self, dir, voltage, voltageUnits=VoltageUnits.VOLT)
 Turns on the motors and spins them in a specified direction and a specified voltage. More...
 
def spin_to (self, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True)
 Turns on the motors and spin them to an absolute target rotation value at a specified velocity. More...
 
def spin_to_position (self, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True)
 Turns on the motors and spins them to an absolute target rotation value at a specified velocity. More...
 
def spin_for (self, dir, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True)
 Turn on the motors and spin them to a relative target rotation value at a specified velocity. More...
 
def spin_for_time (self, dir, time, timeUnits=TimeUnits.SEC, velocity=None, velocityUnits=VelocityUnits.PCT)
 Turn on the motors and spin them for a given amount of time. More...
 
def start_spin_to (self, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT)
 Starts spinning motors to an absolute target rotation but does not wait for the motors to reach that target. More...
 
def start_spin_to_position (self, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT)
 Starts spinning a motor to an absolute target rotation but does not wait for the motor to reach that target. More...
 
def start_spin_for (self, dir, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT)
 Starts spinning motors to a relative target rotation but does not wait for the motors to reach that target. More...
 
def is_spinning (self)
 Checks to see if a spin_for/spin_to command is still in process, i.e. More...
 
def is_done (self)
 Determines if a spin_for/spin_to command has reached its target position. More...
 
def stop (self, brakeType=None)
 Stops all motors using the default brake mode. More...
 
def set_max_torque (self, value, torqueUnits=TorqueUnits.NM)
 Sets the max torque of all motors. More...
 
def set_max_torque_percent (self, value)
 Sets the max torque of all motors as a percentage. More...
 
def set_max_torque_current (self, value)
 Sets the max torque of all motors. More...
 
def direction (self)
 Gets which direction the first motor is spinning. More...
 
def rotation (self, rotationUnits=RotationUnits.DEG)
 Gets the current rotation of the first motor in the group's encoder. More...
 
def velocity (self, velocityUnits=VelocityUnits.PCT)
 Gets the current velocity of the first motor in the group. More...
 
def current (self)
 Gets the sum electrical current for all motors in the group. More...
 
def power (self, powerUnits=PowerUnits.WATT)
 Gets the power of the first motor. More...
 
def torque (self, torqueUnits=TorqueUnits.NM)
 Gets the torque of the first motor. More...
 
def efficiency (self, percentUnits=PercentUnits.PCT)
 Gets the efficiency of the first motor. More...
 
def temperature (self, temperatureUnits=TemperatureUnits.CELSIUS)
 Gets the temperature of the motor. More...
 

Detailed Description

 Creates a new motor group with specified motors
 @param motors a list or tuple of motors in the group

Constructor & Destructor Documentation

◆ __init__()

def motor_group.MotorGroup.__init__ (   self,
  motors 
)

Member Function Documentation

◆ count()

def motor_group.MotorGroup.count (   self)

return the number of motors in the motor group

Returns
number of motors

◆ set_velocity()

def motor_group.MotorGroup.set_velocity (   self,
  velocity,
  velocityUnits = VelocityUnits.PCT 
)

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.
velocityUnitsThe measurement unit for velocity, a VelocityUnits enum value.

◆ set_stopping()

def motor_group.MotorGroup.set_stopping (   self,
  brakeType 
)

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

Parameters
brakeTypeThe stopping mode can be set to BrakeType.COAST, BRAKE, or HOLD.

◆ reset_rotation()

def motor_group.MotorGroup.reset_rotation (   self)

Resets all motor encoders to the value of zero.

◆ set_rotation()

def motor_group.MotorGroup.set_rotation (   self,
  value,
  rotationUnits = RotationUnits.DEG 
)

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

Parameters
valueSets the amount of rotation.
rotationUnitsThe measurement unit for the rotation, a RotationUnits enum value.

◆ set_timeout()

def motor_group.MotorGroup.set_timeout (   self,
  time,
  timeUnits = TimeUnits.SEC 
)

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.
timeUnitsThe measurement unit for the time, a TimeUnits enum value.

◆ spin()

def motor_group.MotorGroup.spin (   self,
  dir,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

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

Parameters
dirThe direction to spin the motors, a DirectionType enum value.
velocitySets the amount of velocity.
velocityUnitsThe measurement unit for the velocity, a VelocityUnits enum value.

◆ spin_with_voltage()

def motor_group.MotorGroup.spin_with_voltage (   self,
  dir,
  voltage,
  voltageUnits = VoltageUnits.VOLT 
)

Turns on the motors and spins them in a specified direction and a specified voltage.

Parameters
dirThe direction to spin the motor.
voltageSets the amount of volts.
voltageUnitsThe measurement unit for the voltage value. Optional, default is volts.

◆ spin_to()

def motor_group.MotorGroup.spin_to (   self,
  rotation,
  rotationUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT,
  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.
rotationUnitsThe measurement unit for the rotation value.
velocitySets the amount of velocity.
velocityUnitsThe 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.

◆ spin_to_position()

def motor_group.MotorGroup.spin_to_position (   self,
  rotation,
  rotationUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT,
  waitForCompletion = True 
)

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

Same as spinTo.

Parameters
rotationThe motor encoder's target rotation value
rotationUnitsA rotational unit type that defines how the previous value should be treated as.
velocitySet the amount of velocity that the motor should use.
velocityUnitsSet what the motor should treat the previous velocity value as.
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.
Returns
Returns a Boolean that signifies when the motor has reached the target rotation value.

◆ spin_for()

def motor_group.MotorGroup.spin_for (   self,
  dir,
  rotation,
  rotationUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT,
  waitForCompletion = True 
)

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

Returns
True if motors have reached the target rotation value, False otherwise.
Parameters
dirdirection to spin in, a DirectionType enum value or None.
rotationSets the amount of rotation.
rotationUnitsThe measurement unit for the rotation value.
velocitySets the amount of velocity.
velocityUnitsThe 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.

◆ spin_for_time()

def motor_group.MotorGroup.spin_for_time (   self,
  dir,
  time,
  timeUnits = TimeUnits.SEC,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

Turn on the motors and spin them for a given amount of time.

Parameters
dirdirection to spin in, a DirectionType enum value or None.
timeSets the amount of time.
timeUnitsThe measurement unit for the time value, a TimeUnits enum value.
velocitySets the amount of velocity.
velocityUnitsThe measurement unit for the velocity value, a VelocityUnits enum value.

◆ start_spin_to()

def motor_group.MotorGroup.start_spin_to (   self,
  rotation,
  rotationUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

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

Parameters
rotationSets the amount of rotation.
rotationUnitsThe measurement unit for the rotation value.
velocitySets the amount of velocity.
velocityUnitsThe measurement unit for the velocity value.

◆ start_spin_to_position()

def motor_group.MotorGroup.start_spin_to_position (   self,
  rotation,
  rotationUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

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

Same as startSpinTo

Parameters
rotationThis is the motor encoder's target rotation value
rotationUnitsThis is a rotational unit type that defines how the previous value should be treated as.
velocitySet the amount of velocity that the motor should use.
velocityUnitsSet what the motor should treat the previous velocity value as.

◆ start_spin_for()

def motor_group.MotorGroup.start_spin_for (   self,
  dir,
  rotation,
  rotationUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

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

Parameters
dirdirection to spin in, a DirectionType enum value or None.
rotationSets the amount of rotation.
rotationUnitsThe measurement unit for the rotation value.
velocitySets the amount of velocity.
velocityUnitsThe measurement unit for the velocity value.

◆ is_spinning()

def motor_group.MotorGroup.is_spinning (   self)

Checks to see if a spin_for/spin_to command is still in process, i.e.

any motor is still rotating and hasn't yet reached its target position.

Returns
Returns a true Boolean if the motor is on and is running. Returns a false Boolean if the motor is off or braking.

◆ is_done()

def motor_group.MotorGroup.is_done (   self)

Determines if a spin_for/spin_to command has reached its target position.

Returns
False if any motor is on and is rotating to a target, True if all motors are done rotating to a target.

◆ stop()

def motor_group.MotorGroup.stop (   self,
  brakeType = None 
)

Stops all motors using the default brake mode.

Parameters
brakeTypeThe brake mode can be set to BrakeType.COAST, BRAKE, or HOLD.

◆ set_max_torque()

def motor_group.MotorGroup.set_max_torque (   self,
  value,
  torqueUnits = TorqueUnits.NM 
)

Sets the max torque of all motors.

Parameters
valueSets the amount of torque (max 0.414 Nm)
torqueUnitsThe measurement unit for the torque value.

◆ set_max_torque_percent()

def motor_group.MotorGroup.set_max_torque_percent (   self,
  value 
)

Sets the max torque of all motors as a percentage.

Parameters
valueSets the amount of torque (0 to 100%)

◆ set_max_torque_current()

def motor_group.MotorGroup.set_max_torque_current (   self,
  value 
)

Sets the max torque of all motors.

Parameters
valueSets the amount of torque in Amps (max 1.2A)

◆ direction()

def motor_group.MotorGroup.direction (   self)

Gets which direction the first motor is spinning.

Returns
Returns an integer that represents the direction that the motor is spinning.

◆ rotation()

def motor_group.MotorGroup.rotation (   self,
  rotationUnits = RotationUnits.DEG 
)

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
rotationUnitsThe measurement unit for the rotation.

◆ velocity()

def motor_group.MotorGroup.velocity (   self,
  velocityUnits = VelocityUnits.PCT 
)

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

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

◆ current()

def motor_group.MotorGroup.current (   self)

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

Returns
Returns a float that represents the electrical current of the motors.

◆ power()

def motor_group.MotorGroup.power (   self,
  powerUnits = PowerUnits.WATT 
)

Gets the power of the first motor.

Parameters
powerUnits
Returns
Returns a float that represents the power of the motor in the units defined in the parameter.

◆ torque()

def motor_group.MotorGroup.torque (   self,
  torqueUnits = TorqueUnits.NM 
)

Gets the torque of the first motor.

Parameters
torqueUnitsDefines the unit type of torque to be returned.
Returns
Returns a double that represents the torque of the motor in the units defined in the parameter.

◆ efficiency()

def motor_group.MotorGroup.efficiency (   self,
  percentUnits = PercentUnits.PCT 
)

Gets the efficiency of the first motor.

Parameters
percentUnitsDefines the unit type of the efficiency value to be returned.
Returns
Returns the efficiency of the motor in the units defined in the parameter.

◆ temperature()

def motor_group.MotorGroup.temperature (   self,
  temperatureUnits = TemperatureUnits.CELSIUS 
)

Gets the temperature of the motor.

Parameters
temperatureUnitsDefines the unit type of the temperature value to be returned. Default Celsius.
Returns
Returns the temperature of the motor in the units defined in the parameter.