Drivetrain#

Functions#

drivetrain.drive()#

This is a non-waiting command and allows any subsequent commands to execute without delay.

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.

Parameters

Description

direction

The direction for the Drivetrain to move in: FORWARD or REVERSE.

Returns: None.

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.

Parameters

Description

direction

The direction for the Drivetrain to move in: FORWARD or REVERSE.

distance

The value for the Drivetrain to move.

units

The units that the distance will use: MM (Millimeters) or INCHES.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

Returns: None.

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.

Parameters

Description

object

The object that the VR Rover will drive to: BASE, ENEMY, or MINERALS.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

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.

Returns: None.

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.

Parameters

Description

object

The object that the VR Rover will turn and drive to: BASE, ENEMY, or MINERALS.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

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.

Returns: None.

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.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

direction

The direction for the Drivetrain to turn to: RIGHT or LEFT.

Returns: None.

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) command is used to turn the Drivetrain for a given angle.

This is can be a non-waiting or waiting command depending on if the wait parameter is used.

Parameters

Description

direction

The direction for the Drivetrain to turn towards: LEFT or RIGHT.

angle

The angle for the Drivetrain to turn by.

units

The unit for the Drivetrain, DEGREES.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

Returns: None.

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.

Parameters

Description

object

The object that the VR Rover will turn to: BASE, ENEMY, or MINERALS.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

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.

Returns: None.

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.

Parameters

Description

angle

The heading(angle) for the Drivetrain to turn to.

units

The unit for the Drivetrain, DEGREES.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

Returns: None.

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.

Parameters

Description

angle

The heading(angle) for the Drivetrain to turn to.

units

The unit for the Drivetrain, DEGREES.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

Returns: None.

def main():
    # Turn to 180 degrees.
    drivetrain.turn_to_rotation(180, DEGREES)

drivetrain.stop()#

The drivetrain.stop() command is used to stop the Drivetrain.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: None.

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.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

velocity

The Drivetrain velocity, from 0 to 100%.

units

The unit for the Drivetrain’s velocity, PERCENT.

Returns: None.

By default, the Drivetrain velocity is set to 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.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

velocity

The Drivetrain velocity, from 0 to 100%.

units

The unit for the Drivetrain’s turn velocity, PERCENT.

Returns: None.

By default, the Drivetrain’s turn velocity is set to 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.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

angle

The value that the Drivetrain’s Gyro heading will be set to.

units

The unit for the Drivetrain, DEGREES.

Returns: None.

In this example, the Drivetrain should not move because the heading is already 90 degrees.

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.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

angle

The integer that the Drivetrain’s angle of rotation heading will be set to.

units

The angle of rotation’s unit, DEGREES.

Returns: None.

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)