NXT soccer with central image processing and bluetooth com

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

NXT soccer with central image processing and bluetooth com

Postby daniel » Wed Aug 15, 2007 8:55 am

Hi all,

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,
Daniel
daniel
New User
 
Posts: 2
Joined: Wed Aug 15, 2007 8:25 am

Re: NXT soccer with central image processing and bluetooth

Postby roger » Thu Aug 16, 2007 6:12 am

Hi Daniel,
There is an easier way of solving your bluetooth communication problem by using streams.
Look at the BluetoothConnection class in lejos.nxt.comm and the various NXTComm classes in pccoms\lejos\pc\comm\.
You can Use the NXTCommFactory to produce a NXTComm object for you operating system, which can then give you the InputStream and OutputStream you need on the PC side, just as the BlueToothConnection does on the NXT.
Good luck with you project - looks very interesting.
Roger
roger
Moderator
 
Posts: 359
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Postby CoBB » Thu Aug 16, 2007 6:42 am

roger wrote:There is an easier way of solving your bluetooth communication problem by using streams.
Look at the BluetoothConnection class in lejos.nxt.comm and the various NXTComm classes in pccoms\lejos\pc\comm\.
You can Use the NXTCommFactory to produce a NXTComm object for you operating system, which can then give you the InputStream and OutputStream you need on the PC side, just as the BlueToothConnection does on the NXT.

From what I experienced, I can really recommend using the low-level btSend and btReceive methods for fast communication. If you want to send data from the brick to the PC, definitely avoid streams, because each byte is sent in a different packet. They are okay in the other direction, but still seem to be a bit overkill for just a few numbers.
User avatar
CoBB
Novice
 
Posts: 73
Joined: Tue Apr 24, 2007 12:24 pm

Postby bbagnall » Mon Sep 03, 2007 4:36 pm

Hi Daniel,

The Impressario link gives me "Object not Found". Is that site down? I'm very interested in the processing capabilities of this as it might help us expand the functions of the icommand.vision tools.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Postby daniel » Thu Sep 20, 2007 8:29 am

Hi Brian,

it seems they have redesigned ther site and taken the tool off. Anyway the image processing library used is called lti-lib and can be found on sourceforge:
http://ltilib.sourceforge.net/doc/homepage/index.shtml

It's a C++ library for image processing so I'm not sure whether it's helpful for icommand but you might want to give it a try.

Daniel
daniel
New User
 
Posts: 2
Joined: Wed Aug 15, 2007 8:25 am

Postby bbagnall » Sat Oct 20, 2007 4:55 pm

How are you planning on interfacing the C++ code with Java?
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Postby Lloyd66 » Tue Dec 02, 2008 3:57 pm

Hi, this topic is a few old, but we've got the same project to do at my university.
First of all, sorry for my english, I'm french :P

We use Icommand and bluetooth connection.
We haven't any bluetooth problem for the moment.

So, to follow the ball, we have divided the image from the webcam in a certain number of regions. They've all got a colorListener which is looking for red color. It seems that the colorListener doesn't react because the colorDetected function is never called, even if we place the ball in front of the camera :(

I thought it was a bug, but even testing the VisionAlarm sample, the colorListener has no reaction...

Can you help us to find out why it's not working?

Thanks
Lloyd66
New User
 
Posts: 1
Joined: Tue Dec 02, 2008 3:39 pm

Postby lawrie » Tue Dec 02, 2008 11:03 pm

I wrote the vision system quite a few years ago for the RCX and Brian Bagnall ported it to iCommand. I have not used it for several years, so my memory of the code is not very good. Try displaying the average color RGB values of the region when the ball is in front of it and comparing it with the color you are trying to detect. Change the color you are trying to detect to the value the camera sees. You can adjust the sensitivity of the color detection using the GUI. How well colors are detected varies a lot with lighting conditions.
lawrie
leJOS Team Member
 
Posts: 921
Joined: Mon Feb 05, 2007 1:27 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff