摩托维克托#
初始化 MotorVictor 类#
使用以下构造函数创建 Motor Victor 控制器:
MotorVictor(port, reverse)
此构造函数使用两个参数:
范围 |
描述 |
---|---|
|
|
|
Optional. Set this Motor to be reversed or not. If set to |
必须先创建 Brain 或 3-Wire Expander,然后才能使用 MotorVictor 类构造函数创建对象。
# 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.
类方法#
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.
这是一个非等待命令,允许下一个命令无延迟运行。
参数 |
描述 |
---|---|
方向 |
有效的 DirectionType。 |
速度 |
Optional. The velocity to spin the Motor. The default is the value set by the |
单位 |
Optional. A valid VelocityUnits type. The default is |
**返回:**无。
# Spin the Motor forward at velocity set with set_velocity.
victor.spin(FORWARD)
stop()#
The stop()
method stops the Motor.
**返回:**无。
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.
参数 |
描述 |
---|---|
价值 |
要设置的速度值。 |
单位 |
Optional. A valid VelocityUnits type. The default is |
**返回:**无。
set_reversed()#
The set_reversed()
method sets the Motor direction to be reversed or not.
参数 |
描述 |
---|---|
价值 |
|
**返回:**无。
# set Motor reversed flag True
victor.set_reversed(True)