hello,
I am building an hexapod. I almost done with its coding implementing inverse kinematics. but I have serious kind of confusion.
Well as left and right side of hexapod are mirror when I command right rear coxa servo to move 30 degree it move upwards away from me similarly when I command left rear coxa servo to move 30 degree it move downwards towards me. meanz they move in opposite direction. as the are mirror some happened to other two servo of single leg .Do I have to make them move in some direction? or the inverse kinematics. will take care of it?
Likewise it always helps to give some more information, like what type of servo you are using. What are you using to control them, what type of processor…
Example the answer may be different depending on what servo/servo controller you are using
If RC (like Hitec…) the fix would be like Alan stated. If it is some form of Servo like a Robotis AX-12, then the calculations might be different. If using Orion Robotics/Basic Micro, different servo position scheme.
I am using hitec RC servos.
what I am doing is :
As inverse kinematics calculate all the values for servo I am updating the new angles for right side servos as calculated by inverse kinematics means if ik calculates coxa value for right rear leg 30 I simply give servo command to move 30 but for left leg if 20 is Ik calculated angle then I am commanding servo to move -20 to make move both coxa of left and right in same direction.
is this correct or I have to send angle calculated by Ik directly to the servos for left side legs.
If I’m correct, the value 3000 is the pulsation lengh sent to the servo, the rang is from 0 to 3000. This means for 0 degree angle, the value needs to be 1500.
If you want to turn your servo by 30 degrees clockwise, the value can be 2 things based on your servo and code.
It can be:
1500+300
or
1500-300
I don’t have the scale of a particular servo handy, 500 - 2500 often gives you a range of 180 degrees, sometimes only 90 degrees. 1500 is the “centered” norm. so 3000 - 500 gives you 2500, or “flips” the servo (mirrored). All servos center at 1500, but may not get out to the extremes of 500 or 2500.
My servo moves to -90 (clockwise) toward positive X-axis on 400 counts 0 center on Y axis on 1300 count and t0 90 (anticlockwise)toward negative X-axis on 2200 counts.
1800 count is the total count range
so for right legs my way calculating counts is
servo counts =1300+(angle10) // for right legs
if angle is 30 count will be
servo counts = 1300+(3010)=1600.
and for left leg to move it in the same direction as right leg I am doing
servo counts =1300-(angle10) // left legs
so for 30 is gives me
A): servo counts = 1300-(3010)=1000. both left and write move in some direction anticlockwise by doing so this.
when I use
B): servo counts =1300+(angle*10) for left legs the movement of left and write legs are opposite .
which one should I use for writing the values calculated by Ik for left leg servos? A or B?
I missed that 30 degrees was 300 (not 30), which looks like your scale. you can work either way from seems to be your neutral or 0 degree position. 1300 is not a usual center, but no great surprise.
If the servo goes in the right direction, then you’re set. You can do flip in either servo counts, or back in an angle calculation, which ever is more convenient for you.
ok
now you said I can also do in angle calculation like I am using Ik and very leg has different coordinate and the angles are calculated a according to it X and Z.
when I check lynxmoton code for will write value to SCC they are doing some thing like:
This no my code this lynxmotion code to drive servos:
[code];[SERVO DRIVER] Updates the positions of the servos
ServoDriver:
;Front Right leg
serout SSC_OUT,SSC_BAUTE,"#",dec RFCoxaPin,“P”,dec TOINT(TOFLOAT(-RFCoxaAngle +90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec RFFemurPin,“P”,dec TOINT(TOFLOAT(-RFFemurAngle+90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec RFTibiaPin,“P”,dec TOINT(TOFLOAT(-RFTibiaAngle+90)/0.10588238)+650]
;Middle Right leg
serout SSC_OUT,SSC_BAUTE,"#",dec RMCoxaPin,“P”,dec TOINT(TOFLOAT(-RMCoxaAngle +90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec RMFemurPin,“P”,dec TOINT(TOFLOAT(-RMFemurAngle+90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec RMTibiaPin,“P”,dec TOINT(TOFLOAT(-RMTibiaAngle+90)/0.10588238)+650]
;Rear Right leg
serout SSC_OUT,SSC_BAUTE,"#",dec RRCoxaPin,“P”,dec TOINT(TOFLOAT(-RRCoxaAngle +90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec RRFemurPin,“P”,dec TOINT(TOFLOAT(-RRFemurAngle+90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec RRTibiaPin,“P”,dec TOINT(TOFLOAT(-RRTibiaAngle+90)/0.10588238)+650]
;Front Left leg
serout SSC_OUT,SSC_BAUTE,"#",dec LFCoxaPin,“P”,dec TOINT(TOFLOAT(LFCoxaAngle +90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec LFFemurPin,“P”,dec TOINT(TOFLOAT(LFFemurAngle+90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec LFTibiaPin ,“P”,dec TOINT(TOFLOAT(LFTibiaAngle+90)/0.10588238)+650]
;Middle Left leg
serout SSC_OUT,SSC_BAUTE,"#",dec LMCoxaPin,“P”,dec TOINT(TOFLOAT(LMCoxaAngle +90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec LMFemurPin,“P”,dec TOINT(TOFLOAT(LMFemurAngle+90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec LMTibiaPin,“P”,dec TOINT(TOFLOAT(LMTibiaAngle+90)/0.10588238)+650]
;Rear Left leg
serout SSC_OUT,SSC_BAUTE,"#",dec LRCoxaPin,“P”,dec TOINT(TOFLOAT(LRCoxaAngle +90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec LRFemurPin,“P”,dec TOINT(TOFLOAT(LRFemurAngle+90)/0.10588238)+650]
serout SSC_OUT,SSC_BAUTE,"#",dec LRTibiaPin,“P”,dec TOINT(TOFLOAT(LRTibiaAngle+90)/0.10588238)+650]
Again I’m still a bit new to hexapods but I think 1300 for 0 degree is weird. If it was me, I would calibrate everything (0 degree) based on 1500, then it doesn’t matter if the servo goes 105 degrees on side and only 100 degrees the other side when reaches the limits. Also, maybe you could set some servo offset in the SSC32? or set the offset in the code itself but it depends what code you’re using.
What code do you use? on what electronic? (arduino, bap, raspi?)
Regarding the mirroring thing, well spoted on the ServoDriver, that my be a solution.
ok Now I am bit confident to move forward
Now Should the servos on hexapod move clockwise or anticlockwise on 300 servo counts?
As when we do some thing similar to lynxmotion code one move clockwise and other move anticlockwise and in effect both leg left and right legs look to moving in same direction.
when I am not multiplying -1 with left leg servos all servos are moving in same direction after multiplication left side servos move anticlockwise and right side moves in clock wise direction but the end point of both motor line on sight line complete parallel to each other you can say they reach at common point if you move them keeping them side by side without any distance between them.
using PIc18f452 in master slave configuration. six pic controller for all six legs and one master to control them.
I will check my servo movements again for center value counts