Drivetrain#

Introduction#

The drivetrain includes wheels and motors that control how the robot drives and turns. Drivetrains can be configured with motors or motor groups.

If the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor, it can make more precise forward, reverse, and turning movements by tracking the sensor’s heading and rotation.

There are many ways to code the drivetrain. Below is a list of all Drivetrain blocks:

Actions — Move and turn the robot.

  • drive — Moves the robot forward or reverse forever.

  • drive for — Moves the robot forward or reverse for a specific distance.

  • turn — Turns the robot left or right forever.

  • turn for — Turns the robot left or right for a specific number of degrees.

  • turn to heading — Turns the robot to face a specific heading.

  • turn to rotation — Turns the robot to a specific rotation.

  • stop driving — Stops the robot’s movement.

Settings — Adjust drivetrain settings.

Values — Check movement status.

Actions#

drive#

The drive stack block moves the robot forward or reverse forever. The robot will continue to move until it is given another action, like turning or stopping.

  drive [forward v]

Parameters

Description

direction

The direction the robot moves: forward or reverse.

Example

  when started
  [Drive forward, then stop.]
  drive [forward v]    
  wait [2] seconds
  stop driving

drive for#

The drive for stack block moves the robot forward or reverse for a specific distance. The project will wait until the robot is done moving before the next block in the stack runs.

  drive [forward v] for [200] [mm v] ▶

Parameters

Description

direction

The direction the robot moves: forward or reverse.

distance

The distance the robot drives. This can be an integer or a decimal.

unit

The distance unit: mm (millimeters) or inches

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

Example

  when started
  [Drive forwards and backwards.]
  drive [forward v] for [200] [mm v] ▶
  wait [1] seconds
  drive [reverse v] for [200] [mm v] ▶

turn#

The turn stack block turns the robot left or right forever. The robot will continue to turn until it is given another action, like driving or stopping.

  turn [right v]

Parameters

Description

direction

The direction the robot turns: left or right.

Example

  when started
  [Turn right, then stop.]
  turn [right v]
  wait [2] seconds    
  stop driving

turn for#

The turn for stack block turns the robot left or right for a specific number of degrees. The turn is relative to the current position of the robot. The project will wait until the robot is done turning before the next block in the stack runs.

  turn [right v] for [90] degrees ▶

Parameters

Description

direction

The direction the robot turns: left or right.

angle

The number of degrees the robot turns. This can be an integer or a decimal.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

Example

  when started
  [Turn left, then turn around to the right.]
  turn [left v] for [90] degrees ▶
  turn [right v] for [180] degrees ▶

turn to heading#

A heading is the direction the robot is facing, measured in degrees. The turn to heading stack block turns the robot to face a specific heading from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.

The starting heading is 0 degrees.

The project will wait until the robot is done turning before the next block in the stack runs.

Note: This block is only available if the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor in the Devices window.

  turn to heading (90) degrees ▶

Parameters

Description

heading

The heading the robot should face, from -359 to 359 degrees.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

Example

  when started
  [Turn to face the cardinal directions.]
  turn to heading [90] degrees ▶
  wait [2] seconds
  turn to heading [180] degrees ▶
  wait [2] seconds
  turn to heading [270] degrees ▶
  wait [2] seconds
  turn to heading [0] degrees ▶
  wait [2] seconds

turn to rotation#

The turn to rotation stack block turns the robot to a specific rotation.

Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. Rotation can also be set using the set drive rotation block.

Rotation values are absolute. This means the direction of the turn depends on the robot’s current rotation. Turning right increases the rotation, and turning left decreases the rotation.

For example, if the robot starts at 0 degrees and you turn to a rotation of 720 degrees, it will turn right twice. If you then turn to a rotation of 360 degrees, it will turn left once, because 360 is less than 720.

The project will wait until the robot is done turning before the next block in the stack runs.

Note: This block is only available if the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor in the Devices window.

  turn to rotation [90] degrees ▶

Parameters

Description

rotation

The rotation value, in degrees, that the robot will turn to. This can be an integer or a decimal.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

Example

  when started
  [Turn left, then spin in a circle clockwise and face right.]
  turn to rotation [-90] degrees ▶
  wait [2] seconds
  turn to rotation [450] degrees ▶

stop driving#

The stop driving stack block stops the robot’s movement.

  stop driving

Parameters

Description

This block has no parameters.

Example

  when started
  [Drive forward, then stop.]
  drive [forward v]
  wait [4] seconds
  stop driving

Settings#

set drive velocity#

