Guest User

Autonauts Heavy Haulers OpenSCAD Script

a guest
Dec 16th, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 16.72 KB | Source Code | 0 0
  1. //--------------------------------
  2. // Heavy Haulers For Autonauts
  3. // Keith Olson
  4. // CC 2020
  5. // OpenSCAD
  6. //--------------------------------
  7.  
  8. // Make GIF.
  9. // magick frame*.png -crop 900x900+510+3 +repage -resize 300x300 +repage haulbot.gif
  10. // 36 FPS / 72 Steps
  11.  
  12. // magick frame*.png -crop 900x900+510+3 +repage -resize 300x300 +repage haulbot.gif
  13. // 36 FPS / 72 Steps
  14.  
  15. // Thingiverse Customizer Docs: http://customizer.makerbot.com/docs
  16.  
  17. // OpenSCAD uses millimeters (mm) for units.
  18. // Distance functions are both for conversion and to state plainly that a number is a
  19. //    measurement, not just a value.
  20. // Fractions are interpreted as formulas: '1 3/4' = '1+3/4' = 1.75
  21. function mm(x = 1)     = x *    1.00000;
  22. function cm(x = 1)     = x *   10.00000;
  23. function m(x = 1)      = x * 1000.00000;
  24. function inches(x = 1) = x *   25.40000;  
  25. function feet(x = 1)   = x *   25.40000 * 12;  
  26. function yards(x = 1)  = x *   25.40000 * 12 * 3;  
  27.  
  28. function twice(x = 1)  = x *    2.00000;
  29. function half(x = 1)   = x *    0.50000;
  30.  
  31. // OpenSCAD uses degrees (deg) for units.
  32. // Angle functions are both for conversion and to state plainly that a number is a
  33. //    measurement, not just a value.
  34. _pi   = 3.14159265359;
  35. _ease = 1.0155;  // Multiply holes by this to counteract shrinkage in 3d printed parts.
  36.  
  37. function deg(x = 1) = x;
  38. function rad(x = 1) = x * (180 / _pi);
  39. function true_hole_radius (radius, num_facets) = radius / cos(360/(num_facets*2));
  40. function poly_offset (radius, num_facets) = radius * cos(360/(num_facets*2));
  41.  
  42. quality = 24*5; // [12:6:360]
  43. smoothness=$preview ? 24*4 : quality; // (Circles are divided in $fn line segments.)
  44. //echo($preview,smoothness);
  45. $fn = smoothness;
  46.  
  47. //--------------------------------------------------------------------------------------------
  48.  
  49.  
  50.  
  51.  
  52. //--------------------------------------------------------------------------------------------
  53. // Bot Base
  54. //--------------------------------------------------------------------------------------------
  55. WheelDia      = cm( 45.0000);
  56. WheelDepth    = cm( 20.0000);
  57. AxleDia       = cm( 10.0000);
  58. WallThickness = cm(  5.0000);
  59. BotBaseWidth  =  m(  1.0000);
  60. BotBaseLength =  m(  2.0000);
  61. BotBaseHeight = cm( 50.0000);
  62. BotBaseInset  = cm( 20.0000);
  63. NumWheels     = 6;
  64. WheelInset    = BotBaseLength / NumWheels;
  65. WheelSpacing  = [0,1.5,4];
  66. KeyShaftDia   = cm(  5.0000);
  67. KeyHeadDia    = cm( 10.0000);
  68.  
  69. //--------------------------------------------------------------------------------------------
  70. // Bot Torso
  71. //--------------------------------------------------------------------------------------------
  72. BotTorsoWidth  =  m(  1.0000);
  73. BotTorsoLength =  m(  2.0000);
  74. BotTorsoHeight = cm( 50.0000);
  75.  
  76. BotTorsoBedHt  = 0.90; // percentage of total height
  77. BotTorsoBedWd  = 0.90; // percentage of total height
  78.  
  79. BotBedLength   = BotTorsoLength * 0.75;
  80. BedWallHeight  = [cm( 10.0000), cm( 50.0000)];
  81. BotArmDia      = cm( 20.0000);
  82. BotArmSecLen   = cm(125.0000);
  83. BotArmJointWd  = BotArmDia * 1.5;
  84. ExcavMult      = 1.25;
  85. BotArmAngle    = 60;
  86. BotHandDia     = cm( 35.0000);
  87. BotHandDepth   = cm( 20.0000);
  88. BotHandThick   = cm(  7.5000);
  89.  
  90. AntennaWd      = cm(  7.5000);
  91. AntennaHt      = cm( 75.0000);
  92. AntennaBallWd  = cm(  7.5000);
  93.  
  94. HeadlightWd    = (BotTorsoWidth/2 - (BotArmJointWd/2) * 1.5)/2;
  95. GrillUnit      = 5;
  96.  
  97. //WallThickness  = (BotTorsoWidth-(BotTorsoWidth*BotTorsoBedWd))/2;
  98.  
  99. BotExcavWd     = WallThickness * 2.5 * 3;
  100. BotExcavLip    = BotExcavWd * 0.25;
  101.  
  102. //--------------------------------------------------------------------------------------------
  103. // Bot Head
  104. //--------------------------------------------------------------------------------------------
  105. BotHeadWidth = BotTorsoWidth/2;
  106. BotSensorDia    = cm( 20.0000);
  107. BotSensorHeight = cm( 25.0000);
  108.  
  109. BedColor       = ["Peru", "#444444ff", "Linen"];
  110. BodyColor      = ["ForestGreen", "Gold", "DarkTurquoise"];
  111. ManipColor     = ["Gold", "Silver", BedColor[2]];
  112. WheelColor     = "Black";
  113. AxleColor      = "Gainsboro";
  114. HeadColor      = "WhiteSmoke";
  115. HeadlightColor = "LightYellow";
  116. GrillColor     = "Silver";
  117. KeyColor       = "Silver";
  118. SensorColor    = "LightBlue";
  119. AntennaColor2  = "GreenYellow";  
  120.  
  121. BotTypeText = ["Hauler", "Dumper", "Tanker"];
  122. BotType     = 2;
  123.  
  124. BotViewAngle = [[0,0],[60,0],[75,0],[90,0]];
  125. BotView      = 1;
  126. //--------------------------------------------------------------------------------------------
  127. // Draw All
  128. //--------------------------------------------------------------------------------------------
  129.  
  130. //translate([0, -BotBaseWidth/2, 0]) cube([BotBaseLength, BotBaseWidth,BotBaseHeight]);
  131. $vpr = [BotViewAngle[BotView][0],BotViewAngle[BotView][1],$t * 360];
  132. //echo("VPR :",[BotViewAngle[0],$t * 360]);
  133. $vpt = [0, 0, 0];
  134. //echo("VPT :",$vpt);
  135. $vpd = 20000;
  136. //echo($vpt);
  137. translate([-BotBaseLength*.75, -BotBaseWidth*0, WheelDia * 0.50])
  138. {
  139.     DrawBase();
  140.     DrawTorso();
  141.     DrawHead();
  142.     //DrawBed(0);
  143.     //DrawBucket();
  144.     //DrawHand();
  145.     //DrawArm();
  146.     //DrawKey();
  147. }
  148.  
  149. rotate([BotViewAngle[BotView][0]*2-90,0,$t * 360])
  150.     translate([0,-BotBaseLength*1,0])//BotTorsoHeight])
  151.     text(text = BotTypeText[BotType], font =
  152.         "Calibri:style=Bold"
  153.         , size = 500, halign = "center", $fn=72);
  154.  
  155. //echo("---",BotTorsoWidth,(BotTorsoWidth-BotTorsoWidth*BotTorsoBedWd/2));
  156. //--------------------------------------------------------------------------------------------
  157. // Modules
  158. //--------------------------------------------------------------------------------------------
  159.  
  160. module DrawWalls(BoxX,BoxY,BoxZ,WallT)
  161. {
  162.     difference()
  163.     {
  164.         translate([0,-BoxY/2,0])
  165.             cube([BoxX,BoxY,BoxZ]);
  166.         translate([0+WallT,-BoxY/2+WallT,-1])
  167.             cube([BoxX-WallT*2,BoxY-WallT*2,BoxZ+2]);
  168.     }
  169. }
  170.  
  171. module DrawBed(BedType = BotType)
  172. {
  173.     if (BedType == 0) // Hauler
  174.     {
  175.         translate([-WallThickness, -(BotTorsoWidth/2), -(WheelDia * 0.50) + BotBaseHeight])
  176.             cube([BotBedLength, BotTorsoWidth, WallThickness*2]);
  177.         translate([-WallThickness, 0, -(WheelDia * 0.50) + BotBaseHeight + WallThickness * 2])
  178.             DrawWalls(BotBedLength, BotTorsoWidth, BedWallHeight[BotType], WallThickness);
  179.     } else if (BedType == 1) // Dumper
  180.     {
  181.         translate([-WallThickness, -(BotTorsoWidth/2), -(WheelDia * 0.50) + BotBaseHeight])
  182.             cube([BotBedLength, BotTorsoWidth, WallThickness*2]);
  183.         translate([-WallThickness, 0, -(WheelDia * 0.50) + BotBaseHeight + WallThickness * 2])
  184.             DrawWalls(BotBedLength, BotTorsoWidth, BedWallHeight[BotType], WallThickness);        
  185.     } else if (BedType == 2) // Tanker
  186.     {
  187.         translate([-WallThickness, 0, -(WheelDia * 0.50) + BotBaseHeight + 0.5*poly_offset(BotTorsoWidth,6)])
  188.             rotate([0,90,0])
  189.             rotate([0,0,30])
  190.             cylinder(d = BotTorsoWidth, h = BotBedLength);
  191.         translate([BotBedLength*0.75,0,-(WheelDia * 0.50) + BotBaseHeight + poly_offset(BotTorsoWidth,6)])
  192.             cylinder(d=BotTorsoWidth/4, h=BotTorsoWidth/8);
  193.         translate([BotBedLength*0.75,0,-(WheelDia * 0.50) + BotBaseHeight + poly_offset(BotTorsoWidth,6)+BotTorsoWidth/16])
  194.             cylinder(d=BotTorsoWidth/3, h=BotTorsoWidth/8);
  195.     }
  196. }
  197.  
  198. module DrawTorso()
  199. {
  200.     color(BodyColor[BotType])
  201.     {
  202.         %difference()
  203.         {
  204.             translate([BotTorsoLength * 0.75, -(BotTorsoWidth/2), -(WheelDia * 0.50) + BotBaseHeight])
  205.                 cube([BotTorsoLength - BotBedLength, BotTorsoWidth, BotTorsoHeight]);
  206.             translate([BotTorsoLength - BotTorsoWidth/2-100, -BotTorsoWidth/2 - 1, BotBaseHeight - WheelDia * 0.50 + BotTorsoHeight/2 - 1])
  207.             cube([BotTorsoWidth/2+200,BotTorsoWidth/2+1,BotTorsoHeight+2]);
  208.         }
  209.     }
  210.     translate([BotTorsoLength - (BotArmJointWd/2)*1.5, -BotTorsoWidth/2 + (BotArmJointWd/2) * 1.5, BotBaseHeight  - WheelDia * 0.50 + (BotTorsoWidth-(BotTorsoWidth*BotTorsoBedWd))/2])
  211.         DrawArm();
  212.    
  213.     color(HeadlightColor)
  214.     {
  215.         translate([BotTorsoLength - (BotArmJointWd/2)*0, -BotTorsoWidth/2 + (BotArmJointWd/2) * 1.5, BotBaseHeight + BotTorsoHeight/4 - WheelDia * 0.50]) scale([0.125,1,.5]) sphere(HeadlightWd);
  216.         translate([BotTorsoLength - (BotArmJointWd/2)*0, BotTorsoWidth/2 - (BotArmJointWd/2) * 1.5, BotBaseHeight + BotTorsoHeight/4 - WheelDia * 0.50]) scale([0.125,1,.5]) sphere(HeadlightWd);
  217.     }
  218.     color(BedColor[BotType]) DrawBed(BotType);
  219.    
  220. }
  221.  
  222.  
  223. module DrawBucket()
  224. {
  225.     difference()
  226.     {
  227.         translate([0,-BotExcavWd/2,-BotExcavWd/3])
  228.             cube(BotExcavWd);
  229.         translate([WallThickness,-BotExcavWd/2+WallThickness,-BotExcavWd/3-1])
  230.             cube((BotExcavWd-WallThickness*2+1));
  231.     }
  232.     difference()
  233.     {
  234.         translate([BotExcavWd-WallThickness,-BotExcavWd/2,-BotExcavLip-BotExcavWd/3])
  235.             cube([WallThickness,BotExcavWd,BotExcavLip]);
  236.         translate([BotExcavWd-WallThickness/2,-BotExcavWd/2+BotExcavWd*2/10,-BotExcavLip-BotExcavWd/3])
  237.             cube([WallThickness*3,BotExcavWd/10,BotExcavLip*1.25],center = true);
  238.         translate([BotExcavWd-WallThickness/2,-BotExcavWd/2+BotExcavWd*5/10,-BotExcavLip-BotExcavWd/3])
  239.             cube([WallThickness*3,BotExcavWd/10,BotExcavLip*1.25],center = true);
  240.         translate([BotExcavWd-WallThickness/2,-BotExcavWd/2+BotExcavWd*8/10,-BotExcavLip-BotExcavWd/3])
  241.             cube([WallThickness*3,BotExcavWd/10,BotExcavLip*1.25],center = true);
  242.     }
  243. }
  244.  
  245. module DrawHand()
  246. {
  247.     translate([BotHandDia/2-BotHandThick/2,0,0])
  248.     difference()
  249.     {
  250.         cylinder(d=BotHandDia,h=BotHandDepth,center=true);
  251.         cylinder(d=BotHandDia-BotHandThick*2,h=BotHandDepth+2,center=true);
  252.         translate([BotHandDia/2,0,0]) cylinder(d=BotHandDia,h=BotHandDepth+2,center=true,$fn=4);
  253.     }
  254. }
  255. module DrawHead()
  256. {
  257.     translate([BotTorsoLength - BotTorsoWidth/4, BotTorsoWidth/4, BotBaseHeight + BotTorsoHeight - WheelDia * 0.50])
  258.     {
  259.         translate([-BotHeadWidth/2,-BotHeadWidth/2,0])
  260.             color(HeadColor) cube([BotHeadWidth,BotHeadWidth,WallThickness]);
  261.        
  262.         translate([-BotHeadWidth/4,BotHeadWidth/4,WallThickness])
  263.             DrawAntenna();
  264.         translate([BotHeadWidth/4,-BotHeadWidth/4,WallThickness])
  265.             DrawSensor();
  266.     }
  267. }
  268.  
  269. module DrawHose()
  270. {
  271.     translate([-BotArmJointWd/2,0,-BotArmJointWd/2])
  272.     difference()
  273.     {
  274.         union(){
  275.             cylinder(d=BotHandDia*.5,h=BotHandDepth*2,center=true);
  276.             cylinder(d=BotHandDia*.375,h=BotHandDepth*3,center=true);
  277.         }
  278.         cylinder(d=BotHandDia*.25,h=BotHandDepth*6+2,center=true);
  279.         //translate([BotHandDia/2,0,0]) cylinder(d=BotHandDia,h=BotHandDepth+2,center=true,$fn=4);
  280.     }
  281. }
  282.  
  283. module DrawSensor()
  284. {
  285.     color(SensorColor) difference()
  286.     {
  287.         union()
  288.         {
  289.             rotate([0,0,360/12]) cylinder(d=BotSensorDia, h=BotSensorHeight);
  290.             rotate([0,0,360/12]) translate([0,0,BotSensorHeight]) sphere(BotSensorDia/2);
  291.         }
  292.         translate([0,-BotSensorDia*2,BotSensorHeight/2])
  293.             cube([BotSensorDia*4,BotSensorDia*4,BotSensorHeight*4]);
  294.     }
  295. }
  296.  
  297. module DrawAntenna()
  298. {
  299.     color(HeadColor) rotate([0,0,360/12]) cylinder(d=AntennaWd * 2, h=AntennaHt * 0.2);
  300.     color(HeadColor) rotate([0,0,360/12]) cylinder(d=AntennaWd, h=AntennaHt);
  301.     translate([0,0,AntennaHt]) color(AntennaColor2) cube(AntennaBallWd*1.5,center=true);
  302. }
  303.  
  304. module DrawKey()
  305. {
  306.     translate([0,0,BotBaseHeight/2])
  307.     {
  308.         rotate([0,-90,180])
  309.         rotate([0,0,360/12]) cylinder(d=KeyShaftDia, h = BotBaseLength/2);
  310.         rotate([30,0,0]) hull()
  311.         {
  312.             translate([0,-KeyHeadDia/2,-KeyShaftDia/2]) cylinder(d=KeyHeadDia,h=KeyShaftDia);
  313.             translate([0,KeyHeadDia/2,-KeyShaftDia/2]) cylinder(d=KeyHeadDia,h=KeyShaftDia);
  314.         }
  315.     }
  316. }
  317.  
  318. module DrawGrill()
  319. {
  320.     scale([GrillUnit * 0.5,GrillUnit * 1,GrillUnit * 1]) hull()
  321.     {
  322.         translate([0,-30,20])
  323.         sphere(10);
  324.         translate([0,30,20])
  325.         sphere(10);
  326.         translate([0,-30,0])
  327.         sphere(10);
  328.         translate([0,30,0])
  329.         sphere(10);
  330.     }
  331. }
  332. module DrawArm(ArmType=BotType)
  333. {
  334.     if (ArmType == 0) // Hauler
  335.     {
  336.         color(BodyColor[BotType]) cylinder(d=BotArmDia,h=BotArmJointWd/2+BotTorsoHeight);
  337.         translate([0,0,+BotTorsoHeight + BotArmJointWd/2])
  338.         {
  339.             rotate([0,90-BotArmAngle,0])
  340.                 color(BodyColor[BotType]) cylinder(d=BotArmDia, h=BotArmSecLen);
  341.             color(BodyColor[BotType]) sphere(d=BotArmJointWd);
  342.                 translate([BotArmSecLen*cos(BotArmAngle), 0, BotArmSecLen*sin(BotArmAngle)])
  343.                 {
  344.                     color(BodyColor[BotType]) sphere(d=BotArmJointWd);
  345.                         rotate([0,180,0])
  346.                         color(BodyColor[BotType]) cylinder(d=BotArmDia, h=BotArmSecLen);
  347.                     translate([0,0,-BotArmSecLen])
  348.                         {
  349.                             color(BodyColor[BotType]) sphere(d=BotArmJointWd);
  350.                             translate([BotArmJointWd/2-BotHandThick/2,0,0])
  351.                                 color(ManipColor[BotType]) DrawHand();
  352.                         }
  353.                 }
  354.         }
  355.     } else if (ArmType == 1) // Dumper
  356.     {
  357.         color(BodyColor[BotType]) cylinder(d=BotArmDia * ExcavMult,h=BotArmJointWd * ExcavMult/2+BotTorsoHeight);
  358.         translate([0,0,+BotTorsoHeight + BotArmJointWd * ExcavMult/2])
  359.         {
  360.             rotate([0,90-BotArmAngle,0])
  361.                 color(BodyColor[BotType]) cylinder(d=BotArmDia * ExcavMult, h=BotArmSecLen);
  362.             color(BodyColor[BotType]) sphere(d=BotArmJointWd * ExcavMult);
  363.                 translate([BotArmSecLen*cos(BotArmAngle), 0, BotArmSecLen*sin(BotArmAngle)])
  364.                 {
  365.                     color(BodyColor[BotType]) sphere(d=BotArmJointWd * ExcavMult);
  366.                         rotate([0,180,0])
  367.                         color(BodyColor[BotType]) cylinder(d=BotArmDia * ExcavMult, h=BotArmSecLen);
  368.                     translate([0,0,-BotArmSecLen])
  369.                         {
  370.                             color(BodyColor[BotType]) sphere(d=BotArmJointWd * ExcavMult);
  371.                             translate([BotArmJointWd * ExcavMult/2-BotHandThick/2,0,0])
  372.                                 color(ManipColor[BotType]) DrawBucket();
  373.                         }
  374.                 }
  375.         }
  376.     } else if (ArmType == 2) // Tanker
  377.     {
  378.         color(BodyColor[BotType]) cylinder(d=BotArmDia * ExcavMult,h=BotArmJointWd * ExcavMult/2+BotTorsoHeight);
  379.         translate([0,0,+BotTorsoHeight + BotArmJointWd * ExcavMult/2])
  380.         {
  381.             rotate([0,90-BotArmAngle,0])
  382.                 color(BodyColor[BotType]) cylinder(d=BotArmDia * ExcavMult, h=BotArmSecLen);
  383.             color(BodyColor[BotType]) sphere(d=BotArmJointWd * ExcavMult);
  384.                 translate([BotArmSecLen*cos(BotArmAngle), 0, BotArmSecLen*sin(BotArmAngle)])
  385.                 {
  386.                     color(BodyColor[BotType]) sphere(d=BotArmJointWd * ExcavMult);
  387.                         rotate([0,180,0])
  388.                         color(BodyColor[BotType]) cylinder(d=BotArmDia * ExcavMult, h=BotArmSecLen);
  389.                     translate([0,0,-BotArmSecLen])
  390.                         {
  391.                             color(BodyColor[BotType]) sphere(d=BotArmJointWd * ExcavMult);
  392.                             translate([BotArmJointWd * ExcavMult/2-BotHandThick/2,0,0])
  393.                                 color(ManipColor[BotType]) DrawHose();
  394.                         }
  395.                 }
  396.         }
  397.     }
  398. }
  399.  
  400. module DrawBase()
  401. {
  402.     color(BodyColor[BotType]) translate([BotBaseInset, -(BotBaseWidth/2-WheelDepth), -(WheelDia * 0.50) + BotBaseHeight * 0.25])
  403.         cube([BotBaseLength-BotBaseInset, BotBaseWidth - WheelDepth * 2, BotBaseHeight * 0.75]);
  404.    
  405.     translate([WheelInset, 0, 0])
  406.         for (ii=[0:(NumWheels/2-1)])
  407.         {
  408.             //echo(WheelSpacing[ii]);
  409.             translate([WheelSpacing[ii] * WheelInset, 0, 0])
  410.             DrawWheels();
  411.         }
  412.     translate([0,0,-BotBaseHeight/2 + WheelDia * 0.250])
  413.         color(KeyColor) DrawKey();
  414.     translate([BotTorsoLength, 0, BotBaseHeight * 0.50  - WheelDia * 0.50])
  415.         color(GrillColor) DrawGrill();
  416. }
  417.  
  418. module DrawWheels()
  419. {
  420.     rotate([90,0,0])
  421.         color(AxleColor) cylinder(d=AxleDia, h=BotBaseWidth, center=true);
  422.     color(WheelColor)
  423.     {
  424.         translate([0, BotBaseWidth * 0.4750, 0])
  425.             DrawWheel();
  426.         translate([0, -BotBaseWidth * 0.4750, 0])
  427.             rotate([0,0,180])
  428.             DrawWheel();
  429.     }
  430. }
  431.  
  432.  
  433. module DrawWheel()
  434. {
  435.     translate([0,WheelDepth/2,0])
  436.     rotate([90,0,0])
  437.         difference()
  438.         {
  439.             cylinder(d=WheelDia, h=WheelDepth);
  440.             translate([0,0,-10])
  441.                 cylinder(d=WheelDia * 0.60, h=WheelDepth * 0.50);
  442.         }
  443. }
Advertisement
Add Comment
Please, Sign In to add comment