Native Bluetooth Performance on MAC - Snow Leopard

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Native Bluetooth Performance on MAC - Snow Leopard

Postby nate » Sun Jan 08, 2012 7:05 am

I've got a interesting quandry. First, a little background.

My 13" Macbook runs LeJOS 0.9.0 wonderful. I'm in the process of writing some classes so that I can develop FIRST (http://www.usfirst.org) FTC robots using Tetrix parts in Java vs. RobotC. Ultimately, the idea is that we can emulate the FRC robots using the much less expensive FTC robots. So far, I've been able to write enough infrastructure to emulate simple autonomous programs.

However, the next step is to now emulate teleop, which means I need to be able to control the robot via a joystick. I downloaded the jinput classes, and have it reading a couple of different joysticks (including the same Logitech game controller as used in RobotC). I also finished writing a NXT program that takes the output from a PC program that reads the joystick and sends them to the NXT brick using USB and/or Bluetooth. This works, and is fairly robust (I have a sequence number, and acknowledge all packets, which is overkill, but allows me to easily detect link loss).

However, here is my quandry. When I run LeJOS native on my MAC under USB, I can send multiple packets (~10) per second to the NXT reliably. Unfortunately, using Bluetooth, I get *maybe* 2 packets per second. This is unacceptable since the robot can't respond fast enough to the joystick input. Perhaps this is a hardware issue on OS X, but I don't believe so because of the next issue.

If I startup XP under Parallels 6 and run the same programs, (obviously, running on the exact same hardware), I get close the same speed as the native OS X USB speed (~8 pkts/sec). So, it's obviously not a hardware issue. And, OS/X is obviously capable of sending out the packets fast enough, as they are both using the same bluetooth hardware, just one is doing it through an emulated USB stack via Parallels.

On my MAC I'm using Java6, while on Windows I ended up with Java7. I can't imaging that the JVM would make much, if any difference. Other than that, the class files on OS/X and XP are identical (I'm using a shared folder), and the program on the NXT is the same in both tests. Just to take it out of the picture, I also disabled the code that reads the joysticks, and am sending 'fake' joystick data.

My suspicion is that OS/X Fantom drivers (supplied by National Instruments for Lego) are the issue, but I haven't dug into it yet. (Note, I'm using the latest version 1.1.3 from Lego, which has a date of 1/2010.) Does anyone else have any insight? If it's an issue with the Fantom drivers, is there any recourse to make things better?


Nate
nate
New User
 
Posts: 16
Joined: Sat Oct 29, 2011 11:40 pm

Re: Native Bluetooth Performance on MAC - Snow Leopard

Postby gloomyandy » Sun Jan 08, 2012 3:27 pm

Hi,
leJOS does not use the Fantom driver for Bluetooth communication, so that is not likely to be an issue. We always use the Bluecove library which then talks to the native (Mac or Windows) Bluetooth stack. So it may be that the problem here is with the Mac Bluetooth stack. One possible thing to try here is to avoid waiting for an acknowledgement from the NXT when sending commands. Certainly on the NXT switching from receive to transmit is a relatively expensive operation and perhaps this is also true for the Mac... I think other people have also reported issues with using the Mac Bluetooth stack with the NXT, but using other languages like NXC, so it seems likely this is not a leJOS/Java/Bluecove issue...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4004
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Native Bluetooth Performance on MAC - Snow Leopard

Postby nate » Sun Jan 08, 2012 4:11 pm

gloomyandy wrote:Hi,
leJOS does not use the Fantom driver for Bluetooth communication, so that is not likely to be an issue.


I didn't realize that, thanks for the info!

We always use the Bluecove library which then talks to the native (Mac or Windows) Bluetooth stack. So it may be that the problem here is with the Mac Bluetooth stack. One possible thing to try here is to avoid waiting for an acknowledgement from the NXT when sending commands.


An early version did not include the two-way protocol for every packet, but it didn't seem to make any difference. And, the same protocol works when I'm connecting from virtual Windows.

I think other people have also reported issues with using the Mac Bluetooth stack with the NXT, but using other languages like NXC, so it seems likely this is not a leJOS/Java/Bluecove issue...


Hmm.... I may do a quickie program in NXC to see if I can recreate it natively there as well.

Thanks for the response Andy!


Nate
nate
New User
 
Posts: 16
Joined: Sat Oct 29, 2011 11:40 pm

Re: Native Bluetooth Performance on MAC - Snow Leopard

Postby nate » Sun Jan 08, 2012 5:10 pm

nate wrote:
gloomyandy wrote:I think other people have also reported issues with using the Mac Bluetooth stack with the NXT, but using other languages like NXC, so it seems likely this is not a leJOS/Java/Bluecove issue...


Hmm.... I may do a quickie program in NXC to see if I can recreate it natively there as well.


Darn. I can't see a way to write a program on my MAC using NXC to talk to my NXT over bluetooth... Maybe Perl, but I'm running out of free time this weekend, so it probably won't happen today now.

Do you know of any other way of sending data from my MAC to the NXT using bluetooth (I'm just sending byte streams currently)?


Nate
nate
New User
 
Posts: 16
Joined: Sat Oct 29, 2011 11:40 pm

Re: Native Bluetooth Performance on MAC - Snow Leopard

Postby gloomyandy » Mon Jan 09, 2012 10:27 am

Hi,
You may find this (old) thread of interest...
viewtopic.php?f=6&t=1331&hilit=bluetooth+performance
Unfortunately NXTasy is no more so the link at the end to the reports of others having issues with Mac and Bluetooth will not work...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4004
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Native Bluetooth Performance on MAC - Snow Leopard

Postby nate » Mon Jan 09, 2012 3:33 pm

gloomyandy wrote:Hi,
You may find this (old) thread of interest...
viewtopic.php?f=6&t=1331&hilit=bluetooth+performance
Unfortunately NXTasy is no more so the link at the end to the reports of others having issues with Mac and Bluetooth will not work...

Andy


I had read that earlier, and tried to see if the NXTasy link was available in the Internet WayBack machine (www.waybackmachine.org), but after spending about 20 minutes looking I gave up.

Thanks!


Nate
nate
New User
 
Posts: 16
Joined: Sat Oct 29, 2011 11:40 pm


Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

cron
more stuff