Hexy Goes Exploring

Finally got around to starting another project with Hexy. Delays on my part due to laziness, lovely British summer weather (therefore Pimms) and being jaw-dropped by the awesomeness of this guy.

Note that the cable has the black wire on the left at the bottom, but on the right at the sensor

Note that the cable has the black wire on the left at the bottom, but on the right at the sensor

Rather embarrassingly, had to ask the lovely forum users for help at the outset and got given some really useful code-snippets back to help me on my way.

Some tweaks and fiddles later and I had Hexy swinging his head back and forth and some distance information being passed back to the Python code to allow it to make some decisions about what Hexy should do next. This is the start of a closed loop controller for Hexy.

Closed loop control is a really important idea. It's what you do every day, you're doing it right now, as your eyes pass from word to word. Without closed loop control you'd fall over on your face as soon as you tried to stand and take a step. It's also a massive topic, which I'm only going to scratch the surface.

Feedback is the key to all of this, and it can take many forms, but it all boils down to measuring. If you can measure something about what you're doing, you can use that information to help to control it. Taking that information about what's happening and using it forms a closed loop.

Imagine trying to stand up without any information about your balance from your ears, or seeing if there's anything that you'll bump your head on. You do this without having to think about it at all, unconsciously you do something like this:

Standing up Flow Chart

One of the difficulties of using feedback is knowing how accurate the information is. Perhaps you're trying to balance, but feel dizzy; or if you're trying to see where to place your feet as you walk but aren't wearing your glasses? If the feedback you're using to control the system is inaccurate, your control won't be so hot. Hexy can see with his Ultrasonic Distance Sensor, but sometimes the data is noisy. A nice easy way to reduce this error due to noise is by averaging a few measurements.

So how does Hexy explore? It's a set of actions and decisions based on feedback. Have a look around with the sensor, make a decision about which way to go, do it, repeat.

Flow Diagram for Hexy Exploring

In order to implement this for Hexy you've got to make a couple of modifications to some files (in PoMoCo and the Servotor32 board), which are documented here. Then it's just a case of adding this file to your "Moves" folder and watching Hexy go!