VEX IQ Python API
|
Public Member Functions | |
def | __init__ (self, index, reverse=False) |
def | set_reversed (self, is_reversed) |
Sets the motor mode to "reverse", which will make motor commands spin the motor in the opposite direction. 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) |
def | did_timeout (self) |
def | spin (self, dir, velocity=None, velocityUnits=VelocityUnits.PCT) |
Turns on the motor and spins it in a specified direction and a specified velocity. 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_for (self, dir, 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, dir, time, timeUnits=TimeUnits.SEC, velocity=None, velocityUnits=VelocityUnits.PCT) |
Turns on the motor and spins it to a relative target time value 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_for (self, dir, 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) |
Determines if a spin_for/spin_to command is in progress. 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 the default brake mode. More... | |
def | set_max_torque_percent (self, value) |
Sets the max torque of the motor as a percentage. More... | |
def | set_max_torque (self, value, torqueUnits=TorqueUnits.NM) |
Sets the max torque of the motor. More... | |
def | set_max_torque_current (self, value) |
Sets the max torque of the motor. 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) |
Gets the electrical current of the motor. More... | |
@brief Creates a new motor object on the port specified and sets the reversed flag. @param index The port index for this motor. The index is zero-based. @param reverse Sets the reverse flag for the new motor object.
def vex.Motor.__init__ | ( | self, | |
index, | |||
reverse = False |
|||
) |
def vex.Motor.set_reversed | ( | self, | |
is_reversed | |||
) |
Sets the motor mode to "reverse", which will make motor commands spin the motor in the opposite direction.
is_reversed | If set to True, motor commands spin the motor in the opposite 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 | Sets the amount of velocity. |
velocityUnits | The measurement unit for the velocity, a VelocityUnits enum value. |
def vex.Motor.set_stopping | ( | self, | |
brakeType | |||
) |
Sets the stopping mode of the motor by passing a brake mode as a parameter.
(note this will stop the motor if it's spinning)
brakeType | The stopping mode can be set to BrakeType.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 | Sets the amount of rotation. |
rotationUnits | The measurement unit for the rotation, a RotationUnits enum value. |
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 stop.
time | Sets the amount of time. |
timeUnits | The measurement unit for the time, a TimeUnits enum value. |
def vex.Motor.timeout | ( | self, | |
timeUnits = TimeUnits.SEC |
|||
) |
def vex.Motor.did_timeout | ( | self | ) |
def vex.Motor.spin | ( | self, | |
dir, | |||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT |
|||
) |
Turns on the motor and spins it in a specified direction and a specified velocity.
dir | The direction to spin the motor, DirectionType enum value. |
velocity | Sets the amount of velocity. |
velocityUnits | The measurement unit for the velocity, a VelocityUnits enum value. |
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 | Sets the amount of rotation. |
rotationUnits | The measurement unit for the rotation value. |
velocity | Sets the amount of velocity. |
velocityUnits | The 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. |
def vex.Motor.spin_for | ( | self, | |
dir, | |||
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.
dir | direction to spin in, a DirectionType enum value or None. |
rotation | Sets the amount of rotation. |
rotationUnits | The measurement unit for the rotation value. |
velocity | Sets the amount of velocity. |
velocityUnits | The 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. |
def vex.Motor.spin_for_time | ( | self, | |
dir, | |||
time, | |||
timeUnits = TimeUnits.SEC , |
|||
velocity = None , |
|||
velocityUnits = VelocityUnits.PCT |
|||
) |
Turns on the motor and spins it to a relative target time value at a specified velocity.
dir | direction to spin in, a DirectionType enum value or None. |
time | Sets the amount of time. |
timeUnits | The measurement unit for the time value. |
velocity | Sets the amount of velocity. |
velocityUnits | The measurement unit for the velocity value. |
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 | Sets the amount of rotation. |
rotationUnits | The measurement unit for the rotation value. |
velocity | Sets the amount of velocity. |
velocityUnits | The measurement unit for the velocity value. |
def vex.Motor.start_spin_for | ( | self, | |
dir, | |||
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.
dir | direction to spin in, a DirectionType enum value or None. |
rotation | Sets the amount of rotation. |
rotationUnits | The measurement unit for the rotation value. |
velocity | Sets the amount of velocity. |
velocityUnits | The measurement unit for the velocity value. |
def vex.Motor.is_spinning | ( | self | ) |
Determines if a spin_for/spin_to command is in progress.
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 the default brake mode.
brakeType | The brake mode can be set to BrakeType.COAST, BRAKE, or HOLD. |
def vex.Motor.set_max_torque_percent | ( | self, | |
value | |||
) |
Sets the max torque of the motor as a percentage.
value | Sets the amount of torque (0 to 100%) |
def vex.Motor.set_max_torque | ( | self, | |
value, | |||
torqueUnits = TorqueUnits.NM |
|||
) |
Sets the max torque of the motor.
value | Sets the amount of torque (max 0.414 Nm) |
torqueUnits | The measurement unit for the torque value. |
def vex.Motor.set_max_torque_current | ( | self, | |
value | |||
) |
Sets the max torque of the motor.
value | Sets the amount of torque in Amps (max 1.2A) |
def vex.Motor.rotation | ( | self, | |
rotationUnits = RotationUnits.DEG |
|||
) |
Gets the current rotation of the motor's encoder.
rotationUnits | The measurement unit for the rotation. |
def vex.Motor.velocity | ( | self, | |
velocityUnits = VelocityUnits.PCT |
|||
) |
Gets the current velocity of the motor.
velocityUnits | The measurement unit for the velocity. |
def vex.Motor.current | ( | self | ) |
Gets the electrical current of the motor.