The set drive velocity stack block tells the robot how fast to drive. A higher percentage makes the robot drive faster and a lower percentage makes the robot drive slower. For RPM, the limit is changed by the gear ratio of the drivetrain.

Every project begins with the robot driving at 50% velocity by default.

Note: A higher velocity makes the robot drive faster, but it may be less precise. A lower velocity makes the robot drive slower, but it can be more precise.

  set drive velocity to (50) [% v]

Parameters

Description

velocity

The velocity to drive with from 0% to 100% when using velocityUnits::pct, or from 0 to 600 rpm for rpm.

unit

The velocity unit:

  • % – percent
  • rpm – revolutions per minute

Example

  when started
  [Drive forward at the default velocity.]
  drive [forward v] for (100) [mm v] ▶
  wait (1) seconds
  [Move slower.]
  set drive velocity to (20) [% v]
  drive [forward v] for (100) [mm v] ▶
  wait (1) seconds
  [Move faster.]
  set drive velocity to (100) [% v]
  drive [forward v] for (100) [mm v] ▶
  wait (1) seconds

set turn velocity#

The set turn velocity stack block tells the robot how fast to turn. A higher percentage makes the robot turn faster and a lower percentage makes the robot turn slower. For RPM, the limit is changed by the gear ratio of the drivetrain.

Every project begins with the robot turning at 50% velocity by default.

Note: A higher velocity makes the robot turn faster, but it may be less precise. A lower velocity makes the robot turn slower, but it can be more precise.

  set turn velocity to (50) [% v]

Parameters

Description

velocity

The velocity to turn with from 0% to 100% when using velocityUnits::pct, or from 0 to 120 rpm for rpm.

unit

The velocity unit:

  • % – percent
  • rpm – revolutions per minute

Example

  when started
  [Turn at default velocity.]
  turn [right v] for (100) degrees ▶
  wait (1) seconds
  [Turn slower.]
  set turn velocity to (20) [% v]
  turn [right v] for (100) degrees ▶
  wait (1) seconds
  [Turn faster.]
  set turn velocity to (100) [% v]
  turn [right v] for (100) degrees ▶
  wait (1) seconds

set drive stopping#

The set drive stopping stack block sets how the robot will stop moving: by braking, coasting, or holding.

  set drive stopping to [brake v]

Parameters

Description

stopping behavior

How the robot will stop:

  • brake — Stops immediately.
  • coast — Slows to a stop.
  • hold — Stops immediately and holds the wheels’ position.

If this block is not used, the robot will use brake when stopping.

set drive timeout#

The set drive timeout stack block sets how many seconds the robot will try to finish a movement. If the robot cannot finish in that time it will stop trying and move on to the next block in the stack. This keeps the robot from getting stuck on a movement.

  set drive timeout to (1) seconds

Parameters

Description

time

The number of seconds the robot can try to finish a movement. This can be a whole number or a decimal.

set drive heading#

A heading is the direction the robot is facing, measured in degrees. The set drive heading stack block changes the robot’s current heading to a new heading value.

For example, if the robot has turned to face right, setting the heading to 0 degrees makes that right-facing position the new 0 degrees. Then the robot can turn to other positions based on that new heading.

Note: This block is only available if the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor in the Devices window.

  set drive heading to (0) degrees

Parameters

Description

heading

The heading value, in degrees, to set for the robot.

Example

  when started
  [Turn to the left.]
  set drive heading to (90) degrees
  turn to heading (0) degrees ▶

set drive rotation#

Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The set drive rotation stack block changes the robot’s current rotation to a new value.

For example, if the robot has made two full turns to the right, its rotation value will be 720 degrees. Setting the rotation to 0 degrees will reset that rotation from 720 to 0 degrees. Then the robot can turn to rotations based on that new value.

Note: This block is only available if the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor in the Devices window.

  set drive rotation to (0) degrees

Parameters

Description

rotation

The rotation value, in degrees, to set for the robot. This can be an integer or a decimal.

Example

  when started
  [Spin counterclockwise two times.]
  set drive rotation to (720) degrees
  turn to rotation (0) degrees ▶

Values#

calibrate drivetrain#

The calibrate drivetrain stack block calibrates the drivetrain’s configured Inertial, GPS, or Gyro Sensor. All subsequent blocks will wait for the calibration to complete before executing. Calibration is an internal procedure that measures and compensates for sensor noise and drift over a specified period. During this time, the sensor must remain completely still (i.e., on a stable surface without any external movement). Movement during calibration will produce inaccurate results.

Note: This block is only available if the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor in the Devices window.

    calibrate drivetrain

Parameters

Description

This block has no parameters.

drive is done#

