传动系统#
功能#
drivetrain.drive()#
这是一个非等待命令,允许任何后续命令无延迟地执行。
The drivetrain.drive(direction)
command is used to move the Drivetrain in the specified direction forever, until a new drivetrain command is used, or the project is stopped.
参数 |
描述 |
---|---|
方向 |
The direction for the Drivetrain to move in: |
**返回:**无。
def main():
# Drive forward.
drivetrain.drive(FORWARD)
# Wait 2 seconds.
wait(2, SECONDS)
# Stop the Drivetrain.
drivetrain.stop()
drivetrain.drive_for()#
The drivetrain.drive_for(direction, distance, units, wait)
command is used to move the Drivetrain for a given distance.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
方向 |
The direction for the Drivetrain to move in: |
距离 |
传动系统移动的值。 |
单位 |
The units that the distance will use: |
等待 |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
**返回:**无。
def main():
# Move the Drivetrain forward for 500 MM.
drivetrain.drive_for(FORWARD, 500, MM)
drivetrain.drive_to()#
The drivetrain.drive_to(object, wait)
command is used to drive the VR Rover the distance between it and a specified object.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
目的 |
The object that the VR Rover will drive to: |
等待 |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.drive_to()
command is called, the robot will not drive.
However, when the BASE
parameter is used, the robot will drive forward the amount of distance between it and the base.
**返回:**无。
def main():
# Drive the VR Rover to the nearest mineral.
drivetrain.drive_to(MINERALS)
drivetrain.go_to()#
The drivetrain.go_to(object, wait)
command is used to turn and drive the VR Rover to a specified object.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
目的 |
The object that the VR Rover will turn and drive to: |
等待 |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.go_to()
command is called, the robot will not drive.
However, when the BASE
parameter is used, the robot will always turn towards the base and then drive towards it.
**返回:**无。
def main():
# Turn the VR Rover towards the base and drive to it.
drivetrain.go_to(BASE)
drivetrain.turn()#
The drivetrain.turn(direction)
command is used to turn the Drivetrain right or left forever, until a new drivetrain command is used, or the project is stopped.
这是一个非等待命令,允许任何后续命令无延迟地执行。
参数 |
描述 |
---|---|
方向 |
The direction for the Drivetrain to turn to: |
**返回:**无。
def main():
# Turn right.
drivetrain.turn(RIGHT)
# Wait 2 seconds.
wait(2, SECONDS)
# Stop the Drivetrain.
drivetrain.stop()
drivetrain.turn_for()#
The drivetrain.turn_for(direction, angle, units, wait)
turns the drivetrain left or right for a specified angle or rotations.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
方向 |
The direction for the Drivetrain to turn towards: |
角度 |
传动系统转动的角度。 |
单位 |
The unit for the Drivetrain, |
等待 |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
**返回:**无。
def main():
# Turn the drivetrain to the right for 90 degrees.
drivetrain.turn_for(RIGHT, 90, DEGREES)
drivetrain.turn_to()#
The drivetrain.turn_to(object, wait)
command is used to turn the VR Rover towards a specified object.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
目的 |
The object that the VR Rover will turn to: |
等待 |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.drive_to()
command is called, the robot will not drive.
However, when the BASE
parameter is used, the robot will turn to face the base.
**返回:**无。
def main():
# Turn the VR Rover towards the nearest mineral.
drivetrain.turn_to(MINERALS)
drivetrain.turn_to_heading()#
The drivetrain.turn_to_heading(angle, units, wait)
command is used to turn a Drivetrain to a specific heading(angle) using the built in Gyro sensor.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
角度 |
传动系统转向的方向(角度)。 |
单位 |
The unit for the Drivetrain, |
等待 |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
**返回:**无。
def main():
# Turn towards 90 degrees (East).
drivetrain.turn_to_heading(90, DEGREES)
drivetrain.turn_to_rotation()#
The drivetrain.turn_to_rotation(angle, units, wait)
command is used to turn a Drivetrain to a specific angle of rotation using the built in Gyro sensor.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
参数 |
描述 |
---|---|
角度 |
传动系统转向的方向(角度)。 |
单位 |
The unit for the Drivetrain, |
等待 |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
**返回:**无。
def main():
# Turn to 180 degrees.
drivetrain.turn_to_rotation(180, DEGREES)
drivetrain.stop()#
The drivetrain.stop()
command is used to stop the Drivetrain.
这是一个非等待命令,允许任何后续命令无延迟地执行。
**返回:**无。
def main():
# # Drive the Drivetrain forward.
drivetrain.drive(FORWARD)
# Wait 5 seconds.
wait(5, SECONDS)
# Stop the drivetrain.
drivetrain.stop()
drivetrain.set_drive_velocity()#
The drivetrain.set_drive_velocity(velocity,units)
command is used to set the velocity of the Drivetrain.
这是一个非等待命令,允许任何后续命令无延迟地执行。
参数 |
描述 |
---|---|
速度 |
传动系统速度,从 0 到 100%。 |
单位 |
The unit for the Drivetrain’s velocity, |
**返回:**无。
默认情况下,传动系统速度设置为 50%。
def main():
# Set the Drivetrain's velocity to 100%.
drivetrain.set_drive_velocity(100, PERCENT)
# Drive forward for 200 mm.
drivetrain.drive_for(FORWARD, 200, MM)
drivetrain.set_turn_velocity()#
The drivetrain.set_turn_velocity(VELOCITY,PERCENT)
command is used to set the velocity of the Drivetrain’s turns.
这是一个非等待命令,允许任何后续命令无延迟地执行。
参数 |
描述 |
---|---|
速度 |
传动系统速度,从 0 到 100%。 |
单位 |
The unit for the Drivetrain’s turn velocity, |
**返回:**无。
默认情况下,传动系统的转弯速度设置为 50%。
def main():
# Set the Drivetrain's turn velocity to 100%.
drivetrain.set_turn_velocity(100, PERCENT)
# Turn 270 degrees to the left.
drivetrain.turn_for(LEFT, 270, DEGREES)
drivetrain.set_heading()#
The drivetrain.set_heading(angle,units)
command is used to sets the Drivetrain’s Gyro heading value.
这是一个非等待命令,允许任何后续命令无延迟地执行。
参数 |
描述 |
---|---|
角度 |
传动系统的陀螺仪航向将被设置为的值。 |
单位 |
The unit for the Drivetrain, |
**返回:**无。
在这个例子中,传动系统不应该移动,因为航向已经是 90 度。
def main():
# Set the current heading of the VR Robot to 0 degrees.
drivetrain.set_heading(90, DEGREES)
# Turn right to 90 degrees.
drivetrain.turn_to_heading(90, DEGREES)
drivetrain.set_rotation()#
The drivetrain.set_rotation(angle, units)
command is used to sets the Drivetrain’s angle of rotation.
这是一个非等待命令,允许任何后续命令无延迟地执行。
参数 |
描述 |
---|---|
角度 |
传动系统的旋转角度将被设置为的整数。 |
单位 |
The angle of rotation’s unit, |
**返回:**无。
def main():
# Set the Drivetrain's angle of rotation to 600 degrees.
drivetrain.set_rotation(600, DEGREES)
# Turn to 0 degrees.
drivetrain.turn_to_rotation(0, DEGREES)