I am thinking about starting a project involving controlling the movement of a mindstorms robot depending on some input from a Kinect device; however the robot will require at least 6 motors. I have access to 2 NXT sets* (provided by university) - is it possible to control both bricks using either one (or two) bluetooth dongles? I've read through the Bluetooth SDK docs but they only mention that a master NXT can control up to 3 slave NXTs. Reading through the protocol spec I see no reason why another NXT could not be controlled by just sending it "direct control messages". Can it be done in a simplistic way without having to make my own low level bluetooth api?
4 Answers
Yes, this is definitely possible! You can connect up to 7 different NXT devices from one computer and one Bluetooth dongle (theoretical limit). I have tested this with the RWTH - Mindstorms NXT Toolbox for MATLAB) successfully with 5 NXTs on Linux and with at least 2 NXTs on Windows.
In real life, it depends on your Bluetooth hardware. Your Bluetooth stack or driver software should provide several serial COM-ports. You can then connect each virtual serial port to a seperate NXT device, and access them via those different serial ports.
If you go the direct way via the official LEGO NXT Bluetooth SDK you mentioned, you can retrieve different handles to multiple NXTs.
Oh, and for the record: You can also connect multiple NXTs via USB, and you can also mix and match with Blueooth.
Regards, Linus
-
1To back this up, I've also controlled 3 NXTs simultaneously from Windows with a single Bluetooth dongle, using a LabVIEW program with the LabVIEW NXT Toolkit.– nhinkleCommented Apr 3, 2012 at 3:47
The RWTH documentation about initiating connections has a sub-chapter called "Using multiple NXTs" which can be found here: PC to NXT Communication - Using multiple NXTs
The C++ communication from norgesgade14.dk claims to support: "Open and close connections with multiple NXT units" on its overview page.
So it should be possible to do this, though I can't confirm since I only have a single NXT. I suspect that you only need one dongle though.
Those answers above do all work. If I were looking for fast speed, I would probably use USB, however if you robot moves around, then bluetooth is probably the best solution (the slowest thing in the loop is the NXT anyhow :P). If your Bluetooth hardware on your computer supports multiple devices, then simply address each associated COM port per device.
After reading through the bluetooth direct command PDF provided by LEGO however, it's written fairly poorly and leaves the user asking a lot of questions or messing around with certain commands for a long time. There is a great writeup here that goes over the commands in an easier, more understandable, and thorough way: http://www.robotappstore.com/Knowledge-Base/Programming-LEGO-NXT-Mindstorms/92.html I recommend checking it out as it goes over a whole host of command types.
Hope this helps!
I've used RWTH and vouch for its effectiveness. However, if you don't have MATLAB, don't know how to use MATLAB, or just want an open-source solution, you can use the Perl module for controlling the NXT over bluetooth.
http://search.cpan.org/~collins/LEGO-NXT-2.00-1/lib/LEGO/NXT.pm
It's quite simple to use and provides very thorough control. Best of luck!