I hope you have received the picture with the Axis reference system for each leg. This was a fast drawing indicating the main information about the Lengths of the segments in the legs, the angles needed, etc... Sorry for not depicting properly the legs, but I thought this picture was enough to understand my explanations.
Following, I clarify your questions:
Other places real sin() and cos() functions are used. I suspect it saves time.
No, it does not save so much time to use Sin() Cos(), it saves basically memory. You would need to make up new tables to calculate them, what would add up to the existing table of ARCOS and also to the several variables declared in the program. In my opinion, the use of (only 6 times in a position calculation cycle) of Sin Cos, reduces the complexity of the program and does not dramatically reduce the speed performance of the program. If you should make all the ARCCOS operations in each cycle, then you would (for sure) notice the low speed performance of the program.
I discovered that YPos is signed char (+127 -128), Tibia_Length for 3DOF-C is 141.
I can see Xpos and Zpos = 0, but why - Tibia_Length for Ypos?
There is no particular reason to use -TibiaLength for YPos. It just depends on where you place your Axis Reference System. In this case, as it is just placed on the HIP HORIZONTAL SERVO Axis, then the leg end is just in the negative direction of the Y axis in our reference system. Just that Alan, you can change it and say that Y axis is possitive in the downwards direction to the leg end, but then you have to change all the convention made in the program concerning the new possitive coordinates in Y direction.
All1500 (all 1500) would be the center of each of the servo's ranges. Seems like Ypos should be 0, it's perpendicular to the axis of the 'bot at this time. Where is Shunt?
Well, as explained before, YPos cannot be 0 when all the servos are at 1500 (center possition). In this situation, the Tibia of the leg is making almost a 90degrees angle with the FemurLength of the leg. Therefore, if we place the reference system in the HIPHORIZONTAL SERVO Axis, then the YPos must be negative. Concerning the Shunt label, it comes out when using the PowerPod Generation for Autonomous control option. Anyway it is just close to the MAIN label for the program.
So all 6 foot contact points get "moved" by vector addition of the speed vector.
ThatÂ´s it Alan. The new positions (X,Y,Z) are calculated for each leg (6 as you know). The positions are the endpoints (tips) of the legs. It is added a direction and a module (properly scaled). This is the basic idea. If you try to control the HEX by means only of the SSC-32 commands for tripod walking you will notice that you can only rotate, move ahead, move ahead+right or left or move backwards, backwards+right or left. This is a limitation of the SSC-32 commands. With the IK control, you can move (theoretically, I have to check this) the HEX in any direction with a PS2 controller for instance (it should be possible to move it even by side movement to right or left).
I follow the Dangle and Dcoord calcs. I don't see the reason for (128 - ABS(Height) - ABS(TibiaAngle * 2)) either.
Well, this is a kind of an small mistery that can be solved with some time. I will try to double check and revert.
YPos2 is vertical? I thought ZPos2 was. Zpos is = 0 to start. I can see that the vert axis would just be up/down (height?).
Yes Alan, YPos2 is vertical. ZPos is 0 at the begining because Z means the movement of the whole leg around the axis of the HIPHORIZONTAL servo (i.e. leg ahead, leg backwards). At the beginning (1500 neutral), the legs are centered with no position ahead or backwards.
DCord projected along both forward and lateral via cos() and sin() functions. 43 is 60 degrees, that answers one question, and 21 is 30 degrees as well. Seems like the moves would just be 180 degrees out for opposite sides. But the 300, I don't see that.
It makes sense to hav 180 degrees out of phase for each opposite sides (we want to keep the right direction for the HEX and this is only possible when we invert the direction for opposite legs). The other 30 degrees are still frustrating to me, I cannot find a coherent explanation.
Can you see what TibiaAngle does? Why it's added to Distance? Oh wait, TibiaAngle is for correcting the angle that the leg is at relative to the body. LegUpShift then is the distance the leg is raised. Or is that HeightShift?
I did not invest too much time in LegUpShift or HeightShift as they were not critical in my description of the program. But TibiaAngle is different. Try to thing the following: Look at the HEX from upwards. You could see a round body with the FemurLength comming radialy out from this circle. But you also will see an small part after the femurlength due to the curvature of the special 3DOF-C legs (which are curved and when projecting this distance over the XZ plane, you get about 10 or 20 milimiters). This is the reason for adding this variable where mentioned. In my opinion, its name does not help as it is not an angle, but a distance.
"due to bug in Basic" seems to indicate a problem, do you follow that?
There are a couple of other constants in there, /4 and *2 the aren't obvious to me.
TibiaAngle is related to the curvature of the leg? I don't see that yet.
Well, in most of the cases, the constants /4 and *2 are not relevant. If you notice the formulas correctly, you will see that they are cancelled in one or other means. I am not informed about these BASIC Bugs. I will have to check this later on. I explained TibiaAngle already.
That's probably the "TmpCos = (Femur_Length * Femur_Length - Tibia_Length * Tibia_Length + TmpSEWSEW)" I see.
You are missing the: TmpCos = TmpCos * 127 / (2 * Femur_Length * Tibia_Length), which is the last part of the COSINES LAW calculation.
Is this Rotate[index] ?
Rotate(Index) seems to be anything different. It is added to the HipHorizontal angle (which is the exact angle we want to move the leg to in the XZ plane). The Rotate(index) looks like an additional rotation factor composed with the desired direction (i.e. translation + rotation), but I am not sure yet. I will revert.
I hope this helps! I was trying to place the picture that I sent you on the forum, but I wasnÂ´t able. If you know how to do it, just post it in order that other people can find sense to these explanations and help us out in any way.
I will come back soon with more information.