汽车集团#
初始化 MotorGroup 类#
使用以下构造函数创建 EXP MotorGroup 对象:
MotorGroup(motor1, motor2, …)
您可以创建具有任意数量电机的 MotorGroup。
# Create 2 Motors, motor_1 and motor_2 in
# Ports 1 and 2 respectively.
motor_1 = Motor(Ports.PORT1)
motor_2 = Motor(Ports.PORT2)
# Using the two previously created Motors, create a
# MotorGroup named motor_group_1.
motor_group_1 = MotorGroup(motor_1, motor_2)
This motor_group_1
object will be used in all subsequent examples throughout this API documentation when referring to MotorGroup class methods.
类方法#
spin()#
The spin(direction, velocity, units)
method is used to spin all Motors in a MotorGroup in the specified direction until a spin or stop command is used, or the project is stopped.
这是一个非等待功能,允许下一个命令无延迟运行。
参数 |
描述 |
---|---|
方向 |
有效的 DirectionType。 |
速度 |
Optional. The velocity at which the Motors in the MotorGroup will spin. The default velocity set by the |
单位 |
Optional. A valid VelocityUnit or |
**返回:**无。
# Spin all Motors in motor_group_1 forward.
motor_group_1.spin(FORWARD)
spin_to_position()#
The spin_to_position(rotation, units, velocity, units_v, wait)
method is used to spin all Motors in a MotorGroup to an absolute position using the provided arguments.
This function can be a waiting or non-waiting command depending on if the wait
parameter is set to True
.
参数 |
描述 |
---|---|
旋转 |
电机组中电机的旋转位置。 |
单位 |
Optional. A valid RotationUnit. The default is |
速度 |
Optional. The velocity with which the Motors in a MotorGroup will spin. The default velocity set by the |
单位 |
Optional. A valid VelocityUnit or |
等待 |
Optional. Determines whether the command will block subsequent commands ( |
**返回:**无。
# Spin the Motors in motor_group_1 to the position 90
# degrees at 100 RPM.
motor_group_1.spin_to_position(90, DEGREES, 100, RPM)
spin_for()#
The spin_for(direction, value, units, velocity, units_v, wait)
method is used to spin all Motors in a MotorGroup for a specific duration, rotations, or until a specific encoder value is reached. The position is relative to the current position of the Motors in the MotorGroup.
This can be a waiting or non-waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
方向 |
有效的 DirectionType。 |
价值 |
MotorGroup 中电机旋转的值。 |
单位 |
Optional. A valid RotationUnit. The default is |
速度 |
Optional. The velocity with which the Motors in a MotorGroup will spin. The default velocity set by the |
单位 |
Optional. A valid VelocityUnit or |
等待 |
Optional. Determines whether the command will block subsequent commands ( |
**返回:**无。
# Spin the Motors in motor_group_1 forward for 10 turns
# at 100% velocity.
motor_group_1.spin_for(FORWARD, 10, TURNS, 100, PERCENT)
stop()#
The stop(mode)
method is used to stop all Motors in a MotorGroup, setting them to 0 velocity and configuring the current stopping mode.
参数 |
描述 |
---|---|
模式 |
Optional. A valid BrakeType. The default is |
**返回:**无。
# Spin all Motors in motor_group_1 forward for 2.5 seconds.
motor_group_1.spin(FORWARD)
wait(2.5, SECONDS)
# Stop all Motos in motor_group_1 using the HOLD brake type.
motor_group_1.stop(HOLD)
count()#
The count()
method returns the number of Motors in the MotorGroup.
返回: MotorGroup 中的 Motors 数量。
set_velocity()#
The set_velocity(velocity, units)
method is used to set the default velocity for all Motors in a MotorGroup. This velocity setting will be used for subsequent calls to any motion functions if a specific velocity is not provided.
参数 |
描述 |
---|---|
速度 |
为 MotorGroup 中的 Motors 设置的新速度。 |
单位 |
A valid VelocityUnit or |
**返回:**无。
# Spin the Motors in motor_group_1 forward at 75% velocity.
motor_group_1.set_velocity(75, PERCENT)
motor_group_1.spin(FORWARD)
set_stopping()#
The set_stopping(mode)
method is used to set the stopping mode for all Motors in a MotorGroup.
参数 |
描述 |
---|---|
模式 |
有效的 BrakeType。 |
**返回:**无。
reset_position()#
The reset_position()
method resets the position of all Motors in a MotorGroup to 0. The position that is returned by the position()
method will be updated to 0.
**返回:**无。
set_position()#
The set_position(value, units)
method is used to set the position of all Motors in a MotorGroup. The position that is returned by the position()
method will be updated to this new value.
参数 |
描述 |
---|---|
价值 |
为 MotorGroup 中的所有 Motors 设置的新位置。 |
单位 |
有效的 RotationUnit。 |
**返回:**无。
set_timeout()#
The set_timeout(value, units)
method is used to set the timeout for all Motors in a MotorGroup. The position that is returned by the get_timeout()
method will be updated to this new value.
参数 |
描述 |
---|---|
价值 |
为 MotorGroup 中的所有 Motors 设置新的超时时间。 |
单位 |
Optional. A valid TimeUnit. The default is |
**返回:**无。
is_spinning()#
The is_spinning()
method returns the current status of the spin_to_position()
or spin_for()
methods. This function is used when False
has been passed as the wait
parameter in either command.
Returns: True
if any Motor in the MotorGroup is still spinning. False
if the Motors in the MotorGroup have completed the move or a timeout has occurred.
is_done()#
The is_done()
method returns the current status of the spin_to_position()
or spin_for()
method. This function is used when False
has been passed as the wait
parameter in either command.
Returns: True
if any Motor in the MotorGroup is still spinning. False
if the Motors in the MotorGroup have completed the move or a timeout has occurred.
set_max_torque()#
The set_max_torque(value, units)
method is used to set the maximum torque for all Motors in a MotorGroup. The torque can be set as torque units, current units, or a percent of maximum torque.
参数 |
描述 |
---|---|
价值 |
MotorGroup 中所有电机的新最大扭矩。 |
单位 |
A valid TorqueUnit, |
**返回:**无。
direction()#
The direction()
method returns the current direction the first Motor in a MotorGroup is spinning.
**返回:**当前 DirectionType MotorGroup 中第一个电机正在旋转。
position()#
The position(units)
method returns the current position of the first Motor in a MotorGroup.
参数 |
描述 |
---|---|
单位 |
Optional. A valid RotationUnit. The default is |
返回: MotorGroup 中第一个 Motor 的当前位置(以指定的单位表示)。
velocity()#
The velocity(units)
method returns the current velocity of the first Motor in a MotorGroup.
参数 |
描述 |
---|---|
单位 |
Optional. A valid VelocityUnit. The default is |
返回: MotorGroup 中第一个 Motor 的当前速度(以指定单位表示)。
current()#
The current(units)
method returns the total current being used by the Motors in a MotorGroup.
参数 |
描述 |
---|---|
单位 |
Optional. The only valid units for current are |
返回: MotorGroup 中电机以指定单位所消耗的总电流。
power()#
The power(units)
method returns the power the first Motor in a MotorGroup is providing.
参数 |
描述 |
---|---|
单位 |
Optional. The only valid units for power are |
返回: MotorGroup 中第一个 Motor 以指定单位提供的功率。
torque()#
The torque(units)
method returns the torque the first Motor in a MotorGroup is providing.
参数 |
描述 |
---|---|
单位 |
Optional. A valid TorqueUnit. The default is |
返回: MotorGroup 中第一个 Motor 以指定单位提供的扭矩。
efficiency()#
The efficiency(units)
method returns the efficiency of the first Motor in a MotorGroup.
参数 |
描述 |
---|---|
单位 |
Optional. The only valid unit for efficiency is |
返回: MotorGroup 中第一个 Motor 的效率百分比。
temperature()#
The temperature(units)
method returns the temperature of the first Motor in a MotorGroup.
参数 |
描述 |
---|---|
单位 |
Optional. A valid TemperatureUnit. The default is |
返回: MotorGroup 中第一个 Motor 的指定单位的温度。