Hi Xan,
I’ve been playing around with your gait code. And have made a 12 steps ripple gait and also a 8 steps tripod gait code for my LM Phoenix. Pretty cool to see her “dance” with the tripod gait too. Both the 12 steps and 8 steps gait are made with 3 swing positions.
My code for a 12 step ripple:
From the main section, initiate Ripple 12 steps pattern:
[code];Calculate Gait positions
gosub Gait [1, LRGaitPosX, LRGaitPosY, LRGaitPosZ, LRGaitRotY]
LRGaitPosX = GaitPosX
LRGaitPosY = GaitPosY
LRGaitPosZ = GaitPosZ
LRGaitRotY = GaitRotY
gosub Gait [3, RFGaitPosX, RFGaitPosY, RFGaitPosZ, RFGaitRotY]
RFGaitPosX = GaitPosX
RFGaitPosY = GaitPosY
RFGaitPosZ = GaitPosZ
RFGaitRotY = GaitRotY
gosub Gait [5, LMGaitPosX, LMGaitPosY, LMGaitPosZ, LMGaitRotY]
LMGaitPosX = GaitPosX
LMGaitPosY = GaitPosY
LMGaitPosZ = GaitPosZ
LMGaitRotY = GaitRotY
gosub Gait [7, RRGaitPosX, RRGaitPosY, RRGaitPosZ, RRGaitRotY]
RRGaitPosX = GaitPosX
RRGaitPosY = GaitPosY
RRGaitPosZ = GaitPosZ
RRGaitRotY = GaitRotY
gosub Gait [9, LFGaitPosX, LFGaitPosY, LFGaitPosZ, LFGaitRotY]
LFGaitPosX = GaitPosX
LFGaitPosY = GaitPosY
LFGaitPosZ = GaitPosZ
LFGaitRotY = GaitRotY
gosub Gait [11, RMGaitPosX, RMGaitPosY, RMGaitPosZ, RMGaitRotY]
RMGaitPosX = GaitPosX
RMGaitPosY = GaitPosY
RMGaitPosZ = GaitPosZ
RMGaitRotY = GaitRotY[/code]
And the 12 steps ripple gait sub:
[code];[GAIT]
Gait [GaitLegNr, GaitPosX, GaitPosY, GaitPosZ, GaitRotY]
IF (GaitStep=GaitLegNr) & ((ABS(TravelLengthX)>2) | (ABS(TravelLengthZ)>2) | (ABS(GaitPosX)>2) | (ABS(GaitPosZ)>2) | (ABS(GaitRotY)>2)) THEN ;Up
;Up middle position:
GaitPosX = 0
GaitPosY = -LegLiftHeight
GaitPosZ = 0
GaitRotY = 0
ELSE
;Up start position:
IF (GaitStep=GaitLegNr+1) & ((ABS(TravelLengthX)>2) | (ABS(TravelLengthZ)>2) | (ABS(GaitPosX)>2) | (ABS(GaitPosZ)>2) | (ABS(GaitRotY)>2)) THEN
GaitPosX = TravelLengthX/2
GaitPosY = -LegLiftHeight
GaitPosZ = TravelLengthZ/2
GaitRotY = TravelRotationY/2
ELSE
;Up end position:
IF (GaitStep=GaitLegNr-1 | GaitStep=GaitLegNr+11) & ((ABS(TravelLengthX)>2) | (ABS(TravelLengthZ)>2) | (ABS(GaitPosX)>2) | (ABS(GaitPosZ)>2) | (ABS(GaitRotY)>2)) THEN
GaitPosX = -TravelLengthX/2
GaitPosY = -LegLiftHeight
GaitPosZ = -TravelLengthZ/2
GaitRotY = -TravelRotationY/2
ELSE
;Down start position:
IF (GaitStep=GaitLegNr+2 | GaitStep=GaitLegNr-10) & GaitPosY<0 THEN
GaitPosX = TravelLengthX/2
GaitPosY = 0
GaitPosZ = TravelLengthZ/2
GaitRotY = TravelRotationY/2
;just walk:
ELSE
GaitPosX = GaitPosX - (TravelLengthX/8)
GaitPosY = 0
GaitPosZ = GaitPosZ - (TravelLengthZ/8)
GaitRotY = GaitRotY - (TravelRotationY/8)
ENDIF
ENDIF
ENDIF
ENDIF
;Advance to the next step
IF GaitLegNr=11 THEN ;the last leg in this step (RM leg)
GaitStep = GaitStep+1
IF GaitStep>12 THEN
GaitStep = 1
ENDIF
ENDIF
return[/code]
For the tripod gait I had to add a bit variable called LastLeg since the initation (your GaitLegNr) repeat itself for a tripod.
8 steps tripod code from the main section:
[code];Calculate Gait positions
LastLeg = FALSE
gosub Gait [1, LRGaitPosX, LRGaitPosY, LRGaitPosZ, LRGaitRotY]
LRGaitPosX = GaitPosX
LRGaitPosY = GaitPosY
LRGaitPosZ = GaitPosZ
LRGaitRotY = GaitRotY
gosub Gait [5, RFGaitPosX, RFGaitPosY, RFGaitPosZ, RFGaitRotY]
RFGaitPosX = GaitPosX
RFGaitPosY = GaitPosY
RFGaitPosZ = GaitPosZ
RFGaitRotY = GaitRotY
gosub Gait [5, LMGaitPosX, LMGaitPosY, LMGaitPosZ, LMGaitRotY]
LMGaitPosX = GaitPosX
LMGaitPosY = GaitPosY
LMGaitPosZ = GaitPosZ
LMGaitRotY = GaitRotY
gosub Gait [5, RRGaitPosX, RRGaitPosY, RRGaitPosZ, RRGaitRotY]
RRGaitPosX = GaitPosX
RRGaitPosY = GaitPosY
RRGaitPosZ = GaitPosZ
RRGaitRotY = GaitRotY
gosub Gait [1, LFGaitPosX, LFGaitPosY, LFGaitPosZ, LFGaitRotY]
LFGaitPosX = GaitPosX
LFGaitPosY = GaitPosY
LFGaitPosZ = GaitPosZ
LFGaitRotY = GaitRotY
LastLeg = TRUE
gosub Gait [1, RMGaitPosX, RMGaitPosY, RMGaitPosZ, RMGaitRotY]
RMGaitPosX = GaitPosX
RMGaitPosY = GaitPosY
RMGaitPosZ = GaitPosZ
RMGaitRotY = GaitRotY[/code]
And code for the gaitsub:
[code];[GAIT]
Gait [GaitLegNr, GaitPosX, GaitPosY, GaitPosZ, GaitRotY]
IF (GaitStep=GaitLegNr) & ((ABS(TravelLengthX)>2) | (ABS(TravelLengthZ)>2) | (ABS(GaitPosX)>2) | (ABS(GaitPosZ)>2) | (ABS(GaitRotY)>2)) THEN ;Up
;Up middle position:
GaitPosX = 0
GaitPosY = -LegLiftHeight
GaitPosZ = 0
GaitRotY = 0
ELSE
;Up start position:
IF (GaitStep=GaitLegNr+1) & ((ABS(TravelLengthX)>2) | (ABS(TravelLengthZ)>2) | (ABS(GaitPosX)>2) | (ABS(GaitPosZ)>2) | (ABS(GaitRotY)>2)) THEN
GaitPosX = TravelLengthX/2
GaitPosY = -LegLiftHeight
GaitPosZ = TravelLengthZ/2
GaitRotY = TravelRotationY/2
ELSE
;Up end position:
IF (GaitStep=GaitLegNr-1 | GaitStep=GaitLegNr+7) & ((ABS(TravelLengthX)>2) | (ABS(TravelLengthZ)>2) | (ABS(GaitPosX)>2) | (ABS(GaitPosZ)>2) | (ABS(GaitRotY)>2)) THEN
GaitPosX = -TravelLengthX/2
GaitPosY = -LegLiftHeight
GaitPosZ = -TravelLengthZ/2
GaitRotY = -TravelRotationY/2
ELSE
;Down start position:
IF (GaitStep=GaitLegNr+2) & GaitPosY<0 THEN
GaitPosX = TravelLengthX/2
GaitPosY = 0
GaitPosZ = TravelLengthZ/2
GaitRotY = TravelRotationY/2
;just walk:
ELSE
GaitPosX = GaitPosX - (TravelLengthX/4)
GaitPosY = 0
GaitPosZ = GaitPosZ - (TravelLengthZ/4)
GaitRotY = GaitRotY - (TravelRotationY/4)
ENDIF
ENDIF
ENDIF
ENDIF
;Advance to the next step
IF LastLeg THEN ;the last leg in this step (RM leg)
GaitStep = GaitStep+1
IF GaitStep>8 THEN
GaitStep = 1
ENDIF
ENDIF
return[/code]
When running the 12 steps ripple gait you can clearly see that calculation speed has to be improved. Not visible at 6 steps ripple.
I hope you didn’t mind me doing this. I just had to try.
Agian, thanks for sharing your code!