MotorVictor#
Initializing the MotorVictor Class#
A Motor Victor Controller is created by using the following constructor:
MotorVictor(port, reverse)
This constructor uses two parameters:
Parameter |
Description |
---|---|
|
The 3-Wire Port that the Motor Victor Controller is connected to, whether it’s a port on the Brain, or a 3-Wire Expander. |
|
Optional. Set this Motor to be reversed or not. If set to |
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the MotorVictor Class constructor.
# Create the Brain.
brain = Brain()
# Construct a Motor Victor Controller "victor" with the
# MotorVictor class.
victor = MotorVictor(brain.three_wire_port.a)
This victor
object will be used in all subsequent examples throughout this API documentation when referring to MotorVictor class methods.
Class Methods#
spin()#
The spin(direction, velocty, units)
method spins the Motor in a specified direction. The Motor is assumed to have a maximum velocity of 100 rpm.
This is a non-waiting command and allows the next command to run without delay.
Parameters |
Description |
---|---|
direction |
A valid DirectionType. |
velocity |
Optional. The velocity to spin the Motor. The default is the value set by the |
units |
Optional. A valid VelocityUnits type. The default is |
Returns: None.
# Spin the Motor forward at velocity set with set_velocity.
victor.spin(FORWARD)
stop()#
The stop()
method stops the Motor.
Returns: None.
set_velocity()#
The set_velocity()
method sets the velocity of the Motor. This will be the velocity used for subsequent uses of spin()
if a velocity is not provided.
Parameters |
Description |
---|---|
value |
The velocity value to set. |
units |
Optional. A valid VelocityUnits type. The default is |
Returns: None.
set_reversed()#
The set_reversed()
method sets the Motor direction to be reversed or not.
Parameters |
Description |
---|---|
value |
|
Returns: None.
# set Motor reversed flag True
victor.set_reversed(True)