Basic Manoeuvres

February 13, 2009 – 7:24 pm

I’ve started developing a set of basic routines for the bot which can be called upon by any particular program, rather than hard coding them in each time. As well as making programs quicker to write (and hopefully easier to read), this helps future-proof task-specific code in case I make changes to the hardware platform.

For instance, the autonomous roaming code used in the previous post performs all turns by calls to basic routines in a separate file with obvious names like turnRight45. So if I fit, say, tracks instead of the current wheels, I can correct that one file once instead of hunting down and fixing every motor command in my other programs. This will also help when the LED wires fall out and I forget which port was assigned to which colour :)

The ‘correct’ java way to do this would probably be to extend the RobotClient to add such methods, but for now I’m just pulling them from a separate class. It took quite a while to work out how to even do that – I lost an hour trying to master the art of importing, before I discovered that the correct approach is ‘do nothing’. I declare the methods in a class QwerkBot saved in the same place as my other programs, and then if they make mention of some method QwerkBot.foo the compiler will add that in. Handy!

However, there’s still the question of writing the basic routines themselves, and here I’m bumping into some limitations of the Qwerk and its API. For instance, a few of the 180 turns in the roaming videos are nothing of the sort! This is because I currently have no way of detecting a heading, be it landmarks, wheel quadrature or a compass module. Even from a dead stop, knowing the motor commands sent is not enough; the driving surface, and that uncontrolled rear castor, will influence the physical outcome. Poking around in the interface for the iRobot Create suggests it can be given precise angle instructions, so perhaps such a base would be a worthwhile future upgrade for more ambitious projects.

Post a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word