摩托胜利者#
初始化 motor_victor 类#
使用以下构造函数之一可以创建 Motor Victor 控制器:
The motor_victor
constructor creates a motor_victor object in the specified Three Wire Port.
范围 |
描述 |
---|---|
|
// Create the Brain.
brain Brain;
// Construct a Motor Victor Controller "victor" with the
// MotorVictor class.
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);
The motor_victor(port, reverse)
constructor creates a motor_victor object in the specified Three Wire Port with the reverse flag set to the specified value.
范围 |
描述 |
---|---|
|
|
|
Set this Motor to be reversed or not. If set to |
// Create the Brain.
brain Brain;
// Construct a Motor Victor Controller "victor" with the
// motor_victor class.
motor_victor victor = motor_victor(Brain.ThreeWirePort.A, true);
必须先创建 Brain 或 3-Wire Expander,然后才能使用 motor_victor 类构造函数创建对象。
This victor
object will be used in all subsequent examples throughout this API documentation when referring to MotorVictor class methods.
类方法#
spin()#
这是一种非等待方法,允许下一个方法无延迟运行。
该方法通过以下方式调用:
The spin(direction)
method spins the Motor in a specified direction at the default velocity. The Motor is assumed to have a maximum velocity of 100 rpm.
参数 |
描述 |
---|---|
方向 |
有效的 directionType。 |
**返回:**无。
// Spin the Motor forward.
victor.spin(forward);
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。 |
速度 |
旋转电机的速度。 |
单位 |
有效的 velocityUnit。 |
**返回:**无。
// Spin the Motor forward at 100 rpm.
victor.spin(forward, 100, rpm);
stop()#
The stop()
method stops the Motor.
**返回:**无。
setVelocity()#
The setVelocity()
method sets the velocity of the Motor. This will be the velocity used for subsequent calls of spin()
if a velocity is not provided.
参数 |
描述 |
---|---|
价值 |
要设置的速度值。 |
单位 |
The only valid unit for velocity in this usecase is |
**返回:**无。
setReversed()#
The setReversed(value)
method sets the Motor direction to be reversed or not.
参数 |
描述 |
---|---|
价值 |
A boolean or binary value to set the reverse flag of the motor to |
**返回:**无。