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?