hexapod source code

Hi,

I am building a hexapod with 3 servos on each of the six legs for a total of 18 servos for movement.
I am wondering if anyone here has source code for one for the Arduino. I hate to reinvent the wheel if someone here would be so kind as to share. I have looked all over the internet and here and find bits and pieces of code, but have yet to find complete working code. Or maybe direct to me to some good code.

I was asked to teach a robotics class at a Boy Scout Camp, I taught one back in 1997 but it was just simple line and light follower kits. So I am hoping to do something much more advanced this time. Here is a picture of the body I have created, it is an enlarged version of one I down loaded from thingiverse. The original used real small servos and had no room for the electronics so I have enlarged it to fit MG996r's.

Scroll down to the bottom of the page to see the Hex-A-Pod

http://myrobotlab.org/content/boy-scout-camp-project#comment-4645

Thanks for considering
wkinne

It took a bit to find - but maybe this will help you?

Wow!

Thank you so much!

Looks like a great place to start.

wkinne

Speaking of inventing the wheel, I think you'll find that writing code for a Hexapod Tripod gait is trivial, and could be accomplished very quickly - even for having 3-servos per leg as with yours.

  1. write for one leg (FSM): lift leg, move leg forward, drop leg, move leg backwards.
  2. clone same for other 5 legs - requires only select servo# and trigger times.
  3. coordinate legs in groups of 3.

It's pretty darn trivial. Most of my walkers are quadrupeds, which require code that is 10X harder to write than for a hexapod, since the H6 uses static-stability, while a Q4 requires dynamic-stability.

Basically, you write a "re-enterable" FSM for step 1, using the basic Blink-Without-Delay scheme to time each FSM state. Go in, enter current state [selected using a switch() filter], check if time to take next action, if so then send servo signal and advance pointer to next state, exit. Same FSM for each leg, but using 180-deg out-of-phase trigger times for the 2 tripod groups. Really very simple.

The cool thing is, with this scheme, you can also operate each leg as an independent unit, to attain different gaits: eg, creep/crawl, ripple, tripod, etc, just by changing the step trigger times. If you want to learn a little bit of theory ...