Write Software

Next on agenda is to make Flig walk!

Original idea was to make sure that the three legs are on the ground all the time, slowly 'travelling' backwards (propelling body forward) while fourth leg travels forward to a new position. But which way around? Now to synchronise all the legs to do what is needed of them to do so?

Fortunately there are quite a few resources on the internet about quadruped walking patterns or gaits. This is one that was quite helpful:

Also, for testing it in the paper - I've devised special tool:

Gait Paper Tool

For implementing it in software, Flig got another service - called 'Gait Service' - a code that managed different 'gaits', selecting them on messages on the bus from PyROS (MQTT broker, really), and 'driving' selected gait. Gait(s) are normally made of phases - in above example of 'cat' walk, there are 4 distinct phases - one for each leg being in the air while other three are moving through their 'three part path' on the ground.

Unfortunately it wasn't enough! With legs moving as on the example above there are moments where the three legs do not provide enough support for the body above. So, in software, aside of abstracting 'Leg', I've added abstraction of 'Body', as well, including its relative position to where the legs are. That way 'Body' was able to move relatively to three points, three legs form with the ground and provide better CoG management. So, when front left leg is moving, body would move over back, right side...

When was all put together it looked like this:

There's the current feedback from the servos overlaid on the video, too. At this point we already have following 'gaits' (or, better, patterns of robot movements):

  • relax gait - robot lowers down and switched off all the servos
  • stand gait - robot moves up in 'first' position
  • walk gait - cat alike moving (as on the video)
  • position gait - this is not really a gait by itself - it is just convenient way of setting up position of the legs manually.

Those gaits can be invoked by sending specially crafted messages to PyROS message bus (MQTT broker). They are in form of

$ mosquitto_pub -h flig-pdm1 -t gait/invoke/<gait-name> -m "<gait parameters>"

Where gait parameters are command delimited list of name=value pairs:

  • speed - amount in seconds for moving to position or between phases
  • height - amount in cm from the ground to the body (how much legs are 'extended')
  • ox/oy - offset of body from centre
  • x/y/z - overall (applied to all legs) X, Y and Z coordinates. For position gait we have leg name like bl.x (back left) followed by leg's relative position (x in this case)
  • stride - distance between front most and back most positions of each leg

For instance:

$ mosquitto_pub -h flig-pdm1 -t gait/invoke/position -m "height=8.5,speed=1,x=0,y=0,ox=-0.2,oy=0"

makes Flig stand at 8.5cm height, 0.2cm slightly back and it would move to that position from wherever it is at in 1 second.