Our lil' friend went through a quite rebellious stage the last days, but we now seem to have outgrown the worst problems - the toddler has started talking! After a lengthy search through available libraries for communicating with NXT devices over bluetooth, we've finally settled on jaraco.nxt, as it's the only one we got working within a reasonable time-frame, has the correct abstraction level and happens to be written in python. And as a bonus, available through PyPI, which makes it all so much more pleasant to get started. Documentation is not great, but the source code is succinct enough to be easily read, and it ships with a couple of working examples to get you started.

Why do we want the bluetooth communication anyway? Purely for debugging purposes. Lil' Bobby is expected to navigate around the playing field on his own, being aware of his own approximate coordinates on the field so that he can avoid colliding with the net, and to be able to throw stuff over the net when that time comes. Implementing this logic would not be too hard in a pure software emulation, but implementing this on a hardware device in, you know, real life, comes the brutality of working with cheap sensors and inaccurate motors. So we use the bluetooth connection purely for debugging, writing out sensor data and debug statements so that we can monitor it during execution.

The logging code we use for monitoring looks like this:

It's far from perfect though, the NXT will still lose all bluetooth communication quite haphazardly, and can only recover through a reboot. But we now have more uptime than not, a great improvement from the four hours we spent getting to this point, where connections were dropping randomly and the NXT device seemed to respond as predictably to messages as cornstarch do to the latest Kanye single. With this rolling, we managed to teach Bob collision detection and subsequent recovery, and get a rough metric of distance to nearest wall. Videos might or might not follow shortly.

← Back to main