Motor29#

初始化 Motor29 类#

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

Motor29(port, reverse)

此构造函数使用两个参数:

范围

描述

port

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

reverse

Optional. 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.
mc29 = Motor29(brain.three_wire_port.a)

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

类方法#

spin()#

The spin(direction, velocity, 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 velocity is set by the motor393.motor.set_velocity() command.

单位

Optional. A valid VelocityUnits type. The default is RPM.

**返回:**无。

# Spin the Motor forward at velocity set with set_velocity.
mc29.spin(FORWARD)

停止()#

The stop() method stops the Motor.

**返回:**无。

设置速度()#

The set_velocity() 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.

参数

描述

价值

要设置的速度值。

单位

A valid VelocityUnits type. The default is RPM.

**返回:**无。

设置反转()#

The set_reversed() method sets the Motor direction to be reversed or not.

参数

描述

价值

True to reverse the motor direction. False to maintain the normal direction.

**返回:**无。

# Reverse the Motor's direction.
mc29.set_reversed(True)