I'm starting a project that enables two NXT robots programmed using lejos to play soccer against each other. My idea is to capture the whole playing field with one camera and do the digital image processing on a central PC that sends information about the players' and the ball's coordinates to the robots via bluetooth.
While the image processing is pretty straight forward for me (see the excellent tool Impresario
), I've never programmed a bluetooth device before. I've looked through the NXT communication protocol in the Lego Bluetooth Developer Kit
and would appreciate some help with the following question:
What's the easiest way to get the coordinate information which could be encoded in 6 bytes from a PC (master) to two NXTs (slaves) via bluetooth?
Is the direct command "message write" the correct choice on the PC side? If so, would it look like this?:
Byte 0: 0x80 (I don't need a response)
Byte 1: 0x09 (message write)
Byte 2: 0x00 (Inbox number, which one should I choose?)
Byte 3: 0x07 (message size, including null termination?)
Byte 4-9: encoded coordinates
Byte 10: 0x00 (null termination)
How can I read this information on the NXTs? Could I use lejos.nxt.comm.Bluetooth.btReceive?
Thanks in advance,