摩托胜利者#
初始化 motor_victor 类#
使用以下构造函数之一可以创建 Motor Victor 控制器:
The motor_victor constructor creates a motor_victor object in the specified Three Wire Port.
范围 |
描述 |
|---|---|
|
The 3-Wire Port that the Motor Victor Controller is connected to, whether it’s a port on the |
// 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.
范围 |
描述 |
|---|---|
|
The 3-Wire Port that the Motor Victor Controller is connected to, whether it’s a port on the |
|
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);
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the motor_victor Class constructor.
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.
参数 |
描述 |
|---|---|
|
A valid |
**返回:**无。
// 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.
参数 |
描述 |
|---|---|
|
A valid |
|
旋转电机的速度。 |
|
A valid |
**返回:**无。
// 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 |
**返回:**无。