VEX V5 Python API
|
Inherits vex.Device.
Public Member Functions | |
def | __init__ (self, index, gearSetting=GearSetting.RATIO18_1, reverse=False) |
Creates a new motor object on the port specified. More... | |
def | set_reversed (self, isReversed) |
Use this function to reverse setting for the motor. More... | |
def | set_velocity (self, velocity, velocityUnits=VelocityUnits.PCT) |
Sets the velocity of the motor based on the parameters set in the command. More... | |
def | set_stopping (self, brakeType) |
Sets the stopping mode of the motor by passing a brake mode as a parameter. More... | |
def | reset_rotation (self) |
Resets the motor's encoder to the value of zero. More... | |
def | set_rotation (self, value, rotationUnits=RotationUnits.DEG) |
Sets the value of the motor's encoder to the value specified in the parameter. More... | |
def | set_timeout (self, time, timeUnits=TimeUnits.SEC) |
Sets the timeout for the motor. More... | |
def | timeout (self, timeUnits=TimeUnits.SEC) |
Return the timeout for the motor. More... | |
def | did_timeout (self) |
Check if the last motor operation timed out. More... | |
def | spin (self, direction, velocity=None, velocityUnits=VelocityUnits.PCT) |
Turns on the motor and spins it in a specified direction and velocity (if specified). More... | |
def | spin_with_voltage (self, direction, voltage, voltageUnits=VoltageUnits.VOLT) |
Turns on the motor and spins it 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 motor and spins it 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 motor and spins it to an absolute target rotation value at a specified velocity. More... | |
def | spin_for (self, direction, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True) |
Turns on the motor and spins it to a relative target rotation value at a specified velocity. More... | |
def | spin_for_time (self, direction, time, timeUnits=TimeUnits.SEC, velocity=None, velocityUnits=VelocityUnits.PCT) |
Turns on the motor and spins it for specified time at a specified velocity. More... | |
def | start_spin_to (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_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, direction, rotation, rotationUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT) |
Starts spinning a motor to a relative target rotation but does not wait for the motor 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 the motor using a specified brake mode (or default mode if not specified). More... | |
def | set_max_torque (self, value, torqueUnits=TorqueUnits.NM) |
Sets the max torque of the motor, in torque units. More... | |
def | set_max_torque_percent (self, value, percentUnits=PercentUnits.PCT) |
Sets the max torque of the motor, in percent. More... | |
def | set_max_torque_current (self, value, currentUnits=CurrentUnits.AMP) |
Sets the max torque of the motor, in terms of current. More... | |
def | direction (self) |
Gets which direction the motor is spinning. More... | |
def | rotation (self, rotationUnits=RotationUnits.DEG) |
Gets the current rotation of the motor's encoder. More... | |
def | velocity (self, velocityUnits=VelocityUnits.PCT) |
Gets the current velocity of the motor. More... | |
def | current (self, currentUnits=CurrentUnits.AMP) |
Gets the electrical current of the motor. More... | |
def | voltage (self, voltageUnits=VoltageUnits.VOLT) |
Gets the electrical voltage being applied to the motor. More... | |
def | power (self, powerUnits=PowerUnits.WATT) |
Gets the power of the motor. More... | |
def | torque (self, torqueUnits=TorqueUnits.NM) |
Gets the torque of the motor. More... | |
def | efficiency (self, percentUnits=PercentUnits.PCT) |
Gets the efficiency of the motor. More... | |
def | temperature (self, temperatureUnits=TemperatureUnits.CELSIUS) |
Gets the temperature of the motor. More... | |
def | type (self) |
Get the device type. More... | |
def | installed (self) |
Gets the status of what is installed. More... | |
def | value (self) |
def vex.Motor.__init__ | ( | self, | |
index, | |||
gearSetting = GearSetting.RATIO18_1 , |
|||
reverse = False |
|||
) |
Creates a new motor object on the port specified.
index | The port index for this motor. The index is zero based. |
gearSetting | Sets the gears setting for the new motor object. |
reverse | Sets the reverse flag for the new motor object. |
def vex.Motor.set_reversed | ( | self, | |
isReversed | |||
) |
Use this function to reverse setting for the motor.
isReversed | If set to true, the motor will spin in the reversed direction. |
def vex.Motor.set_velocity | ( | self, | |
velocity, | |||
velocityUnits = VelocityUnits.PCT |
|||
) |
Sets the velocity of the motor 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.
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set what the motor should treat the previous velocity value as. |
def vex.Motor.set_stopping | ( | self, | |
brakeType | |||
) |
Sets the stopping mode of the motor by passing a brake mode as a parameter.
brakeType | The stopping mode can be set to coast, brake, or hold. |
def vex.Motor.reset_rotation | ( | self | ) |
Resets the motor's encoder to the value of zero.
def vex.Motor.set_rotation | ( | self, | |
value, | |||
rotationUnits = RotationUnits.DEG |
|||
) |
Sets the value of the motor's encoder to the value specified in the parameter.
value | The value of what you want the motor's encoder to be set to. |
rotationUnits | A rotational unit type that defines how the previous value should be treated as. |
def vex.Motor.set_timeout | ( | self, | |
time, | |||
timeUnits = TimeUnits.SEC |
|||
) |
Sets the timeout for the motor.
If the motor does not reach its' commanded position prior to the completion of the timeout, the motor will turn off.
time | The value of the time out expiration. |
timeUnits | A time unit that defines how to treat the previous value. |
def vex.Motor.timeout | ( | self, | |
timeUnits = TimeUnits.SEC |
|||
) |
Return the timeout for the motor.
def vex.Motor.did_timeout | ( | self | ) |
Check if the last motor operation timed out.
def vex.Motor.spin | ( | self, | |
direction, | |||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT |
|||
) |
Turns on the motor and spins it in a specified direction and velocity (if specified).
direction | Spin the motor forward by passing FWD, or spin the motor backward by passing REV. |
velocity | Set the amount of velocity that the motor should use. Optional. |
velocityUnits | Set what the motor should treat the previous velocity value as. Optional. |
def vex.Motor.spin_with_voltage | ( | self, | |
direction, | |||
voltage, | |||
voltageUnits = VoltageUnits.VOLT |
|||
) |
Turns on the motor and spins it in a specified direction and a specified voltage.
direction | The direction to spin the motor. |
voltage | Sets the amount of volts. |
voltageUnits | The measurement unit for the voltage value. Optional, default is volts. |
def vex.Motor.spin_to | ( | self, | |
rotation, | |||
rotationUnits = RotationUnits.DEG , |
|||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT , |
|||
waitForCompletion = True |
|||
) |
Turns on the motor and spins it to an absolute target rotation value at a specified velocity.
rotation | The motor encoder's target rotation value |
rotationUnits | A rotational unit type that defines how the previous value should be treated as. |
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set 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. |
def vex.Motor.spin_to_position | ( | self, | |
rotation, | |||
rotationUnits = RotationUnits.DEG , |
|||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT , |
|||
waitForCompletion = True |
|||
) |
Turns on the motor and spins it to an absolute target rotation value at a specified velocity.
Same as spinTo
.
rotation | The motor encoder's target rotation value |
rotationUnits | A rotational unit type that defines how the previous value should be treated as. |
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set 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. |
def vex.Motor.spin_for | ( | self, | |
direction, | |||
rotation, | |||
rotationUnits = RotationUnits.DEG , |
|||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT , |
|||
waitForCompletion = True |
|||
) |
Turns on the motor and spins it to a relative target rotation value at a specified velocity.
direction | Direction to spin in, vex.DirectionType.FWD or REV. |
rotation | The motor encoder's target rotation value |
rotationUnits | A rotational unit type that defines how the previous value should be treated as. |
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set 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. |
def vex.Motor.spin_for_time | ( | self, | |
direction, | |||
time, | |||
timeUnits = TimeUnits.SEC , |
|||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT |
|||
) |
Turns on the motor and spins it for specified time at a specified velocity.
direction | Direction to spin in, vex.DirectionType.FWD or REV. |
time | The value of time that the motor should spin for. |
timeUnits | A time unit that defines how to treat the previous value. |
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set what the motor should treat the previous velocity value as. |
def vex.Motor.start_spin_to | ( | 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.
rotation | This is the motor encoder's target rotation value |
rotationUnits | This is a rotational unit type that defines how the previous value should be treated as. |
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set what the motor should treat the previous velocity value as. |
def vex.Motor.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
rotation | This is the motor encoder's target rotation value |
rotationUnits | This is a rotational unit type that defines how the previous value should be treated as. |
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set what the motor should treat the previous velocity value as. |
def vex.Motor.start_spin_for | ( | self, | |
direction, | |||
rotation, | |||
rotationUnits = RotationUnits.DEG , |
|||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT |
|||
) |
Starts spinning a motor to a relative target rotation but does not wait for the motor to reach that target.
direction | Direction to spin in, vex.DirectionType.FWD or REV. |
rotation | This is the motor encoder's target rotation value |
rotationUnits | This is a rotational unit type that defines how the previous value should be treated as. |
velocity | Set the amount of velocity that the motor should use. |
velocityUnits | Set what the motor should treat the previous velocity value as. |
def vex.Motor.is_spinning | ( | self | ) |
Checks to see if a spin_for/spin_to command is still in process, i.e.
the motor is still rotating and hasn't yet reached its target position.
def vex.Motor.is_done | ( | self | ) |
Determines if a spin_for/spin_to command has reached its target position.
def vex.Motor.stop | ( | self, | |
brakeType = None |
|||
) |
Stops the motor using a specified brake mode (or default mode if not specified).
def vex.Motor.set_max_torque | ( | self, | |
value, | |||
torqueUnits = TorqueUnits.NM |
|||
) |
Sets the max torque of the motor, in torque units.
value | The value that the motor's max torque should be set to. |
torqueUnits | torque units, default Nm |
def vex.Motor.set_max_torque_percent | ( | self, | |
value, | |||
percentUnits = PercentUnits.PCT |
|||
) |
Sets the max torque of the motor, in percent.
value | The value that the motor's max torque should be set to. |
percentUnits | percent units (percent). |
def vex.Motor.set_max_torque_current | ( | self, | |
value, | |||
currentUnits = CurrentUnits.AMP |
|||
) |
Sets the max torque of the motor, in terms of current.
value | The value that the motor's max torque should be set to. |
currentUnits | current units (amps). |
def vex.Motor.direction | ( | self | ) |
Gets which direction the motor is spinning.
def vex.Motor.rotation | ( | self, | |
rotationUnits = RotationUnits.DEG |
|||
) |
Gets the current rotation of the motor's encoder.
rotationUnits | Defines what the unity type of the value of rotation that is returned. |
def vex.Motor.velocity | ( | self, | |
velocityUnits = VelocityUnits.PCT |
|||
) |
Gets the current velocity of the motor.
velocityUnits | Defines the unit type of the velocity value returned. |
def vex.Motor.current | ( | self, | |
currentUnits = CurrentUnits.AMP |
|||
) |
Gets the electrical current of the motor.
currentUnits | Defines the unit type of the electrical current value that is returned. |
def vex.Motor.voltage | ( | self, | |
voltageUnits = VoltageUnits.VOLT |
|||
) |
Gets the electrical voltage being applied to the motor.
voltageUnits | The measurement unit for the voltage. |
def vex.Motor.power | ( | self, | |
powerUnits = PowerUnits.WATT |
|||
) |
Gets the power of the motor.
powerUnits |
def vex.Motor.torque | ( | self, | |
torqueUnits = TorqueUnits.NM |
|||
) |
Gets the torque of the motor.
torqueUnits | Defines the unit type of torque to be returned. |
def vex.Motor.efficiency | ( | self, | |
percentUnits = PercentUnits.PCT |
|||
) |
Gets the efficiency of the motor.
percentUnits | Defines the unit type of the efficiency value to be returned. |
def vex.Motor.temperature | ( | self, | |
temperatureUnits = TemperatureUnits.CELSIUS |
|||
) |
Gets the temperature of the motor.
temperatureUnits | Defines the unit type of the temperature value to be returned. Default Celsius. |
|
inherited |
Get the device type.
|
inherited |
Gets the status of what is installed.
|
inherited |