The drive is done Boolean block reports whether the robot is finished moving. This can be used to control the timing of other behaviors based on the robot’s movement.

  • True — The robot is finished moving.

  • False — The robot is still moving.

This block works together with drivetrain blocks that have the and don’t wait parameter.

    <drive is done?>

Parameters

Description

This block has no parameters.

drive is moving#

The drive is moving Boolean block reports whether the robot is moving. This can be used to control the timing of other behaviors based on the robot’s movement.

  • True — The robot is moving.

  • False — The robot is not moving.

This block works together with drivetrain blocks that have the and don’t wait parameter.

    <drive is moving?>

Parameters

Description

This block has no parameters.

drive heading#

A heading is the direction the robot is facing, measured in degrees. The drive heading reporter block reports that heading from 0 to 359.99 degrees.

The robot’s starting heading is 0 degrees.

Note: This block is only available if the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor in the Devices window.

    (drive heading in degrees)

Parameters

Description

This block has no parameters.

Example

    when started
    [Display the heading after turning.]
    turn [right v] for (450) degrees ▶
    print (drive heading in degrees) on screen ◀ and set cursor to next row

drive rotation#

Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The drive rotation reporter block reports the robot’s current rotation.

Turning right increases the rotation, and turning left decreases the rotation. For example, making two full turns to the right will report a rotation of 720 degrees.

Note: This block is only available if the drivetrain is configured with an Inertial Sensor, GPS Sensor, or Gyro Sensor in the Devices window.

    (drive rotation in degrees)

Parameters

Description

This block has no parameters.

Example

    when started
    [Display the rotation after turning.]
    turn [right v] for (450) degrees ▶
    print (drive rotation in degrees) on screen ◀ and set cursor to next row

drive velocity#

The drive velocity reporter block reports how fast the robot is driving.

A positive value means the robot is driving forward. A negative value means the robot is driving in reverse.

    (drive velocity in [% v])

Parameters

Description

unit

The velocity unit:

  • %
  • rpm – revolutions per minute

drive current#

The drive current reporter block reports how much electrical current the drivetrain is using, measured in amps (amperes). Current is the amount of electricity flowing through the drivetrain.

A higher current value means the drivetrain is using more electrical current. This can happen when the robot is pushing against an object or trying to move when it is stuck.

This can be used to check if the drivetrain is struggling during a movement. If current stays high, the drivetrain may get warmer or use power less efficiently.

    (drive current amps)

Parameters

Description

This block has no parameters.

drive power#

The drive power reporter block reports how much power the drivetrain is using, measured in watts. Power shows how quickly the drivetrain is using energy.

A higher power value means the drivetrain is using energy faster. This can happen when the robot is pushing against an object or trying to move when it is stuck.

This can be used to compare movements or check if the drivetrain is struggling. If power stays high, the drivetrain may get warmer or use energy less efficiently.

    (drive power in watts)

Parameters

Description

This block has no parameters.

drive torque#

Torque shows how hard the drivetrain can twist, push, or pull while they spin.

The drive torque reporter block reports how much torque the drivetrain is using, measured in inch-pounds (InLb) or Newton-meters (Nm).

A higher torque value means the drivetrain is pushing or pulling harder. This can happen when the robot is pushing against an object or trying to move when it is stuck.

This can be used to check if the drivetrain is struggling or to compare how much push different movements need.

    (drive torque in [InLb v])

Parameters

Description

unit

The torque unit:

  • InLb – inch-pounds
  • Nm – Newton-meters

drive efficiency#

The drive efficiency reporter block reports how efficiently the drivetrain is using power, as a percentage from 0% to 100%.

Efficiency shows how much of the drivetrain’s power is being used for movement. A higher efficiency value means more of the drivetrain’s power is being used to move. A lower efficiency value can happen when the drivetrain is working hard but not moving much, like when the robot is stuck or pushing against an object.

This can be used to compare movements or check if the drivetrain is wasting power instead of using it for movement.

    (drive efficiency in %)

Parameters

Description

This block has no parameters.

drive temperature#

The drive temperature reporter block reports the temperature of the drivetrain as a percentage from 0% to 100%.

Motor temperature shows how warm the drivetrain is. A higher temperature means the motors are getting warmer while they work. The motors should stay below 55°C to keep working at full performance.

If the motors get too hot, they will lower their maximum current to protect themselves. At 70°C, the motors will stop running until they cool down.

This can be used to check if the drivetrain is getting too hot during repeated movements, long runs, or when they are pushing against an object.

    (drive temperature in %)

Parameters

Description

This block has no parameters.