i was just about to test my code but my batteryâs didnât get charge as the plug was pulled out! but before i share a video etc i thought id post the shifting code for others to look at just in case you see a problem.
If you are familiar with the phoenix codes Gait Engine then this should make sense. if not then all will come clear shortly.
Firstly we have the bytetable that flows along side the gait for the body shifting.
im using a 50 step wave gait for this.
[code]'Walking comp tables:
; GaitLegNr(cLF) = 3
; GaitLegNr(cRR) = 15
; GaitLegNr(cRF) = 28
; GaitLegNr(cLR) = 40
; (cLF) (cRR)
'-15=113 15=143 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
Xcomp bytetable 100,100,100,100,100,105,110,115,120,128,128,140,145,150,155,155,155,155,155,155,155,155,155,155,155 |
155,155,155,155,155,150,145,140,128,128,120,145,110,105,100,100,100,100,100,100,100,100,100,100,100,100,
; 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50
; (cRF) (cLR)[/code]
[code] IF (GaitType = 1) THEN ;Wave 48 steps test
GaitLegNr(cLF) = 3
GaitLegNr(cRR) = 15
GaitLegNr(cRF) = 28
GaitLegNr(cLR) = 40
NrLiftedPos = 3
HalfLiftHeigth = 0
TLDivFactor = 40
StepsInGait = 48
NomGaitSpeed = 150
ENDIF[/code]
[code];[GAIT]
GaitCurrentLegNr var nib
Gait [GaitCurrentLegNr]
BodyPosX = (Xcomp(GaitStep))-128
;Clear values under the cTravelDeadZone
IF (GaitInMotion=0) THEN
TravelLengthX=0
TravelLengthZ=0
TravelRotationY=0
ENDIF
;Leg middle up position
;Gait in motion Gait NOT in motion, return to home position
IF (GaitInMotion & (NrLiftedPos=1 | NrLiftedPos=3) & GaitStep=GaitLegNr(GaitCurrentLegNr)) | (NOT GaitInMotion & GaitStep=GaitLegNr(GaitCurrentLegNr) & ((ABS(GaitPosX(GaitCurrentLegNr))>2) | (ABS(GaitPosZ(GaitCurrentLegNr))>2) | (ABS(GaitRotY(GaitCurrentLegNr))>2))) THEN ;Up
GaitPosX(GaitCurrentLegNr) = 0
GaitPosY(GaitCurrentLegNr) = -LegLiftHeight
GaitPosZ(GaitCurrentLegNr) = 0
GaitRotY(GaitCurrentLegNr) = 0
ELSE
;Optional Half heigth Rear
IF ((NrLiftedPos=2 & GaitStep=GaitLegNr(GaitCurrentLegNr)) | (NrLiftedPos=3 & (GaitStep=GaitLegNr(GaitCurrentLegNr)-1 | GaitStep=GaitLegNr(GaitCurrentLegNr)+(StepsInGait-1)))) & GaitInMotion THEN
GaitPosX(GaitCurrentLegNr) = -TravelLengthX/2
GaitPosY(GaitCurrentLegNr) = -LegLiftHeight/(HalfLiftHeigth+1)
GaitPosZ(GaitCurrentLegNr) = -TravelLengthZ/2
GaitRotY(GaitCurrentLegNr) = -TravelRotationY/2
ELSE
;Optional half heigth front
IF (NrLiftedPos>=2) & (GaitStep=GaitLegNr(GaitCurrentLegNr)+1 | GaitStep=GaitLegNr(GaitCurrentLegNr)-(StepsInGait-1)) & GaitInMotion THEN
GaitPosX(GaitCurrentLegNr) = TravelLengthX/2
GaitPosY(GaitCurrentLegNr) = -LegLiftHeight/(HalfLiftHeigth+1)
GaitPosZ(GaitCurrentLegNr) = TravelLengthZ/2
GaitRotY(GaitCurrentLegNr) = TravelRotationY/2
ELSE
;Leg front down position
IF (GaitStep=GaitLegNr(GaitCurrentLegNr)+NrLiftedPos | GaitStep=GaitLegNr(GaitCurrentLegNr)-(StepsInGait-NrLiftedPos)) & GaitPosY(GaitCurrentLegNr)<0 THEN
GaitPosX(GaitCurrentLegNr) = TravelLengthX/2
GaitPosZ(GaitCurrentLegNr) = TravelLengthZ/2
GaitRotY(GaitCurrentLegNr) = TravelRotationY/2
GaitPosY(GaitCurrentLegNr) = 0 ;Only move leg down at once if terrain adaption is turned off
;Move body forward
ELSE
GaitPosX(GaitCurrentLegNr) = GaitPosX(GaitCurrentLegNr) - (TravelLengthX/TLDivFactor)
GaitPosY(GaitCurrentLegNr) = 0
GaitPosZ(GaitCurrentLegNr) = GaitPosZ(GaitCurrentLegNr) - (TravelLengthZ/TLDivFactor)
GaitRotY(GaitCurrentLegNr) = GaitRotY(GaitCurrentLegNr) - (TravelRotationY/TLDivFactor)
ENDIF
ENDIF
ENDIF
ENDIF
;Advance to the next step
IF LastLeg THEN ;The last leg in this step
GaitStep = GaitStep+1
IF GaitStep>StepsInGait THEN
GaitStep = 1
ENDIF
ENDIF
return[/code]