loading
 
Send variables to NXT in real time - use of mailboxes via USB
Anonymous
14 year
Hi all,

got a question for you guys. For the look of it, it seems that one can make use of mailboxes to receive/send messages via USB not only BT. I´d put my hand in fire that I got it working for a while but suddenly it stopped working and I´m getting unexpected results.

http://www.roborealm.com/forum/index.php?thread_id=2824#2

The doc mentions that this is only possible while using BT to communicate:
http://www.roborealm.com/help/Lego_NXT.php

Can you please lend me a hand with this and tell me if it's possible to do so with USB? Maybe using specific program versions?
Thanks!!
Anonymous 14 year
Also regarding real time communication, which is the best way to perform this sending variable task, using the W/R variable module, integration (with an embedded system?) or making use of mailboxes as mentioned? Any other ideas?

Thanks folks!!
Anonymous from United Kingdom  [99 posts] 14 year
The NXT latency over bluetooth is pretty bad.  (up to 300ms after sleep and varying between 5-50ms there after)  The USB latency is better.  Several folks here have done projects with the NXT using roborealm with good success.  (localization)  They typically give up on the bluetooth.   It is difficult to take advantage of the encoders (useful for doing mapping) when the latency is large and variable  If you want to do a lot more work, you can write a program to reside on the ARM7 in the NXT which will serve as the real time controller for the NXT and then message this through a serial bluetooth connection from with Roborealm.  Your real time controller can be clever about keeping track of the encoder values and only moving the robot exactly how you message it to move. Alternately, take a look at the bluetooth SDK that Lego published.  This is quite barebones and I think roborealm implements the most critical bits.   I haven't checked it in a few years, but the functionality might be there already.

have fun,
mmason
Anonymous 14 year
Thanks for the answer mmason!!

That´s what I thought also, the higher BT latency would be an issue in real time apps. Then I suppose I should go with USB. Whenever possible because it wasn't very clear for me after reading these excerpts here:

http://www.roborealm.com/help/Lego_NXT.php

"Please note that messages will NOT be sent when connected via USB; messages are only sent when connected via Bluetooth."

OR

Example 2

"You can use this to test if your NXT is correctly receiving numbers from RoboRealm. Note that this robofile uses the USB connection which should be the same if you connect your NXT via USB. This also eliminates any Bluetooth connection issues. Also note that mail box #1 is used."

Which one is correct then?

Anyway when trying to read messages from specific mailboxes it looks like they were empty and not sending anything.

Besides when I try to connect via BT, this message is shown:
Could not initializate on port COMX - Bluetooth communications port

Any clue why this can be?

Appreciate your commentaries...
Anonymous 14 year
which data type is the one sent via mailboxes? int, string...?
Anonymous 14 year
control of the servomotors in the NXT module is working fine for me. variables are then supposed to be sent correctly making use of the USB connection, am I right?
Anonymous 14 year
perhaps this helps also, i'm using program versions 1.8.23.25 (Dec 03, 2008) & 2.0.2.2 (Jan 12, 2009) for my tests.
Anonymous 14 year
I've got the feeling that I'm almost there!! Just need to be sure that mailboxes can be used to pass the variables when connected via USB. If there is a particular version of the program that got any issues dealing with this corrected plz let me know to use it straight away.


Please help!!!
Thanks ;)
Jim from United Kingdom  [12 posts] 14 year
I did get variables working over USB with my NXT a while back - All variables seem to get passed as strings (except frame count) regardless what you choose in the dropdown which is awkward to handle on the NXT using standard Lego firmware - there are a couple of custom blocks on NXTasy that will do text to number conversions, but you'll probably want to cast the variable to an integer in roborealm using vbscript before sending it to the brick.
I ended up going a different route - installing Lejos java firmware on the nxt, using roborealm API and a little bit of java to get data to the nxt brick - the reason was i just got sick of NXT-G's terrible handling of long strings and numbers, and also responsiveness - since moving over to Lejos bluetooth is much more snappy. It also gets rid of the mailbox restrictions, but means porting everything from NXT-G to java...
Anonymous 14 year
Hi Jim,

Thanks for your contribution. I finally managed to cope with the sending of variables. It works most of the time, though the process gets stuck every now and then.

This now promises! I´m getting forward more quickly now. Again, great work guys!
Anonymous 14 year
Note that an update was made to this module that would respect the type on sending the variable value. In the previous version the type was only for understanding how to read a value from the mailbox. The fix will now also send the value given that particular type.

This may or may not help your situation.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index