vex.motor package¶
Motor.
- class vex.motor.BrakeType(value)[source]¶
Bases:
IntEnumMotor Brake Types.
ROBOT MESH PYTHON B:
The defined units for brake values.
robotmesh.com/studio/content/docs/vexiq-python_b/html/classvex_1_1_brake_type.html
- BRAKE: int = 1¶
- COAST: int = 0¶
- HOLD: int = 2¶
- class vex.motor.DirectionType(value)[source]¶
Bases:
IntEnumMovement Direction Types.
ROBOT MESH PYTHON B:
The defined units for direction values.
robotmesh.com/studio/content/docs/vexiq-python_b/html/classvex_1_1_direction_type.html
- FWD: int = 0¶
- REV: int = 1¶
- class vex.motor.Motor(index: Ports, reverse: bool = False)[source]¶
Bases:
DeviceMotor.
ROBOT MESH PYTHON B:
robotmesh.com/studio/content/docs/vexiq-python_b/html/classvex_1_1_motor.html
- current() float[source]¶
Return Motor’s Electrical Current.
ROBOT MESH PYTHON B:
Get the electrical current of the motor.
Returns: a float that represents the electrical current of the motor in Amps.
- did_timeout() bool[source]¶
Return whether Motor timed out.
ROBOT MESH PYTHON B:
Return True if the last motor operation timed out.
- is_done() bool[source]¶
Check if Motor has finished spinning.
ROBOT MESH PYTHON B:
Determine if spin_for/spin_to command has reached its target position.
Returns: False if the motor is on and is rotating to a target, True if the motor is done rotating to a target.
- is_spinning() bool[source]¶
Check if Motor is spinning.
ROBOT MESH PYTHON B:
Determine if a spin_for/spin_to command is in progress.
Returns: True if the motor is on and is rotating to a target, False if the motor is done rotating to a target.
- reset_rotation()[source]¶
Reset Motor Rotation Value to 0.
ROBOT MESH PYTHON B:
Reset the motor’s encoder to the value of zero.
- rotation(rotationUnits: RotationUnits = RotationUnits.DEG) float[source]¶
Return Motor’s cumulative Rotation Angle Value.
ROBOT MESH PYTHON B:
Get the current rotation of the motor’s encoder.
Parameters: rotationUnits: The measurement unit for the rotation.
Returns: a float that represents the current rotation of the motor in the units defined in the parameter.
- set_max_torque(value: float, torqueUnits: TorqueUnits = TorqueUnits.NM)[source]¶
Set Max Torque.
ROBOT MESH PYTHON B:
Set the max torque of the motor.
Parameters: - value: Sets the amount of torque (max 0.414 Nm) - torqueUnits: The measurement unit for the torque value.
- set_max_torque_current(value: float)[source]¶
Set Max Torque Current.
ROBOT MESH PYTHON B:
Set the max torque of the motor.
Parameters: - value: Sets the amount of torque in Amps (max 1.2A)
- set_max_torque_percent(value: float)[source]¶
Set Max Torque Percent.
ROBOT MESH PYTHON B:
Set the max torque of the motor as a percentage.
Parameters: - value: Sets the amount of torque (0 to 100%)
- set_reversed(is_reversed: bool)[source]¶
Set Reversed Mode.
ROBOT MESH PYTHON B:
Set the motor mode to “reverse”.
(which will make motor commands spin the motor in the opposite direction)
Parameters: - is_reversed: If set to True, motor commands
spin the motor in the opposite direction.
- set_rotation(value: float, rotationUnits: RotationUnits = RotationUnits.DEG)[source]¶
Set Motor Rotation Value to specific value.
ROBOT MESH PYTHON B:
Set value of motor’s encoder to value specified in parameter.
Parameters: - value: Sets the amount of rotation. - rotationUnits: The measurement unit for the rotation,
a RotationUnits enum value.
- set_stopping(brakeType: BrakeType)[source]¶
Set Stopping Mode.
ROBOT MESH PYTHON B:
Set stopping mode of the motor by passing a brake mode as a parameter.
(note this will stop the motor if it’s spinning)
Parameters: - brakeType: The stopping mode can be set to
BrakeType.COAST, BRAKE, or HOLD.
- set_timeout(time: float, timeUnits: TimeUnits = TimeUnits.SEC)[source]¶
Set Motor Timeout Threshold.
ROBOT MESH PYTHON B:
Set 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.
Parameters: - time: Sets the amount of time. - timeUnits: The measurement unit for the time, a TimeUnits enum value.
- set_velocity(velocity: float, velocityUnits: VelocityUnits = VelocityUnits.PCT)[source]¶
Set Velocity.
ROBOT MESH PYTHON B:
Set 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.
Parameters: - velocity: Sets the amount of velocity. - velocityUnits: The measurement unit for the velocity,
a VelocityUnits enum value.
- spin(dir: DirectionType, velocity: float, velocityUnits: VelocityUnits = VelocityUnits.PCT)[source]¶
Spin Motor.
ROBOT MESH PYTHON B:
Turn on the motor and spins it.
(in a specified direction and a specified velocity)
Parameters: - 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.
- spin_for(dir: DirectionType, rotation: float, rotationUnits: RotationUnits = RotationUnits.DEG, velocity: Optional[float] = None, velocityUnits: VelocityUnits = VelocityUnits.PCT, waitForCompletion: bool = True) bool[source]¶
Spin Motor for a certain Rotation Angle Value.
ROBOT MESH PYTHON B:
Turn on the motor and spins it.
(to a relative target rotation value at a specified velocity)
Parameters: - dir: The direction to spin the motor, DirectionType enum value. - 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.
Returns: Returns a Boolean that signifies when the motor has reached the target rotation value.
- spin_for_time(dir: DirectionType, time: str, timeUnits: TimeUnits = TimeUnits.SEC, velocity: Optional[float] = None, velocityUnits: VelocityUnits = VelocityUnits.PCT)[source]¶
Spin Motor for a certain Time Duration.
ROBOT MESH PYTHON B:
Turn on the motor and spins it.
(to a relative target time value at a specified velocity)
Parameters: - 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.
- spin_to(rotation: float, rotationUnits: RotationUnits = RotationUnits.DEG, velocity: Optional[float] = None, velocityUnits: VelocityUnits = VelocityUnits.PCT, waitForCompletion: bool = True) bool[source]¶
Spin Motor to target Rotation Angle Value.
ROBOT MESH PYTHON B:
Turn on the motor and spins it.
(to an absolute target rotation value at a specified velocity)
Parameters: - 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.
- start_spin_for(dir: DirectionType, rotation: float, rotationUnits: RotationUnits = RotationUnits.DEG, velocity: Optional[float] = None, velocityUnits: VelocityUnits = VelocityUnits.PCT)[source]¶
Start spinning motor for a certain Rotation Angle Value.
ROBOT MESH PYTHON B:
Start spinning a motor.
(to a relative target rotation but does not wait for the motor to reach that target)
Parameters: - 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.
- start_spin_to(rotation: float, rotationUnits: RotationUnits = RotationUnits.DEG, velocity: Optional[float] = None, velocityUnits: VelocityUnits = VelocityUnits.PCT)[source]¶
Start spinning Motor to a certain Target Rotation Angle Value.
ROBOT MESH PYTHON B:
Start spinning a motor.
(to an absolute target rotation but does not wait for the motor to reach that target)
Params: - 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.
- stop(brakeType: Optional[BrakeType] = None)[source]¶
Stop Motor.
ROBOT MESH PYTHON B:
Stop the motor using the default brake mode.
Parameters: - brakeType: The brake mode can be set to
BrakeType.COAST, BRAKE, or HOLD.
- timeout(timeUnits: TimeUnits = TimeUnits.SEC) float[source]¶
Return Motor Timeout.
ROBOT MESH PYTHON B:
Return a timeout in given time units.
- velocity(velocityUnits: VelocityUnits = VelocityUnits.PCT) float[source]¶
Return Motor’s Velocity.
ROBOT MESH PYTHON B:
Get the current velocity of the motor.
Parameters: - velocityUnits: The measurement unit for the velocity.
Returns: a float that represents the current velocity of the motor in the units defined in the parameter.
- class vex.motor.TorqueUnits(value)[source]¶
Bases:
IntEnumTorque Units.
ROBOT MESH PYTHON B:
The measurement units for torque values.
robotmesh.com/studio/content/docs/vexiq-python_b/html/classvex_1_1_torque_units.html
- IN_LB: int = 1¶
- NM: int = 0¶
- PCT: int = 2¶