Lego Mindstorms NXT

This driver implements partial interaction with a USB-connected Lego Mindstorms NXT brick.
Motors are implemented.
Sensors are unimplemented.

Compile-time dependencies
  • libusb-1.0 or newer (www.libusb.org)
Provides
  • interface_position1d
    • One per each of the A, B, C motors
    • These can be aggregated in a position2d using, e.g., differential
    • Velocity commands are accepted. Position commands are not.
  • interface_power
    • Battery level of the brick.
Configuration file options
  • max_power (tuple of float [%] default: [100 100 100])
    • Power applied when maximum vel is requested for each motor.
  • max_speed (tuple of float [length/s] default: [0.5 0.5 0.5])
    • Speed that each motor provides at max_power (must be calibrated/measured somehow depending on the LEGO model built).
  • odom_rate (tuple of float default [0.0005 0.0005 0.0005])
    • Multiplier for the tachometer in the lego motor. tacho_count x odom_rate = real_distance (must be calibrated also).
    • Default is somewhat close to the standard small wheels with direct motor drive.
  • period (float [s] default 0.05)
    • Seconds between reads of motor encoders. Since this requires polling and affects CPU use, each app can set an adequate timing.
    • Note that a polling roundtrip via USB takes (empirically measured) around 2ms per motor.
Example
# Standard configured brick with B and C motors in use

unit_length "m"
unit_angle  "radians"

# The NXT driver
driver
(
  name "nxt"
  provides [ "B:::position1d:0" "C:::position1d:1" "power:0" ]

  max_power [100 100 100] # 100% power is to be used
  max_speed [0.5 0.5 0.5] # in order to achieve 0.5 m/s linearly
  odom_rate [0.1 0.1 0.1] # multiplier for odometry

  period 0.05
)

# The differential driver that provides simplified position2d management
driver
(
  name "differential"
  requires [ "left:::position1d:0" "right:::position1d:1" ]
  provides [ "position2d:0" ]

  axis_length 0.25
)
Author
Alejandro R. Mosteo