// Copyleft 2011, 2012 Sergio García-Cuevas González // // This work is licensed under the Creative Commons // Attribution-ShareAlike 3.0 Unported License. // To view a copy of this license, visit // http://creativecommons.org/licenses/by-sa/3.0/ // or send a letter to Creative Commons, // 444 Castro Street, Suite 900, Mountain View, // California, 94041, USA. // Cute robot figurine. // // Usage: // robot (PARAMETERS) // // There are lots of parameters. See the robot module // for an explanation and the bottom of this file for // an example. // Body // // The body is an upright cylinder with // a half sphere on top. // // Parameters: // - radius: body radius // - height: height of the cylindrical part // module body (radius, height) { union () { cylinder (h = height, r = radius); translate ([0, 0, height]) { sphere (r = radius); } } } // Leg // // The leg is an upright cylinder with a prismatic foot. // // Parameters: // - leg_radius: radius of the cylindrical leg // - leg_height: height of the cylindrical leg // - foot_longitudinal_position: distance between the mediolateral plane // of the foot and the axis of the // cylindrical leg; it is positive when // the foot is moved forward // - foot_lateral_position: distance between the medial plane of the foot // and the axis of the cylindrical leg; it is // positive when the foot is moved outward // - foot_length: length of the prismatic foot // - foot_width: width of the prismatic foot // - foot_height: height of the prismatic foot // module leg (leg_radius, leg_height, foot_longitudinal_position, foot_lateral_position, foot_length, foot_width, foot_height) { union () { translate (v = [foot_longitudinal_position - 0.5 * foot_length, foot_lateral_position - 0.5 * foot_width, 0]) { cube (size = [foot_length, foot_width, foot_height]); } cylinder (r = leg_radius, h = leg_height); } } // Eye // // The eye is an ellipsoid. // // Parameters: // - length: size of the longitudinal axis of the ellipsoidal eye // - width: size of the lateral axis of the ellipsoidal eye // - height: size of the vertical axis of the ellipsoidal eye // module eye (length, width, height) { scale (v = [length, width, height]) { union () { sphere (radius = 0.5); rotate (a = -90, v = [0, 1, 0]) { cylinder (r = 1, h = 1); } } } } // Arm // // The arm is a horizontal cylinder with a hand which is made by // half a hollow cylindrical tube and two parallel prismatic plates. // // Parameters: // - arm_radius: radius of the cylindrical arm // - arm_length: length of the cylindrical arm // - hand_longitudinal_position: distance between the axis of the // cylindrical arm and the mediolateral // plane of the prismatic plate part of the // hand; it is positive when the hand // is moved forward // - hand_vertical_position: distance between the axis of the cylindrical // arm and the medial horizontal plane of the // prismatic part of the hand; it is positive // when the hand is moved upward // - hand_radius: outer radius of the cylindrical tube part of the hand // - hand_thickness: thickness of the cylindrical tube part and the // prismatic plate parts of the hand // - hand_length: length of the prismatic plate part of the hand // - hand_height: height of the prismatic plate part of the hand // module arm (arm_radius, arm_length, hand_longitudinal_position, hand_vertical_position, hand_radius, hand_thickness, hand_length, hand_height) { union () { rotate (a = -90, v = [1, 0, 0]) { translate (v = [0, 0, -arm_length]) { cylinder (r = arm_radius, h = 2 * arm_length); } } translate (v = [hand_longitudinal_position - 0.5 * hand_length, arm_length + hand_radius, hand_vertical_position - 0.5 * hand_height]) { difference () { cylinder (r = hand_radius, h = hand_height); cylinder (r = hand_radius - hand_thickness, h = hand_height); translate (v = [0, -hand_radius, 0]) { cube (size = [hand_radius, 2 * hand_radius, hand_height]); } } } translate (v = [hand_longitudinal_position - 0.5 * hand_length, arm_length, hand_vertical_position - 0.5 * hand_height]) { difference () { cube (size = [hand_length, 2 * hand_radius, hand_height]); translate (v = [0, hand_thickness, 0]) { cube (size = [hand_length, 2 * hand_radius - 2 * hand_thickness, hand_height]); } } } } } // Lateral details // // A combination of the left eye, the left arm and the left leg. // The right lateral details can be done by mirroring. // // Parameters: // - body_radius: radius of the cylindrical body // - eye_vertical_position: distance between the center of the eye // and the bottom plane of the cylindrical body // - eye_azimuth: azimuthal angular position of the center of the eye // relative to the anterior meridian of the cylindrical // body // - eye_length: size of the longitudinal axis of the ellipsoidal eye // - eye_width: size of the lateral axis of the ellipsoidal eye // - eye_height: size of the vertical axis of the ellipsoidal eye // - arm_vertical_position: distance between the the bottom plane // of the cylindrical body and the center of // the cylindrical arm // - arm_azimuth: azimuthal angular position of the center of the // cylindrical arm relative the the anterior // meridian of the cylindrical body // - arm_radius: radius of the cylindrical arm // - arm_length: length of the cylindrical arm // - hand_longitudinal_position: distance between the axis of the // cylindrical arm and the mediolateral // plane of the prismatic plate part of the // hand; it is positive when the hand // is moved forward // - hand_vertical_position: distance between the axis of the cylindrical // arm and the medial horizontal plane of the // prismatic part of the hand; it is positive // when the hand is moved upward // - hand_rotation: downwards rotation angle of the hand around the axis // of the cylindrical arm relative to the horizontal // - hand_radius: outer radius of the cylindrical tube part of the hand // - hand_thickness: thickness of the cylindrical tube part and the // prismatic plate parts of the hand // - hand_length: length of the prismatic plate part of the hand // - hand_height: height of the prismatic plate part of the hand // - leg_longitudinal_position: distance between the center of the // cylindrical leg and the mediolateral // plane of the body // - leg_lateral_position: distance between the center of the cylindrical // leg and the medial plane of the body // - leg_rotation: outwards rotation angle of the foot around the axis // of the cylindrical leg relative to the fordward // position // - leg_radius: radius of the cylindrical leg // - leg_height: height of the cylindrical leg // - foot_longitudinal_position: distance between the mediolateral plane // of the foot and the axis of the // cylindrical leg; it is positive when // the foot is moved forward // - foot_lateral_position: distance between the medial plane of the foot // and the axis of the cylindrical leg; it is // positive when the foot is moved outward // - foot_length: length of the prismatic foot // - foot_width: width of the prismatic foot // - foot_height: height of the prismatic foot module lateral_details (body_radius, eye_vertical_position, eye_azimuth, eye_length, eye_width, eye_height, arm_vertical_position, arm_azimuth, arm_radius, arm_length, hand_longitudinal_position, hand_vertical_position, hand_rotation, hand_radius, hand_thickness, hand_length, hand_height, leg_longitudinal_position, leg_lateral_position, leg_radius, leg_height, foot_longitudinal_position, foot_lateral_position, foot_rotation, foot_length, foot_width, foot_height) { union () { rotate (a = eye_azimuth, v = [0, 0, 1]) { translate (v = [body_radius, 0, eye_vertical_position]) { eye (length = eye_length, width = eye_width, height = eye_height); } } rotate (a = arm_azimuth, v = [0, 0, 1]) { translate (v = [0, body_radius, arm_vertical_position]) { rotate (a = hand_rotation, v = [0, 1, 0]) { arm (arm_radius = arm_radius, arm_length = arm_length, hand_longitudinal_position = hand_longitudinal_position, hand_vertical_position = hand_vertical_position, hand_radius = hand_radius, hand_thickness = hand_thickness, hand_length = hand_length, hand_height = hand_height); } } } translate (v = [leg_longitudinal_position, leg_lateral_position, -leg_height]) { rotate (a = foot_rotation, v = [0, 0, 1]) { leg (leg_radius = leg_radius, leg_height = leg_height, foot_length = foot_length, foot_longitudinal_position = foot_longitudinal_position, foot_lateral_position = foot_lateral_position, foot_width = foot_width, foot_height = foot_height); } } } } // Antenna // // The antenna is an upright cylinder (the shaft) // with a distal ellipsoid (the tip) with radial symmetry. // // Parameters: // - shaft_radius: radius of the cylindrical shaft // - shaft_height: height of the cylindrical shaft // - tip_radius: radius of the ellipsoidal tip // - tip_height: height of the ellipsoidal tip // module antenna (shaft_radius, shaft_height, tip_radius, tip_height) { union () { translate (v = [0, 0, -shaft_height]) { cylinder (r = shaft_radius, h = 2 * shaft_height); } translate (v = [0, 0, shaft_height]) { scale (v = [tip_radius, tip_radius, tip_height / 2]) { sphere (r = 1); } } } } // Key // // The key is made of a horizontal, cylindrical shaft and two // shallow, hollow, vertical cylinders (the flanges) // // Parameters: // - shaft_radius: radius of the shaft // - shaft_length: length of the shaft // - key_longitudinal_position: distance between the distal // plane of the cylindrical shaft // and the center of each cylindrical // flange of the key // - key_radius: radius of the cylindrical flanges of the key // - key_thickness: thickness of the cylindrical flanges of the key // - key_hole_radius: radius of the cylindrical holes of the // cylindrical flanges of the key // module key (shaft_radius, shaft_length, key_longitudinal_position, key_radius, key_thickness, key_hole_radius) { difference () { union () { rotate (a = -90, v = [0, 1, 0]) { translate (v = [0, 0, -shaft_length]) { cylinder (r = shaft_radius, h = 2 * shaft_length); } } translate (v = [-key_longitudinal_position - 0.5 * shaft_length, key_hole_radius + shaft_radius, -0.5 * key_thickness]) { cylinder (r = key_radius, h = key_thickness); } translate (v = [-key_longitudinal_position - 0.5 * shaft_length, -key_hole_radius - shaft_radius, -0.5 * key_thickness]) { cylinder (r = key_radius, h = key_thickness); } } translate (v = [-key_longitudinal_position - 0.5 * shaft_length, key_hole_radius + shaft_radius, -0.5 * key_thickness]) { cylinder (r = key_hole_radius, h = key_thickness); } translate (v = [-key_longitudinal_position - 0.5 * shaft_length, -key_hole_radius - shaft_radius, -0.5 * key_thickness]) { cylinder (r = key_hole_radius, h = key_thickness); } } } // Robot // // The complete robot. // // Parameters: // - body_radius: radius of the cylindrical body // - body_height: height of the cylindrical part of the body // - eye_vertical_position: distance between the center of the eye // and the bottom plane of the cylindrical body // - eye_azimuth: azimuthal angular position of the center of the eye // relative to the anterior meridian of the cylindrical // body // - eye_length: size of the longitudinal axis of the ellipsoidal eye // - eye_width: size of the lateral axis of the ellipsoidal eye // - eye_height: size of the vertical axis of the ellipsoidal eye // - arm_vertical_position: distance between the the bottom plane // of the cylindrical body and the center of // the cylindrical arm // - arm_azimuth: azimuthal angular position of the center of the // cylindrical arm relative the the anterior // meridian of the cylindrical body // - arm_radius: radius of the cylindrical arm // - arm_length: length of the cylindrical arm // - hand_longitudinal_position: distance between the axis of the // cylindrical arm and the mediolateral // plane of the prismatic plate part of the // hand; it is positive when the hand // is moved forward // - hand_vertical_position: distance between the axis of the cylindrical // arm and the medial horizontal plane of the // prismatic part of the hand; it is positive // when the hand is moved upward // - left_hand_rotation: downwards rotation angle of the left hand around // the axis of the left cylindrical arm relative to // the horizontal // - right_hand_rotation: downwards rotation angle of the right hand around // the axis of the right cylindrical arm relative to // the horizontal // - hand_radius: outer radius of the cylindrical tube part of the hand // - hand_thickness: thickness of the cylindrical tube part and the // prismatic plate parts of the hand // - hand_length: length of the prismatic plate part of the hand // - hand_height: height of the prismatic plate part of the hand // - leg_longitudinal_position: distance between the center of the // cylindrical leg and the mediolateral // plane of the body // - leg_lateral_position: distance between the center of the cylindrical // leg and the medial plane of the body // - left_leg_rotation: outwards rotation angle of the left foot around // the axis of the left cylindrical leg relative to // the fordward position // - right_leg_rotation: outwards rotation angle of the right foot around // the axis of the right cylindrical leg relative to // the fordward position // - leg_radius: radius of the cylindrical leg // - leg_height: height of the cylindrical leg // - foot_longitudinal_position: distance between the mediolateral plane // of the foot and the axis of the // cylindrical leg; it is positive when // the foot is moved forward // - foot_lateral_position: distance between the medial plane of the foot // and the axis of the cylindrical leg; it is // positive when the foot is moved outward // - foot_length: length of the prismatic foot // - foot_width: width of the prismatic foot // - foot_height: height of the prismatic foot // - antenna_shaft_radius: radius of the cylindrical shaft of the antenna // - antenna_shaft_height: height of the cylindrical shaft of the antenna // - antenna_tip_radius: radius of the ellipsoidal tip of the antenna // - antenna_tip_height: height of the ellipsoidal tip of the antenna // - key_vertical_position: distance between the bottom plane // of the body and the center of the // cylindrical shaft of the key // - key_rotation: angular rotation of the key relative to the // horizontal (clockwise looking from behind // towards the body) // - key_shaft_radius: radius of the cylindrical shaft of the key // - key_shaft_length: length of the cylindrical shaft of the key // - key_longitudinal_position: distance between the distal // plane of the cylindrical shaft of // the key and the center of each // cylindrical flange of the key // - key_radius: radius of the cylindrical flanges of the key // - key_thickness: thickness of the cylindrical flanges of the key // - key_hole_radius: radius of the cylindrical holes of the // cylindrical flanges of the key // module robot (body_radius, body_height, eye_vertical_position, eye_azimuth, eye_length, eye_width, eye_height, arm_vertical_position, arm_azimuth, arm_radius, arm_length, hand_longitudinal_position, hand_vertical_position, left_hand_rotation, right_hand_rotation, hand_radius, hand_thickness, hand_length, hand_height, leg_longitudinal_position, leg_lateral_position, leg_radius, leg_height, foot_longitudinal_position, foot_lateral_position, left_foot_rotation, right_foot_rotation, foot_length, foot_width, foot_height, antenna_shaft_radius, antenna_shaft_height, antenna_tip_radius, antenna_tip_height, key_vertical_position, key_rotation, key_shaft_radius, key_shaft_length, key_longitudinal_position, key_radius, key_thickness, key_hole_radius) { translate (v = [0, 0, leg_height]) { union () { body (radius = body_radius, height = body_height); lateral_details (body_radius = body_radius, eye_vertical_position = eye_vertical_position, eye_azimuth = eye_azimuth, eye_length = eye_length, eye_width = eye_width, eye_height = eye_height, arm_vertical_position = arm_vertical_position, arm_azimuth = arm_azimuth, arm_radius = arm_radius, arm_length = arm_length, hand_longitudinal_position = hand_longitudinal_position, hand_vertical_position = hand_vertical_position, hand_rotation = left_hand_rotation, hand_radius = hand_radius, hand_thickness = hand_thickness, hand_length = hand_length, hand_height = hand_height, leg_longitudinal_position = leg_longitudinal_position, leg_lateral_position = leg_lateral_position, leg_radius = leg_radius, leg_height = leg_height, foot_longitudinal_position = foot_longitudinal_position, foot_lateral_position = foot_lateral_position, foot_rotation = left_foot_rotation, foot_length = foot_length, foot_width = foot_width, foot_height = foot_height); mirror ([0, 1, 0]) { lateral_details (body_radius = body_radius, eye_vertical_position = eye_vertical_position, eye_azimuth = eye_azimuth, eye_length = eye_length, eye_width = eye_width, eye_height = eye_height, arm_vertical_position = arm_vertical_position, arm_azimuth = arm_azimuth, arm_radius = arm_radius, arm_length = arm_length, hand_longitudinal_position = hand_longitudinal_position, hand_vertical_position = hand_vertical_position, hand_rotation = right_hand_rotation, hand_radius = hand_radius, hand_thickness = hand_thickness, hand_length = hand_length, hand_height = hand_height, leg_longitudinal_position = leg_longitudinal_position, leg_lateral_position = leg_lateral_position, leg_radius = leg_radius, leg_height = leg_height, foot_longitudinal_position = foot_longitudinal_position, foot_lateral_position = foot_lateral_position, foot_rotation = right_foot_rotation, foot_length = foot_length, foot_width = foot_width, foot_height = foot_height); } difference () { translate (v = [0, 0, body_height + body_radius]) { antenna (shaft_radius = antenna_shaft_radius, shaft_height = antenna_shaft_height, tip_radius = antenna_tip_radius, tip_height = antenna_tip_height); } translate (v = [0, 0, body_height]) { sphere (r = body_radius); } } difference () { translate (v = [-body_radius, 0, key_vertical_position]) { rotate (a = key_rotation, v = [1, 0, 0]) { key (shaft_radius = key_shaft_radius, shaft_length = key_shaft_length, key_longitudinal_position = key_longitudinal_position, key_radius = key_radius, key_thickness = key_thickness, key_hole_radius = key_hole_radius); } } translate (v = [0, 0, key_vertical_position - 0.5 * key_shaft_radius]) { cylinder (r = body_radius, h = key_shaft_radius); } } } } } robot (body_radius = 10, body_height = 20, eye_vertical_position = 15, eye_azimuth = 20, eye_length = 1, eye_width = 3.3, eye_height = 5, arm_vertical_position = 10, arm_azimuth = 0, arm_radius = 2, arm_length = 2, hand_longitudinal_position = 3.5, hand_vertical_position = 0, left_hand_rotation = 30, right_hand_rotation = 30, hand_radius = 2.5, hand_thickness = 1, hand_length = 12.5, hand_height = 10, leg_longitudinal_position = -2.5, leg_lateral_position = 5, leg_radius = 2, leg_height = 5, foot_longitudinal_position = 2.5, foot_lateral_position = 0, left_foot_rotation = 5, right_foot_rotation = 5, foot_length = 17.5, foot_width = 7.5, foot_height = 1, antenna_shaft_radius = 1, antenna_shaft_height = 4, antenna_tip_radius = 2, antenna_tip_height = 2, key_vertical_position = 10, key_rotation = 30, key_shaft_radius = 1, key_shaft_length = 10, key_longitudinal_position = 1.5, key_radius = 4, key_thickness = 1, key_hole_radius = 2, $fn = 32);