Code : Robots : Balancing: Modifications and source code

Modifications and new code

We originally set out to create some Mindstorm NXT-based balancing robots based on a design we used for the older Mindstorm RCXes. This didn't work out too well, so we started looking for something better for the NXTs when we came upon Yorihisa Yamamotos NXTWay-GS. The building instructions for the NXTWay-GS are available on the net, and the source code for the robots is distributed with the LEJOS OSEK environment (see references below).

There was one major problem with the original NXTWay-GS system, however: the robots fell over when drivers crashed into objects or tried to run over hills and ramps too rapidly. To get the robots up again, we had to restart both the robot and a program running on a Windows laptop (the NXTGamePad program reads a USB Gamepad and sends control commands to the NXT robot). Since we had multiple robots, we had to run back and forth between the arena and the laptops, checking which robot had crashed to find the corresponding laptop where we needed to kill and restart NXTGamePad. Reconnecting NXTGamePad to the robot required that we clicked through several dialog boxes, adding to the restart time.

The restart time is not a problem in a lab setting, but in a demonstration setting, we want to spend as much time as possible talking to people instead of resetting robots.

New robot controller program running on a Linux laptop is a small control program written in Python that automatically tries to reconnect to a robot if it looses connection (you may have to reset the robot though). The main goal of this controller is to run unattended: the robot can be restarted on the arena without having to go back to the laptop. This allows us to talk to people while restarting the robot rather than running back and forth between the robot and the laptop. runs on a Linux laptop, and allows us to control multiple NXTways from a single laptop using one USB gamepad (playstation-like controller) per robot.

Modified robot code

Even with the new NXTWayController, it would still take up to 20-40 seconds from a robot fell to the point where we could run it again. The main problem was the time spent restarting the robot and waiting for NXTWayController to reconnect to the robot.

To reduce this time, we modified the program running on the Lego Mindstorm robot to allow it to reset without loosing the bluetooth connection to the laptop. This allows us to rescue a fallen robot and get it back on its feet in about 3-5 seconds.

NXTwayController was modified to send a reset command to the robot when a user presses the "start" button on the gamepad. When the robot receives this command, it turns off the motors and waits for 2 seconds before starting to calibrate (which takes 1 second) and run again.

The modified nxtway_gs.c can be used as a drop-in replacement in the NXTWay-GS source code for version 207 of LEJOS OSEK.

We also provide a pre-compiled firmware and program for the NXT for those that don't want to set up a full development environment to play with the robots (see below).

Installation instructions

John Markus Bjørndalen
Last modified: Thu Sep 23 15:01:10 CEST 2010