Commit c356ecad authored by Jan Koniarik's avatar Jan Koniarik
Browse files

yaml -> scad/urdf generator for schpin project

parent e5a2129c
......@@ -20,6 +20,16 @@ module leg_pos(){
mirror(legs_fr_mirror)
children();
translate(legs_mr_pos)
rotate(legs_mr_rot)
mirror(legs_mr_mirror)
children();
translate(legs_ml_pos)
rotate(legs_ml_rot)
mirror(legs_ml_mirror)
children();
translate(legs_fl_pos)
rotate(legs_fl_rot)
mirror(legs_fl_mirror)
......
......@@ -3,7 +3,7 @@ strip_t = 2;
plate_t = 2;
t = 4;
strip_w = 20;
t = 4;
// rendered by script, do not edit manually!
rpi_offset = [-20,0,0];
rpi_holes_x = 58;
rpi_holes_y = 49;
coxa_arm = [0,12.5,-28.15];
rpi_screw_d = 2.5;
rpi_holes_y = 49;
rpi_holes_x = 58;
rpi_offset = [-20,0,0];
femur_arm = [0,40,0];
legs_fr_pos = [30,-25,0];
battery_dim = [80,12,35];
battery_offset = [-5,0,0];
legs_fr_rot = [0,0,-150];
legs_fr_pos = [40,-25,0];
legs_fr_mirror = [1,0,0];
legs_fr_rot = [0,0,-165];
legs_rr_pos = [-30,-25,0];
legs_rr_rot = [0,0,150];
legs_rr_pos = [-40,-25,0];
legs_rr_mirror = [0,0,0];
legs_rr_rot = [0,0,165];
legs_rl_pos = [-30,25,0];
legs_mr_rot = [0,0,180];
legs_mr_pos = [0,-30,0];
legs_mr_mirror = [1,0,0];
legs_rl_rot = [0,0,30];
legs_rl_pos = [-40,25,0];
legs_rl_mirror = [1,0,0];
legs_rl_rot = [0,0,15];
legs_fl_pos = [30,25,0];
legs_ml_rot = [0,0,0];
legs_ml_pos = [0,30,0];
legs_ml_mirror = [0,0,0];
legs_fl_rot = [0,0,-30];
legs_fl_pos = [40,25,0];
legs_fl_mirror = [0,0,0];
legs_fl_rot = [0,0,-15];
tibia_arm = [-5,50,0];
femur_arm = [0,40,0];
battery_offset = [-5,0,0];
battery_dim = [80,12,35];
coxa_arm = [0,12.5,-28.149999999999995];
// rendered by script, do not edit manually!
cam_base_pos = [9.0,0,25];
clearance = 10;
camera_holder_t = 3;
clearance = 10;
cam_screw_pos = [9.35,21.85];
cam_screw_h = 4;
cam_screw_d = 2;
yaw_rot = [0,0,180];
yaw_pos = [9.0,0.0,39.1];
horn_d2 = 2.5;
horn_d = 6;
horn_angle = -10;
horn_a = 6.5;
horn_d2 = 2.5;
horn_b = 12.5;
horn_angle = -10;
horn_d = 6;
pi_screw_d = 2.5;
pi_screw_distance = 49;
pi_y_offset = -2;
pitch_offset = [-12.5,-5.85,17.049999999999997];
camera_offset = [25,5.5,-21.5];
yaw_pos = [9.0,0,39.1];
yaw_rot = [0,0,180];
pitch_offset = [-12.5,-5.85,17.05];
t = 3;
camera_z_offset = -21.5;
camera_y_offset = 5.5;
camera_x_offset = 25;
cam_screw_h = 4;
cam_screw_d = 2;
cam_screw_pos = [9.35,21.85];
cam_base_pos = [9.0,0,25];
pi_screw_d = 2.5;
pi_screw_distance = 49.0;
pi_y_offset = -2;
......@@ -19,9 +19,9 @@ module holder() difference(){
hull(){
cylinder(d = horn_d + t*2, h=camera_holder_t);
for(pos=cam_screw_pos){
translate([camera_x_offset -t , pos + camera_z_offset, 0])
translate([camera_offset[0] -t , pos + camera_offset[2], 0])
cylinder(d = t*2, h=camera_holder_t);
translate([camera_x_offset - cam_screw_h, pos + camera_z_offset, -camera_y_offset])
translate([camera_offset[0] - cam_screw_h, pos + camera_offset[2], -camera_offset[1]])
rotate([0, 90, 0])
cylinder(d=cam_screw_d + t*2, h=cam_screw_h);
}
......@@ -29,14 +29,14 @@ module holder() difference(){
}
hull(){
for(x=[-100,camera_x_offset - t*2], z=[-t, -100])
for(x=[-100,camera_offset[0] - t*2], z=[-t, -100])
translate([x,0,z])
rotate([90, 0, 0])
cylinder(d=t*2, h=100, center=true);
}
for(pos=cam_screw_pos){
translate([camera_x_offset - t, pos + camera_z_offset, -camera_y_offset])
translate([camera_offset[0] - t, pos + camera_offset[2], -camera_offset[1]])
rotate([0, 90, 0])
cylinder(d=cam_screw_d, h=100, center=true);
}
......@@ -67,7 +67,7 @@ module holder_with_servo() translate([0, -10, 0]){
rotate([90, 0, 0])
color("gray")
holder();
translate([camera_x_offset, camera_y_offset , camera_z_offset])
translate(camera_offset)
translate([0.5, 10.5, 19])
rotate([90, 0, 90])
color("Green")
......
......@@ -97,10 +97,10 @@ module kinematics(d=3){
translate( pitch_offset ){
axis("pitch", [90, 0, 0]);
arm("pitch", [camera_x_offset, -pitch_offset[1], 0]);
arm("pitch", [camera_offset[0], -pitch_offset[1], 0]);
color("blue", 0.3)
translate([camera_x_offset, -pitch_offset[1], 0])
translate([camera_offset[0], -pitch_offset[1], 0])
rotate([0, 90, 0])
cylinder(d1=1, d2=20, h=40);
}
......@@ -149,9 +149,9 @@ module body(){
module model() {
kinematics();
//kinematics();
#union(){
union(){
body();
......@@ -173,4 +173,6 @@ kinematics();
}
}
\ No newline at end of file
}
model();
// rendered by script, do not edit manually!
servo_horn_h = 6;
servo_horn_d = 7.1;
servo_horn_b = 12.5;
servo_horn_a = 6.5;
servo_horn_t = 2;
servo_horn_b = 12.5;
servo_horn_d = 7.1;
servo_horn_h = 6;
servo_horn_d2 = 2.5;
servo_horn_t = 2;
mg90s_gimbal_vector = [-5.85,12.5,-17.049999999999997];
mg90s_turret_height = 5.2;
mg90s_turret_y_margin = 11.2;
mg90s_turret_diameter = 11.7;
mg90s_turret_x_margin = 0.40000000000000036;
mg90s_horn_offset = 11.1;
mg90s_servo_height = 22.9;
mg90s_servo_length = 22.9;
mg90s_gimbal_vector = [-5.85,12.5,-17.05];
mg90s_servo_width = 12.5;
mg90s_mounting_hole_diameter = 2;
mg90s_mounting_hole_center_x_offset = 12.5;
mg90s_mounting_hole_center_y_offset = 2.0;
mg90s_mounting_hole_slot = 1;
mg90s_frame_thickness = 2.45;
mg90s_servo_length = 22.9;
mg90s_servo_height = 22.9;
mg90s_turret_diameter = 11.7;
mg90s_turret_margin_y = 11.2;
mg90s_turret_margin_x = 0.4;
mg90s_turret_height = 5.2;
mg90s_frame_length = 32.2;
mg90s_frame_v_offset = 16;
mg90s_frame_thickness = 2.45;
mg90s_axle_diameter = 4.82;
mg90s_axle_height = 3.9;
mg90s_axle_screw_diameter = 2;
mg90s_axle_height = 3.9;
mg90s_mounting_hole_slot = 1;
mg90s_mounting_hole_diameter = 2;
mg90s_mounting_hole_center_offset_y = 2.0;
......@@ -19,15 +19,15 @@ module mg90s(centered=true) color("MediumBlue") {
frame_thickness = mg90s_frame_thickness,
frame_v_offset = mg90s_frame_v_offset,
mounting_hole_diameter = mg90s_mounting_hole_diameter,
mounting_hole_center_x_offset = mg90s_mounting_hole_center_x_offset,
mounting_hole_center_y_offset = mg90s_mounting_hole_center_y_offset,
mounting_hole_center_x_offset = mg90s_mounting_hole_center_offset_x,
mounting_hole_center_y_offset = mg90s_mounting_hole_center_offset_y,
mounting_hole_slot = mg90s_mounting_hole_slot,
axle_diameter = mg90s_axle_diameter,
axle_height = mg90s_axle_height,
axle_is_round = true,
turret_diameter = mg90s_turret_diameter,
turret_x_margin = mg90s_turret_x_margin,
turret_y_margin = mg90s_turret_y_margin,
turret_x_margin = mg90s_turret_margin_x,
turret_y_margin = mg90s_turret_margin_y,
turret_height = mg90s_turret_height,
centered=centered);
}
......
// rendered by script, do not edit manually!
t = 3;
h = 10;
k = 0.1;
screw_d = 3;
screw_offset = -25.599999999999998;
spacing = 1;
t = 3;
screw_d = 3;
screw_offset = -25.6;
mg90s = dict(
servo = dict(
width = 12.5,
length = 22.9,
height = 22.9
),
frame = dict(
length = 32.2,
thickness = 2.45,
v_offset = 16
),
mounting_hole = dict(
diameter = 2,
slot = 1
),
turret = dict(
diameter = 11.7,
height = 5.2
),
axle = dict(
height = 3.9,
diameter = 4.82,
screw_diameter = 2
),
)
servo_horn = dict(
t = 2,
h = 6,
d = 7.1, # body d
d2 = 2.5, # hole d
a = 6.5, # first hole offset
b = 12.5 # second hole offset
)
mg90s["mounting_hole"]["center_x_offset"] = mg90s['servo']["width"]
mg90s["mounting_hole"]["center_y_offset"] = mg90s["mounting_hole"]["slot"] + mg90s["mounting_hole"]["diameter"]/2
mg90s["turret"]['x_margin'] = (mg90s['servo']['width'] - mg90s['turret']['diameter'] )/2
mg90s['turret']['y_margin'] = mg90s['servo']['length'] - mg90s['turret']['diameter']
mg90s['horn_offset'] = mg90s['turret']['height'] + mg90s['axle']['height'] + servo_horn['t']
mg90s['gimbal_vector'] = [
-mg90s['turret']['diameter']/2,
mg90s['servo']['width'],
-(mg90s['servo']['length'] - mg90s['turret']['diameter']/2)
]
battery = dict(
offset = [-5,0,0],
dim = [80,12,35]
)
legs = dict(
fl = dict(
pos=[30,25,0],
rot=[0, 0, -15],
mirror=[0,0,0]
),
fr = dict(
pos=[30,-25,0],
rot=[0, 0, -165],
mirror=[1,0,0]
),
rl = dict(
pos=[-30,25,0],
rot=[0, 0, 15],
mirror=[1,0,0]
),
rr = dict(
pos=[-30,-25,0],
rot=[0, 0, 165],
mirror=[0,0,0]
),
)
rpi = dict(
holes = dict(
y=49,
x=58
),
offset = [-20,0,0],
screw_d = 2.5,
)
femur_arm = [0, 40, 0]
tibia_arm = [-5, 50, 0]
coxa_arm = [
0,
mg90s['servo']["width"],
-(mg90s['servo']["length"] - mg90s["turret"]["diameter"]/2 + mg90s["turret"]["height"] + mg90s["axle"]["height"] + servo_horn["t"])
]
gimbal = dict(
camera = dict(
x_offset = 25,
y_offset = 5.5,
z_offset = -21.5
),
horn = dict(
d = 6, # horn hole d
a = servo_horn['a'],
b = servo_horn['b'],
d2 = servo_horn['d2'],
angle = -10,
),
cam = dict(
screw = dict(
d = 2,
h = 4,
pos = [9.35, 21.85]
)
),
clearance = 10,
camera_holder_t = 3,
t = 3,
pi = dict(
screw_distance = rpi['holes']['y'],
screw_d = rpi['screw_d'],
y_offset = -2,
),
cam_base_pos = [rpi["offset"][0] + rpi["holes"]["x"]/2, 0, 25],
)
gimbal['yaw'] = dict(
pos = [
gimbal['cam_base_pos'][0],
gimbal['cam_base_pos'][1],
gimbal['cam_base_pos'][2] + mg90s['horn_offset'] + gimbal['t']
],
rot = [0,0,180]
)
gimbal['pitch_offset'] = [
mg90s['gimbal_vector'][1]*-1,
mg90s['gimbal_vector'][0],
mg90s['gimbal_vector'][2]*-1,
]
base_plate = dict(
t = 4,
strip_t = 2,
strip_w = 20,
plate_t = 2
)
strengthen = dict(
t = 3,
screw_d = 3,
screw_offset = - mg90s['servo']['height'] - mg90s['mounting_hole']['center_y_offset'] - 0.7,
k = 0.1,
spacing = 1,
h = 10,
)
mg90s:
servo:
width: 12.5
length: 22.9
height: 22.9
frame:
length: 32.2
thickness: 2.45
v_offset: 16
mounting_hole:
diameter: 2
slot: 1
center_offset:
x: "% mg90s.servo.width/2 %"
y: "% mg90s.mounting_hole.slot + mg90s.mounting_hole.diameter / 2 %"
axle:
height: 3.9
diameter: 4.82
screw_diameter: 2
turret:
margin:
x: "% (mg90s.servo.width - mg90s.turret.diameter) / 2 %"
y: "% mg90s.servo.length - mg90s.turret.diameter %"
height: 5.2
diameter: 11.7
horn_offset: "% mg90s.turret.height + mg90s.axle.height + servo_horn.t %"
gimbal_vector:
- "% -mg90s.turret.diameter / 2 %"
- "% mg90s.servo.width %"
- "% -(mg90s.servo.length - mg90s.turret.diameter /2 ) %"
servo_horn:
t: 2 # thickness
h: 6 # height
d: 7.1 # body d
d2: 2.5 # hole d
a: 6.5 # first hole offset
b: 12.5 # second hole offset
battery:
offset: [-5,0,0]
dim: [80,12,35]
legs:
fl:
pos: [40, 25, 0]
rot: [0,0,-30]
mirror: [0,0,0]
fr:
pos: [40, -25, 0]
rot: [0,0,-150]
mirror: [1,0,0]
ml:
pos: [0, 30, 0]
rot: [0,0,0]
mirror: [0,0,0]
mr:
pos: [0, -30, 0]
rot: [0,0,180]
mirror: [1,0,0]
rl:
pos: [-40, 25, 0]
rot: [0,0,30]
mirror: [1,0,0]
rr:
pos: [-40, -25, 0]
rot: [0,0,150]
mirror: [0,0,0]
rpi:
holes:
y: 49
x: 58
offset: [-20, 0, 0]
screw_d: 2.5
femur_arm: [0, 40, 0]
tibia_arm: [-5, 50, 0]
coxa_arm:
- 0
- "% mg90s.servo.width %"
- "% -( mg90s.servo.length - mg90s.turret.diameter / 2 + mg90s.turret.height + mg90s.axle.height + servo_horn.t ) %"
gimbal:
camera:
offset: [25, 5.5, -21.5]
horn:
d: 6
a: "% servo_horn.a %"
b: "% servo_horn.b %"
d2: "% servo_horn.d2 %"
angle: -10
cam:
screw:
d: 2
h: 4
pos: [9.35, 21.85]
base_pos:
- "% rpi.offset.0 + rpi.holes.x / 2 %"
- 0
- 25
clearance: 10
camera_holder_t: 3
t: 3
pi:
screw_distance: "% rpi.holes.y %"
screw_d: "% rpi.screw_d %"
y_offset: -2
yaw:
pos:
- "% gimbal.cam.base_pos.0 %"
- "% gimbal.cam.base_pos.1 %"
- "% gimbal.cam.base_pos.2 + mg90s.horn_offset + gimbal.t %"
rot: [0, 0, 180]
pitch_offset:
- "% -mg90s.gimbal_vector.1 %"
- "% mg90s.gimbal_vector.0 %"
- "% -mg90s.gimbal_vector.2 %"
base_plate:
t: 4
strip_t: 2
strip_w: 20
plate_t: 2
strengthen:
t: 3
screw_d: 3
screw_offset: "% -mg90s.servo.height - mg90s.mounting_hole.center_offset.y - 0.7 %"
k: 0.1
spacing: 1
h: 10
import yaml
import re
def _recur_scad_config(fd, base, variables):
if isinstance(variables, dict):
for key, item in variables.items():
if base == "":
newbase = key
else:
newbase = base + "_" + key
_recur_scad_config(fd, newbase, item)
if base == "":
fd.write("\n")
elif isinstance(variables, (list, tuple)):
fd.write(
"{} = [{}];\n".format(base, ",".join(str(x) for x in variables)))
elif isinstance(variables, (int, float)):
fd.write("{} = {};\n".format(base, variables))
else:
raise Exception("unknown data", variables)
def generate_scad_config(filename, variables):
print("generating scad file: " + filename)
with open(filename, "w") as fd:
fd.write("// rendered by script, do not edit manually!\n")
_recur_scad_config(fd, "", variables)
def check_stl(filename, module):
assert filename[-1] ==