传动系统#
介绍#
传动系统控制机器人的运动,使其能够精确地前进、转弯和停止。
以下是所有方法的列表:
动作——移动和转动机器人。
drive – 无限期地沿指定方向移动传动系统。
drive_for – 将传动系统移动一段设定的距离。
drive_until – 移动传动系统,直到满足条件。
turn – 无限期地向左或向右转动传动系统。
turn_for – 将传动系统转动一段设定的距离。
turn_to_heading – 将传动系统转向指定航向。
turn_to_rotation – 将传动系统转到指定的旋转角度。
stop – 以可配置的行为停止传动系统。
变异器——设置默认移动和转动速度。
set_drive_velocity – 设置传动系统的默认移动速度。
set_turn_velocity – 设置动力传动系统的转弯移动速度。
set_stopping – 设置停止行为(制动、滑行或保持)。
set_timeout – 限制传动系统功能在运动受阻时等待的时间。
set_heading – 将动力传动系统的航向设置为特定值。
set_rotation – 将传动系统的旋转设置为特定值。
Getters – 返回机器人状态和位置。
get_heading – 返回动力传动系统的当前航向。
get_rotation – 返回传动系统的当前旋转。
get_velocity – 返回传动系统的当前速度。
get_yaw – 返回机器人的偏航角(以度为单位)。
get_roll – 返回机器人的滚转角度(以度为单位)。
get_pitch – 返回机器人的俯仰角(以度为单位)。
get_crashed – 返回机器人是否已崩溃。
is_stopped – 返回传动系统当前是否未移动。
行动#
drive#
drive
moves the drivetrain in a specified direction indefinitely.
Usage:
drivetrain.drive(direction)
参数 |
描述 |
---|---|
|
The direction in which to drive:
|
def main():
# Drive forward then stop
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop()
# Start threads — Do not delete
start_thread(main)
drive_for#
drive_for
moves the drivetrain in a specified direction for a set distance.
Usage:
drivetrain.drive_for(direction, distance, units, wait)
参数 |
描述 |
---|---|
|
The direction in which to drive:
|
|
动力传动系统移动的距离,以浮点数或整数表示。 |
|
The unit that represents the distance:
|
|
Optional.
|
# Example coming soon
drive_until#
drive_until
moves the drivetrain forward until a certain condition is met.
Usage:
drivetrain.drive_until(condition, wait)
参数 |
描述 |
---|---|
|
停止动力传动系统
|
|
Optional.
|
# Example coming soon
turn#
turn
turns the drivetrain left or right indefinitely.
Usage:
drivetrain.turn(direction)
参数 |
描述 |
---|---|
|
The direction in which to turn:
|
# Example coming soon
turn_for#
turn_for
turns the drivetrain left or right for a specified angle or rotations.
Usage:
drivetrain.turn_for(direction, angle, wait)
参数 |
描述 |
---|---|
|
The direction in which to turn:
|
|
传动系统转动的度数,以浮点数或整数表示。 |
|
Optional.
|
# Example coming soon
turn_to_heading#
turn_to_heading
turns a drivetrain to a specified heading.
Usage:
drivetrain.turn_to_heading(angle, wait)
参数 |
描述 |
---|---|
|
转动传动系统的方向,以浮点数或整数度为单位。 |
|
Optional.
|
# Example coming soon
turn_to_rotation#
turn_to_rotation
turns a drivetrain to a specified rotation.
Usage:
drivetrain.turn_to_rotation(angle, wait)
参数 |
描述 |
---|---|
|
以浮点数或整数度数表示的旋转传动系统朝向。 |
|
Optional.
|
# Example coming soon
stop#
stop
stops a drivetrain.
Usage:
drivetrain.stop()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
修改器#
set_drive_velocity#
set_drive_velocity
sets the default moving velocity for a drivetrain. This velocity setting will be used for subsequent calls to any drivetrain functions.
Usage:
drivetrain.set_drive_velocity(velocity)
参数 |
描述 |
---|---|
|
传动系统移动的速度,以浮点数或整数表示,范围从 0% 到 100%。 |
# Example coming soon
set_turn_velocity#
set_turn_velocity
sets the default turning velocity for a drivetrain. This velocity setting will be used for subsequent calls to any drivetrain functions.
Usage:
drivetrain.set_turn_velocity(velocity)
参数 |
描述 |
---|---|
|
传动系统转动的速度,以浮点数或整数表示,范围从 0% 到 100%。 |
# Example coming soon
set_stopping#
set_stopping
sets the stopping mode for a drivetrain.
Usage:
drivetrain.set_stopping(brake)
参数 |
描述 |
---|---|
|
How the drivetrain will stop:
|
# Example coming soon
set_timeout#
set_timeout
sets a time limit for how long a drivetrain function will wait to reach its target. If the drivetrain cannot complete the movement within the set time, it will stop automatically and continue with the next function.
**注意:**传动系统的时间限制用于防止未达到目标位置的传动系统功能停止项目其余部分的执行。
Usage:
drivetrain.set_timeout(value, units)
参数 |
描述 |
---|---|
|
运动功能在停止并移动到下一个功能之前运行的最大秒数(整数或浮点数)。 |
|
可选。表示时间的单位:
|
# Example coming soon
set_heading#
set_heading
sets the heading of the drivetrain to a specified value.
Usage:
drivetrain.set_heading(value)
参数 |
描述 |
---|---|
|
新航向使用的度值。 |
# Example coming soon
set_rotation#
set_rotation
sets the rotation of the drivetrain to a specified value.
Usage:
drivetrain.set_rotation(value)
参数 |
描述 |
---|---|
|
用于新旋转的度数值。 |
# Example coming soon
吸气剂#
get_heading#
get_heading
returns the current heading of the drivetrain as a float in degrees.
Usage:
drivetrain.get_heading()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
get_rotation#
get_rotation
returns the current rotation of the Inertial Sensor in degrees.
Usage:
drivetrain.get_rotation()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
get_velocity#
get_velocity
returns the current velocity of the drivetrain as a float in percent.
Usage:
drivetrain.get_velocity()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
get_yaw#
get_yaw
returns the current yaw of the robot as a float in degrees.
Usage:
drivetrain.get_yaw()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
get_roll#
get_roll
returns the current roll of the robot as a float in degrees.
Usage:
drivetrain.get_roll()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
get_pitch#
get_pitch
returns the current pitch of the robot as a float in degrees.
Usage:
drivetrain.get_pitch()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
get_crashed#
get_crashed
returns a Boolean indicating whether or not the robot has crashed.
True
– The robot has crashed.False
– The robot has not crashed.
Usage:
drivetrain.get_crashed()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon
is_stopped#
is_stopped
returns a Boolean indicating whether a drivetrain is not currently moving.
True
– The drivetrain is stopped.False
– The drivetrain is moving.
Usage:
drivetrain.is_stopped()
参数 |
描述 |
---|---|
该方法没有参数。 |
# Example coming soon