Advertisement
Guest User

Untitled

a guest
Jun 18th, 2022
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. armThickness=10;
  2. armDepth = 20;
  3.  
  4.  
  5. //defines a section of the arm with hidges highlighted with a pin
  6. module armSection(l){
  7. hull(){
  8. rotate([90,0,0]) cylinder(h=armThickness,d=armDepth,center=true);
  9. translate([0,0,l]) rotate([90,0,0]) cylinder(h=armThickness,d=armDepth,center=true);
  10. }
  11. rotate([90,0,0]) cylinder(h=armThickness*2,d=armDepth/5,center=true);
  12. translate([0,0,l]) rotate([90,0,0]) cylinder(h=armThickness*2,d=armDepth/5,center=true);
  13. }
  14.  
  15.  
  16. //defines a simpson arm, origin 0,0,0 with the hindge set correctly for desired elbow angle with the first section held vertical
  17. module armVert(l,elbowAngle){
  18. armSection(l/2);
  19. translate([0,0,l/2]) rotate([0,elbowAngle,0]) armSection(l/2);
  20. }
  21.  
  22. //module to derive a simpson arm based on its x/y orign and machine parameters
  23. // base the distance between towers (scaler)
  24. // l the length of the arm at full extension assumes two equal legth sections totaling to this
  25. // xt tower x cordinate
  26. // yt tower y cordinate
  27. // x desired effector x position for machine
  28. // y desired effector y position for machine
  29. // z desired effector z position for machine
  30.  
  31. module tower(base,l,xt,yt,x,y,z){
  32. xElement=x-xt;
  33. yElement=y-yt;
  34. zElement=z;
  35.  
  36. // in a real machine this is the controler parameter,
  37. // either by line drive or using a worm gear against a fixed pivot point
  38. // (drive proportional to pully ratio or ration of driven gear to arm length.
  39. //here we control x y and z and derive from that the elbow angles for the joints
  40. armLen=sqrt(pow(xElement,2)+pow(yElement,2)+pow(zElement,2));
  41.  
  42. //the following elements would be passive and mechanically derived.
  43. elbowAngle=180-asin((armLen/2)/(l/2))*2;
  44. baseAngleVert=((180-elbowAngle)/2)-asin(z/armLen);
  45. baseAngleHor=atan2(yElement,xElement);
  46.  
  47. //echo(xelement=xElement);
  48. //echo(yElement=yElement);
  49. //echo(zElement=zElement);
  50. //echo(armLen=armLen);
  51. //echo(elbowAngle=elbowAngle);
  52. //echo(baseAngleVert=baseAngleVert);
  53. //echo(baseAngleHor=baseAngleHor);
  54.  
  55. //rotate the whole arm to match the passive joints in the real machine,
  56. //translate tower to its desired origin
  57. translate([xt,yt,0]) rotate([0,baseAngleVert,baseAngleHor]) armVert(l,elbowAngle);
  58. }
  59.  
  60. base=180;
  61. maxArmLen=240;
  62. //this tower is further back such that it is equidistant from origin
  63. towerRisersHeight=30;
  64. x0TowerY=sqrt(pow(base,2)/2);
  65. echo(x0TowerY=x0TowerY);
  66.  
  67. loopVar=(($t))*360;
  68. x=sin(loopVar)*(base*.45);
  69. y=cos(loopVar)*(base*.45);
  70. z=40+loopVar/40;
  71.  
  72. translate([0,0,towerRisersHeight]){
  73. tower(base,maxArmLen,-base/2, -base/2,x,y,z);
  74. tower(base,maxArmLen, 0, x0TowerY,x,y,z);
  75. tower(base,maxArmLen, base/2, -base/2,x,y,z);
  76. }
  77. translate([-base/2, -base/2,0]) cylinder(h=towerRisersHeight,d=armDepth);
  78. translate([ 0, x0TowerY,0]) cylinder(h=towerRisersHeight,d=armDepth);
  79. translate([ base/2, -base/2,0]) cylinder(h=towerRisersHeight,d=armDepth);
  80.  
  81. difference(){
  82. cylinder(r=x0TowerY+armDepth,h=1,center=true);
  83. cylinder(r=x0TowerY-armDepth,h=2,center=true);
  84. }
  85.  
  86. translate([200,0,0]){
  87. cube([10,10,x]);
  88. translate([0,-10,0]) text("x");
  89.  
  90. translate([15,0,0]) {
  91. cube([10,10,y]);
  92. translate([0,-10,0]) text("y");
  93. }
  94. translate([30,0,0]) {
  95. cube([10,10,z]);
  96. translate([0,-10,0]) text("z");
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement