I havent had time to impliment the code yet. i will try and have a go tonight…Like this?
OffsetCoxa con 60
add these too: or do i change all IKfeetPos# in the code to (_New)
IKFeetPosX_NEW var sword ;Input position of the Feet X
IKFeetPosY_NEW var sword ;Input position of the Feet Y
what would be the right place for this?
IKFeetPosX_NEW = IKFeetPosX*Cos(-OffsetCoxa) - IKFeetPosY*Sin(OffsetCoxa)
IKFeetPosY_NEW = IKFeetPosX*Sin(OffsetCoxa) + IKFeetPosY*Cos(OffsetCoxa)
is this all i need to change?
[code]LegIK [IKFeetPosX_NEW, IKFeetPosY_NEW, IKFeetPosZ]
IKFeetPosXZ = TOINT(FSQRT(TOFLOAT((IKFeetPosX_NEWIKFeetPosX_NEW)+(IKFeetPosZIKFeetPosZ)))) ;Input position of the Feet X/Y/Z
IKCF = FSQRT(TOFLOAT(((IKFeetPosXZ-CoxaLength)(IKFeetPosXZ-CoxaLength))+(IKFeetPosY_NEWIKFeetPosY_NEW)))
GOSUB GetBoogTan [IKFeetPosXZ-CoxaLength, IKFeetPosY_NEW]
IKA1 = BoogTan
IKA2 = FACOS((TOFLOAT((FemurLengthFemurLength) - (TibiaLengthTibiaLength)) + (IKCFIKCF)) / (TOFLOAT(2Femurlength) * IKCF))
;IKFemurAngle
IKFemurAngle = (TOINT(((IKA1 + IKA2) * 180.0) / 3.141592)*-1)+90
;IKTibiaAngle
IKTibiaAngle = (90-TOINT(((FACOS((TOFLOAT((FemurLengthFemurLength) + (TibiaLengthTibiaLength)) - (IKCFIKCF)) / TOFLOAT(2Femurlength*TibiaLength)))*180.0) / 3.141592)) * -1
;IKCoxaAngle
GOSUB GetBoogTan [IKFeetPosZ, IKFeetPosX_NEW]
IKCoxaAngle = TOINT((BoogTan*180.0) / 3.141592)
IF(IKCF < TOFLOAT(FemurLength+TibiaLength-30)) THEN
IKSolution = POSITIVE ;Output POSITIVE IF the solution is possible
ELSE
IF(IKCF < TOFLOAT(FemurLength+TibiaLength)) THEN
IKSolutionWarning = POSITIVE ;Output POSITIVE IF the solution is NEARLY possible
ELSE
IKSolutionError = POSITIVE ;Output POSITIVE IF the solution is NOT possible
ENDIF
ENDIF
return[/code]
Jim.
i will be ordering one of your packs jim. ![:wink: :wink:](//community.robotshop.com/forum/images/emoji/twitter/wink.png?v=9)
Here is the code currently on the Atom:
[code]CoxaLength con 55 ;Length of the Coxa [mm]
FemurLength con 96 ;Length of the Femur [mm]
TibiaLength con 145 ;Lenght of the Tibia [mm]
CoxaAngle con 0
RFOffsetX con -60 ;Distance X from center of the body to the Right Front coxa
RFOffsetZ con -75 ;Distance Z from center of the body to the Right Front coxa
RROffsetX con -60 ;Distance X from center of the body to the Right Rear coxa
RROffsetZ con 75 ;Distance Z from center of the body to the Right Rear coxa
LFOffsetX con 60 ;Distance X from center of the body to the Left Front coxa
LFOffsetZ con -75 ;Distance Z from center of the body to the Left Front coxa
LROffsetX con 60 ;Distance X from center of the body to the Left Rear coxa
LROffsetZ con 75 ;Distance Z from center of the body to the Left Rear coxa[/code]
[code];The robot’s right front leg is (-,-) on the axis and it’s rear left leg is (+,+).
;Z-axis is front to back.
;X-axis is side to side.
;Y-axis is down (+) and up (-)
;Feet Positions in mm
RFPosX = 50 ;Start positions of the Right Front leg
RFPosY = 25
RFPosZ = -90
RRPosX = 50 ;Start positions of the Right Rear leg
RRPosY = 25
RRPosZ = 90
LFPosX = 50 ;Start positions of the Left Front leg
LFPosY = 25
LFPosZ = -90
LRPosX = 50 ;Start positions of the Left Rear leg
LRPosY = 25
LRPosZ = 90[/code]
regarding the XXPos# i think i must be measuring these wrong… i know you have been over this with me but i did what i was told. i still feel i must be doing something wrong. would it be ok to have a picture of were these measurements are from.
i have changed these numbers as you can see but it didnt really make much difference. maybe once i get a proper battery i can test it.
i think i know whats wrong but like i said ill need my new bat! ![:blush: :blush:](//community.robotshop.com/forum/images/emoji/twitter/blush.png?v=9)
when i did the registers the coxa was at 0 and all legs pointed out 90º from each other. the femurs are horizontal and the tars are directly under the tibia servos.
i tested the registers before adding the botboard and they works fine and legs returned to the same position as i calabrated when turned off-on.
also i have reversed the direction of the servos accordingly as the servos are set up differently for that phoenix:
[code]ServoDriver:
;Front Right leg
serout SSC_OUTPUT,SSC_BAUD,"#",dec RFCoxaPin,“P”,dec TOINT(TOFLOAT(-RFCoxaAngle +90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec RFFemurPin,“P”,dec TOINT(TOFLOAT(RFFemurAngle+90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec RFTibiaPin,“P”,dec TOINT(TOFLOAT(-RFTibiaAngle+90)/0.10588238)+650]
;Rear Right leg
serout SSC_OUTPUT,SSC_BAUD,"#",dec RRCoxaPin,“P”,dec TOINT(TOFLOAT(-RRCoxaAngle +90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec RRFemurPin,“P”,dec TOINT(TOFLOAT(RRFemurAngle+90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec RRTibiaPin,“P”,dec TOINT(TOFLOAT(-RRTibiaAngle+90)/0.10588238)+650]
;Front Left leg
serout SSC_OUTPUT,SSC_BAUD,"#",dec LFCoxaPin,“P”,dec TOINT(TOFLOAT(LFCoxaAngle +90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec LFFemurPin,“P”,dec TOINT(TOFLOAT(-LFFemurAngle+90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec LFTibiaPin,“P”,dec TOINT(TOFLOAT(LFTibiaAngle+90)/0.10588238)+650]
;Rear Left leg
serout SSC_OUTPUT,SSC_BAUD,"#",dec LRCoxaPin,“P”,dec TOINT(TOFLOAT(LRCoxaAngle +90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec LRFemurPin,“P”,dec TOINT(TOFLOAT(-LRFemurAngle+90)/0.10588238)+650]
serout SSC_OUTPUT,SSC_BAUD,"#",dec LRTibiaPin,“P”,dec TOINT(TOFLOAT(LRTibiaAngle+90)/0.10588238)+650]
[/code]
![:confused: :confused:](//community.robotshop.com/forum/images/emoji/twitter/confused.png?v=9)