Close

First Steps (via Processing API)

A project log for Stubby the (Teaching) Hexapod

100% open source robot platform with accessability and affordability in mind: teaching children of all ages about robots & programming

the-big-oneThe Big One 09/09/2014 at 03:470 Comments

Tonight Stubby took its first steps via the Processing API over Bluetooth.  The Processing test program is very simple: 

Stubby stubby = new Stubby(this, "/dev/rfcomm0");
stubby.turnOn();
stubby.moveForward(200);
stubby.moveBackward(200);
stubby.turnOff();

Within the library's API, each command handles the protocol communication, including acknowledges and command complete messages.  For instance, when the Processing program calls stubby.turnOn(), behind the scenes the API sends message 0x20 (power on), and waits for message 0x01 (acknowledge) from the robot before returning.  The move commands require two acknowledgements before returning: first, the command ack, then the command complete message.


The biggest hurdle tonight was actually getting Bluetooth set up on Debian... sigh.  It seemed really simple at first; the driver seems to be built into my kernel, and even getting the device paired (via KDE's Bluetooth GUI) is quite easy.  Actually getting the serial port created is a headache, though, and resulted in complete system lockup a couple of times, requiring a hard reboot (something I have not had to do in Linux for years).

Currently I am manually setting the serial port up, doing the following steps:

$ hcitool scan
Scanning ...
        00:12:02:01:01:97       Stubby

$ sudo rfcomm bind rfcomm0 00:12:02:01:01:97

Eventually I may put this in an init script, but for now I am not confident enough in the procedure to want that.  I tried putting this information into /etc/bluetooth/rfcomm.conf to get it to automatically bind, as various tutorials suggested, but that didn't appear to work.  More investigation is definitely required, but it is too late for me tonight.

In short, I still don't know if I am doing it right... if anyone has experience with this please let me know.


Edit: Well, it looks like it may be just problems with Debian Testing.  I downgraded the bluetooth packages to the Debian Stable versions and they appear to be working a bit better so far.  Here's to hoping...


Edit 2: Nope, no such luck... whatever the problem is, it appears to be at the kernel / driver level; either the driver does not properly support SPP, or something else is seriously wrong with the Bluetooth stack.  When using it, it works sometimes, but a good 25% of the time when I try to connect it causes a kernel panic and I have to do a hard boot (and sometimes even a hard boot is not sufficient, and I need an actual cold boot).  I am going to return that Bluetooth adaptor and try to figure out alternatives, possibly even just throwing an XBee on the end of an FTDI cable.  Boo-urns! :-(

On the bright side, though, Princess Sparkle's laptop, which has Bluetooth built in, works perfectly fine.  I will use XBee when debugging on my desktop, but she can still use Bluetooth when making her own programs.

Discussions