Hello support,
I’m trying to add a new link to the Brat template. I would like to have three links between the ankle and the body. Eventually I’d like to have 12 servos in total including a rotator and adductor on the body as well (see screenshot ‘Before and After’).
So far I have made some minor changes to the body size and link size, I thought I had figured out the coordinates but my new link does not display correctly (see Scout body with w4 link).
I have added w4 as my new link to the existing joints array:
w4 = w3
nxt = @arm.links.index(link)+1
if nxt < @arm.links.size
w4 = @arm.links[nxt]:w]/3.0 * sf
else
w4 = 2.5 * sf
end
joints.push [x,y,w2,w4]
f = 0.3;
Then I added w4 into the coordinates:
coords = -w2,0],-w3,-len],[w3,-len],[w2,0],-w4,0],[w4,0],[0,-len],-w2*(1+f),f],-w3*(1+f),-len*(1+f)],[w3*(1+f),-len*(1+f)],[w2*(1+f),f],-w4*(1+f),f],[w4*(1+f),f]]
But I’m not sure how to reference those coordinates when it comes to drawing the new link correctly. It looks to me that the joints are defined logically and then drawn using a graphics path which references the coordinates. But I don’t see how the coords 0,1,2,3 reference the -w2,-len or 0 in the coords in the array?
gp = GraphicsPath.new
gp.addLine coords[0],coords[1]
gp.addLine coords[1],coords[2]
gp.addLine coords[2],coords[3]
gp.closeFigure
I’ve attached the project and the modified code. Any help appreciated, thanks!
Attachments:
Before and After
Scout body with w4 link
Brat_Mech_mod_1.07
New draw arm code.txt (4.02 KB)
Brat_Mech_mod_1.07.fsp (1010 KB)