电机29#

初始化 motor29 类#

使用以下构造函数之一创建用于控制电机 393 的电机控制器 29。

The motor29(port) constructor creates a motor29 object in the specified Three Wire Port.

范围

描述

port

电机控制器 29 连接到的 3 线端口,无论它是 大脑 上的端口,还是 3 线扩展器 上的端口。

The motor29(port, reverse) constructor creates a motor29 object in the specified Three Wire Port with the reverse flag set to the specified value.

范围

描述

port

电机控制器 29 连接到的 3 线端口,无论它是 大脑 上的端口,还是 3 线扩展器 上的端口。

reverse

Set this Motor to be reversed or not. If set to true, the Motor will spin in the opposite rotation. The default is false.

必须先创建 Brain3-Wire Expander,然后才能使用 motor29 类构造函数创建对象。

// Create the Brain.
brain Brain;
// Construct a Motor Controller 29 "mc29" with the motor29 class.
motor29 mc29 = motor29(Brain.ThreeWirePort.A);

This mc29 object will be used in all subsequent examples throughout this API documentation when referring to Motor29 class methods.

类方法#

spin()#

这是一种非等待方法,允许下一个方法无延迟运行。

该方法通过以下方式调用:

The spin(dir) 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 motor forward.
mc29.spin(forward);

The spin(direction, velocity, units) method spins the motor in a specified direction at the specified velocity. The motor is assumed to have a maximum velocity of 100 rpm.

参数

描述

方向

有效的 directionType

速度

旋转电机的速度。

单位

有效的 velocityUnit

// spin motor forward at 100 rpm.
mc29.spin(forward, 100, rpm);

**返回:**无。

stop()#

The stop() method stops the motor.

**返回:**无。

setVelocity()#

The setVelocity(velocity, units) method sets the velocity of the motor. This will be the velocity used for subsequent calls of the spin() method that do not specify a velocity.

这是一种非等待方法,允许下一个方法无延迟运行。

参数

描述

速度

要设置的速度值。

单位

The only valid unit for velocity in this usecase is percent.

**返回:**无。

setReversed()#

The setReversed() method sets the motor direction to be reversed or not.

参数

描述

价值

用于设置方向是否反转的布尔值或二进制值。

**返回:**无。