SpaceNavigator controlled Lego Mindstorms NXT

It’s my second year of coaching a First Lego League team. The experience has been fantastic, I’m teaching 4th and 5th grade children about robots and computers, and teaching them to build and program their own robots. This year the kids are going to be learning how to use the new Lego Mindstorms NXT robot; therefore I happen to have an NXT robot in the house. One of the cool features of the NXT is that it can communicate to a Mac (or even another NXT robot) via Bluetooth. So I thought it might be fun to take the 3Dconnexion SpaceNavigator controller device I used in my previous blog post and use it to control an NXT Robot. Here is the result:

SpaceNavigatorNXTPreview.png

Although the SpaceNavigator support six degrees of freedom, I’m only using two (Y axis for forwards/reverse and RZ for turning), that leaves plenty of room for expansion (perhaps hooking up a third motor to another controller axis).

Although the video doesn’t show it too well, the SpaceNavigator does allow for very fine grained control over the robot (as long as the robot has fresh batteries!). The controller is extremely sensitive and with practice the robot can be controlled quite delicately.

Currently only one axis is dominant at a time (that’s actually a preference in the SpaceController System Preferences screen) but it is be possible to control robot steering and speed/direction at the same time. I’ll be trying that out soon.

There doesn’t seem to be much in the way of Mac OS X APIs for controlling NXT via Bluetooth, so I’m putting my code onto my public subversion server and releasing it (like everything else in my public repository) under the BSD License. The code is Leopard only (although all I’m using are some Objective-C 2.0 features, such as properties and the new for loop). The code uses Cocoa bindings/KVC and has a rather simple interface:

robot = [[[CNXTRobot alloc] init] autorelease];
((CNXTMotor *)[robot.ports objectForKey:@"B"]).power = (int)(theMotor1 * 100.0);
((CNXTMotor *)[robot.ports objectForKey:@"C"]).power = (int)(theMotor2 * 100.0);

The sample NXT project relies on my ToxicWarped framework. ToxicWarped was originally created for my Geode project and is designed to help write simple but flexible Object Oriented protocol stacks.

The NXT code is barely a day old, so it is very rough and ready but I’ll be tinkering with the NXT and SpaceNavigator code over the next few weeks (in my spare time) but if anyone has a use for the code and would like to contribute back that would be fantastic.

Update: Couldn’t stand awful Youtube image quality any longer. Videos are now on amazon s3.

This entry was posted in Default and tagged , , , , , , . Bookmark the permalink.
  • jacques
    just found your page, do you if there is a "generic" bluetooth app to remote control the nxt with a mac book? your software works only with space navigator?
  • Yeah I was thinking that too as I was chasing the cat around the living room. Quite an expensive RC car though ;-)
  • Funny… in my day we called that type of robot a “remote-control car”. ;-)
blog comments powered by Disqus