运动#
介绍#
GO 电机可以旋转、保持位置并精确控制速度和扭矩。
For the examples below, the configured motor will be named motor_1
. They will be used in all subsequent examples throughout this API documentation when referring to Motor
class methods.
以下是所有方法的列表:
动作——控制电机的运动。
spin – 使电机无限期地沿指定方向旋转。
spin_for – 使电机旋转指定距离。
spin_to_position – 将电机旋转到绝对位置。
stop – 停止电机。
改变器——改变电机的不同属性。
set_velocity – 设置电机的默认速度。
set_max_torque - 设置电机的最大扭矩。
set_position – 将电机的位置设置为特定值。
set_stopping – 设置停止行为(制动、滑行或保持)。
set_timeout – 限制运动受阻时运动功能在放弃之前等待的时间。
Getters – 从电机返回数据。
位置 – 返回电机的当前位置。
velocity – 返回电机的当前速度。
current – 返回电机正在使用的电流。
is_stopped – 返回电机当前是否未旋转。
is_moving – 返回电机当前是否正在旋转。
行动#
spin#
spin
spins the motor in a specified direction indefinitely.
Usage:
motor_1.spin(direction)
参数 |
描述 |
---|---|
|
The direction in which to spin the motor:
|
# Example coming soon
spin_for#
spin_for
spins the motor in a specified direction for a specific angle.
Usage:
motor_1.spin_for(direction, angle, wait)
参数 |
描述 |
---|---|
|
The direction in which to spin the motor:
|
|
电机旋转的度数,以浮点数或整数表示。 |
|
Optional.
|
# Example coming soon
spin_to_position#
spin_to_position
spins the motor to an absolute position.
Usage:
motor_1.spin_to_position(angle, wait)
参数 |
描述 |
---|---|
|
以浮点数或整数形式指定电机旋转的位置。 |
|
Optional.
|
# Example coming soon
stop#
stop
stops a motor from spinning.
Usage:
motor_1.stop()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
修改器#
set_velocity#
set_velocity
sets the default velocity for a motor. This velocity setting will be used for subsequent calls to any Motor functions.
Usage:
motor_1.set_velocity(velocity)
参数 |
描述 |
---|---|
|
电机旋转的速度(以百分比表示)。 |
# Example coming soon
set_max_torque#
set_max_torque
sets the maximum torque for a motor.
Usage:
motor_1.set_max_torque(value)
参数 |
描述 |
---|---|
|
电机的新最大扭矩,以浮点数或整数表示。 |
# Example coming soon
set_position#
set_position
sets the position of a motor.
Usage:
motor_1.set_position(position)
参数 |
描述 |
---|---|
|
新位置以度为单位的整数。 |
# Example coming soon
set_stopping#
set_stopping
sets the stopping mode for a motor.
Usage:
motor_1.set_stopping(mode)
参数 |
描述 |
---|---|
|
How the motor will stop:
|
set_timeout#
set_timeout
sets a time limit for how long a motor function will wait to reach its target. If the motor cannot complete the movement within the set time, it will stop automatically and continue with the next function.
**注意:**电机的时间限制用于防止未达到目标位置的电机功能停止项目其余部分的执行。
Usage:
motor_1.set_timeout(value, units)
参数 |
描述 |
---|---|
|
运动功能在停止并移动到下一个功能之前运行的最大秒数(整数或浮点数)。 |
|
可选。表示时间的单位:
|
# Example coming soon
吸气剂#
position#
position
returns the current position of a motor as an integer or as a float in degrees.
Usage:
motor_1.position()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
velocity#
velocity
returns the current velocity of a motor as an integer or as a float in percent.
Usage:
motor_1.velocity()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
current#
current
returns the current of the motor in amps.
Usage:
motor_1.current()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
is_stopped#
is_stopped
returns a Boolean indicating whether the motor is stopped.
True
– The motor is stopped.False
– The motor is spinning.
Usage:
motor_1.is_stopped()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
is_moving#
is_moving
returns a Boolean indicating whether the motor is spinning.
True
– The motor is spinning.False
– The motor is stopped.
Usage:
motor_1.is_moving()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon