I’m the fine owner of my very on phoenix and have just recently finished building and calibrating it. My phoenix only consist of a ssc-32 controller so it shall remain tethered to my computer.
I’m now at the point where I want her to do something more than just stand their in a neutral “ALL=1500” position However I do not want to just take someones code nor do I wish to purchase the ssc-32 sequencer program. I’m a programmer at heart and wish to program her gait from the ground up. I see many of you enjoy tethering your ps2 controllers to her and controlling her like that but I see more autonomous solution as more rewarding. Of course I will add sensors as this project progresses but in the mean time I need some help with designing my code.
So this question goes out to all those who have written various tools and code to use a hexapod (Zenta, Xan, and a couple others). What was your thought process for getting the hexapod to move and have some kind of organized control over it? Did you read up on the locomotion of hexapods and the many gaits and then just hard code the gait? Or did you come up with a more elegant and dynamic solution? Also is their any reading I should look over to get familiar with the theory and terminology?
I just want to come up with something a little more flexible then a “Walk forward” button that just plays some sequence, etc, etc.
Well, I learned alot by looking at Xan’s code and I think that it was an excellent way to start.
Dive into Xan’s code and try to understand the underlying logic. If you can do that then you can start writing your own system.
Essentailly, the idea underlying all hexapod motion is that the tips of the feet of the robot live in some “home” position in X,Y,Z space. All movement, walking gaits, rotations, etc. are simply translations of those home positions in to some new spot in X,Y,Z space. Leg angles are then calcualted using inverse kinematics working backward from where you want the foot to be…and viola! movement.
Now what about types of movements where the tips of the feet stay still? (Like tilts or “stretches”)
And finally once I develop a system that can find solutions to feet positions is it all making scripts that have feet positions at certain times and “playing” these scripts? Is their another more dynamic approach to this as well? From what I’m assuming most of you guys are using the pre-scripted gaits, but how would a dynamic gait work?
This will sound wierd but tilts and stretches are handled the same way. Imagine if you want the hexapod body to shift left…that would be the same as moving all the feet to the right in space relative to the body. Since the feet are fixed to the ground the body “appears” to shift left.
As for gaits, they are not completely scripted. In Xan’s code, individual movement steps are generated by a function with a few input variables. I.e. number of “frames” per move, number of legs on the ground at all times, and leg lift order. Once again, I would say give his code a read through.
**In Xans code the main part that you will have to change for your robot is here: ** iv taken this from my Quadruped code so you will see that the middle legs have been removed but it still shows the bits you need:
RRCoxaPin con P0 ;Rear Right leg Hip Horizontal
RRFemurPin con P1 ;Rear Right leg Hip Vertical
RRTibiaPin con P2 ;Rear Right leg Knee
RFCoxaPin con P8 ;Front Right leg Hip Horizontal
RFFemurPin con P9 ;Front Right leg Hip Vertical
RFTibiaPin con P10 ;Front Right leg Knee
LRCoxaPin con P16 ;Rear Left leg Hip Horizontal
LRFemurPin con P17 ;Rear Left leg Hip Vertical
LRTibiaPin con P18 ;Rear Left leg Knee
LFCoxaPin con P24 ;Front Left leg Hip Horizontal
LFFemurPin con P25 ;Front Left leg Hip Vertical
LFTibiaPin con P26 ;Front Left leg Knee
;--------------------
RRCoxa_MIN con -40 ;Mechanical limits of the *RIGHT* REAR Leg
RRCoxa_MAX con 40
RRFemur_MIN con -50
RRFemur_MAX con 50
RRTibia_MIN con -45
RRTibia_MAX con 45
;-------------------
RFCoxa_MIN con -40 ;Mechanical limits of the *RIGHT* FRONT Leg
RFCoxa_MAX con 40
RFFemur_MIN con -50
RFFemur_MAX con 50
RFTibia_MIN con -45
RFTibia_MAX con 45
;-------------------
LRCoxa_MIN con -40 ;Mechanical limits of the *LEFT* REAR Leg
LRCoxa_MAX con 40
LRFemur_MIN con -50
LRFemur_MAX con 50
LRTibia_MIN con -45
LRTibia_MAX con 45
;-------------------
LFCoxa_MIN con -40 ;Mechanical limits of the *LEFT* FRONT Leg
LFCoxa_MAX con 40
LFFemur_MIN con -50
LFFemur_MAX con 50
LFTibia_MIN con -45
LFTibia_MAX con 45
;-------------------
CoxaLength con 40 ;Length of the Coxa [mm]
FemurLength con 96 ;Length of the Femur [mm]
TibiaLength con 145 ;Lenght of the Tibia [mm]
CoxaAngle con 60 ;Default Coxa setup angle
RFOffsetX con -50 ;Distance X from center of the body to the Right Front coxa
RFOffsetZ con -50 ;Distance Z from center of the body to the Right Front coxa
RROffsetX con -50 ;Distance X from center of the body to the Right Rear coxa
RROffsetZ con 50 ;Distance Z from center of the body to the Right Rear coxa
LFOffsetX con 50 ;Distance X from center of the body to the Left Front coxa
LFOffsetZ con -50 ;Distance Z from center of the body to the Left Front coxa
LROffsetX con 50 ;Distance X from center of the body to the Left Rear coxa
LROffsetZ con 50 ;Distance Z from center of the body to the Left Rear coxa
;--------------------
;Feet Positions in mm
RFPosX = 150 ;Start positions of the Right Front leg
RFPosY = 0
RFPosZ = -150
RRPosX = 150 ;Start positions of the Right Rear leg
RRPosY = 0
RRPosZ = 150
LFPosX = 150 ;Start positions of the Left Front leg
LFPosY = 0
LFPosZ = -150
LRPosX = 150 ;Start positions of the Left Rear leg
LRPosY = 0
LRPosZ = 150
**
Foot positions: **
Are last and the most difficult numbers to deal with. Essentialy, these foot position are the starting point in space (X,Y,Z) for each of the robots feet. As before, when looking at your robot from above with the robot’s head facing you…the Z-axis is front to back and the x-axis is side to side. The robot’s right front leg is (-,-) on the axis and it’s rear left leg is (+,+). Additionally, the Y-axis is the verticle axis down toward the ground is + and up toward the sky is -. Determining the innitial foot positions is not an easy task but basically they should be the point in space where your robot is curled up in “sleeping positionâ€
By dynamic, I’m guessing you are refering to flexibility of gait? A gait that can change not only the walking direction, but orientation? Or terrain adaption alike?
I’m still really new to this but I’m on a very similar trajectory as yourself… interested in making an autonomous bot while doing as much of the work as possible on my own.
I’ve been developing my own gait software though I have to admit that I know very little about kinematics. I have only done enough reading to come to the understanding that kinematics is the process of determining the position of an end effector based on the desired angles for the joints while inverse kinematics is the process of determining joint angles based on where you want the end effector to be. If you are up on your vector manipulations then the math won’t be difficult. In fact I thought that building the model was an interesting exercise.
My algorithm takes a vector representing the desired movement trajectory. It uses that information in conjunction with information about the bots dimensions and mechanical restrictions to determine the required angles. It never actually calculates the resulting positions of the feet. I don’t know whether this is considered some form of kinematics though I imagine it is.
One of the most significant observations I have made is that 1500 doesn’t always represent center on the servos if you define center as 90 degrees. Instead, because of the way the servo horns attach, 1500 forms an angle near 90 degrees but is usually off by a degree or two.
That’s about all I got to share for now but I’m interested to see what other responses your query generates.
The gaits in my code are predefined steps that initialize on the fly. The gait can vary in step length speed and direction corresponding to the (joystick) input. This means that the steps are pre-programmed but relative to the input. This makes it possible to change speed and direction on the fly. When to move what leg is a sequence. I’ve found some articles about dynamic gaits. I’ll post them if I can find them again. Dynamic gaits can come in handy when building something like terrain adaption. Although it does have some disadvantages as well because you can not fully control which leg will come where.
If you are planning to build the software from scratch you can relax and don’t need to worry about the gait at the moment You first need to get yourself familiar with Inverse Kinematics. Months of free time where spend to get the IK as fluent as it is today. Implementing the gait was a matter of a few weeks.
Maybe Zenta placed the articles in his favourites. I’m pretty lazy about ordering my stuff and alway end up asking myself why I didn’t safe the article.
Thank you everyone for your reply’s. This is making sense now.
Alright so I completely understand what I need to do for the Inverse Kinematics part. That will provide me with the interface to say “Foot W moves to (X,Y,Z)”
From their is probably where things will take a different turn. I’m think about using some kind of neural network implementation to generate my dynamic gait (possibly a recurrent one). I’ve had a little experience with them before so its not a new concept to me. I remember seeing a paper online about using NN’s to generate gaits. Plus the upside would be when I do have the money to add things such as foot pressure sensors it will just be another input of my network.
Even if I don’t go this route I now understand how the program will be separated
A. Inverse Kinematics calculations of feet and sending results to Hexapod
B. Some form of AI or pre-scripted sequences that generate the gait (Feet positions)
Does this sound correct for the most port? And please if you can post any links or articles you have about dynamic gait generation.
Also is their some kind of reference somewhere about the pre-scripted gaits you guys use. I know I’ve heard a couple names tossed around such as tripod and ripple gaits.
I’ve been working on this for twenty years. I haven’t built the robot yet, though, I got busy building electric mopeds.
But I worked out a scripted gait, and the animation was very slow, because I was using a 128k Macintosh. So I printed each frame on a large index card and made a flip book, then I videotaped it. Finally, last month I bought a DVD recorder, so I could upload it to Youtube: