2017-02-05 18:18:36 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2013-2016 Florian Festi
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
from boxes import *
|
|
|
|
from boxes import edges
|
|
|
|
|
|
|
|
class LegEdge(edges.BaseEdge):
|
|
|
|
|
|
|
|
def __call__(self, l, **kw):
|
|
|
|
d0 = (l - 12.0) /2
|
|
|
|
self.hole(l/2, 6, 3.0)
|
|
|
|
self.polyline(d0, 90, 0, (-180, 6), 0, 90, d0)
|
|
|
|
|
|
|
|
class OttoLegs(Boxes):
|
|
|
|
"""Otto LC - a laser cut chassis for Otto DIY - legs"""
|
|
|
|
|
|
|
|
ui_group = "Unstable"
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
|
|
|
|
2017-03-05 16:08:11 +01:00
|
|
|
self.addSettingsArgs(edges.FingerJointSettings, finger=1.0, space=1.0,
|
|
|
|
surroundingspaces=1.0)
|
2017-03-11 17:10:45 +01:00
|
|
|
self.argparser.add_argument(
|
2017-08-11 18:44:34 +02:00
|
|
|
"--anklebolt1", action="store", type=float, default=3.0,
|
2017-03-12 14:47:21 +01:00
|
|
|
help="diameter for hole for ankle bolts - foot side")
|
|
|
|
self.argparser.add_argument(
|
2017-08-11 18:44:34 +02:00
|
|
|
"--anklebolt2", action="store", type=float, default=2.6,
|
2017-03-12 14:47:21 +01:00
|
|
|
help="diameter for hole for ankle bolts - leg side")
|
2017-08-01 21:17:35 +02:00
|
|
|
self.argparser.add_argument(
|
|
|
|
"--length", action="store", type=float, default=37.0,
|
|
|
|
help="length of feet (34mm min)")
|
2017-02-05 18:18:36 +01:00
|
|
|
|
|
|
|
def foot(self, x, y, ly, l, r=5., move=None):
|
|
|
|
if self.move(x, y, move, True):
|
|
|
|
return
|
|
|
|
|
|
|
|
t = self.thickness
|
|
|
|
w = ly + 5.5 + 2 * t
|
|
|
|
self.fingerHolesAt(x/2 - w/2, 0, l, 90)
|
|
|
|
self.fingerHolesAt(x/2 + w/2, 0, l, 90)
|
|
|
|
self.moveTo(r, 0)
|
|
|
|
|
|
|
|
for l in (x, y, x, y):
|
|
|
|
self.polyline(l - 2*r, 45, r*2**0.5, 45)
|
|
|
|
|
|
|
|
self.move(x, y, move)
|
|
|
|
|
2017-08-12 00:07:34 +02:00
|
|
|
def ankles(self, x, h, edge="f", callback=None, move=None):
|
2017-08-03 23:00:20 +02:00
|
|
|
|
|
|
|
f = 0.5
|
|
|
|
tw = x
|
|
|
|
th = 2 * h + self.thickness
|
|
|
|
|
|
|
|
if self.move(tw, th, move, True):
|
|
|
|
return
|
|
|
|
|
|
|
|
self.moveTo(0, self.thickness)
|
|
|
|
for i in range(2):
|
|
|
|
self.cc(callback, 0)
|
2017-08-12 00:07:34 +02:00
|
|
|
self.edges[edge](x)
|
2017-08-03 23:00:20 +02:00
|
|
|
self.polyline(0, 90)
|
|
|
|
self.cc(callback, 1)
|
|
|
|
self.polyline(h, 90, f*x, 45, (2**0.5)*(1-f)*x, 45, h-(1-f)*x, 90)
|
|
|
|
self.moveTo(tw, th, 180)
|
2017-08-03 23:19:32 +02:00
|
|
|
self.ctx.stroke()
|
2017-08-03 23:00:20 +02:00
|
|
|
self.move(tw, th, move)
|
|
|
|
|
2017-02-05 18:18:36 +01:00
|
|
|
def ankle1(self):
|
|
|
|
# from vertical edge
|
2017-08-12 00:07:34 +02:00
|
|
|
self.hole(15, 10, 3.45) # 3.45 for servo arm, 2.3 for knob
|
|
|
|
|
2017-08-19 22:14:30 +02:00
|
|
|
def servoring(self, move=""):
|
|
|
|
if self.move(20, 20, move, True):
|
|
|
|
return
|
|
|
|
self.moveTo(10, 10, 90)
|
2017-08-12 00:07:34 +02:00
|
|
|
self.moveTo(3.45, 0, -90)
|
2017-08-19 22:14:30 +02:00
|
|
|
self.polyline(0, (-264, 3.45), 0, 36, 6.55, 108, 0, (330, 9.0), 0, 108, 6.55)
|
|
|
|
self.move(20, 20, move)
|
2017-02-05 18:18:36 +01:00
|
|
|
|
2017-08-19 22:14:30 +02:00
|
|
|
|
2017-02-05 18:18:36 +01:00
|
|
|
def ankle2(self):
|
|
|
|
# from vertical edge
|
2017-03-12 14:47:21 +01:00
|
|
|
self.hole(15, 10, self.anklebolt1/2)
|
2017-02-05 18:18:36 +01:00
|
|
|
|
|
|
|
def servoHole(self):
|
|
|
|
self.hole(6, 6, 11.6/2)
|
|
|
|
self.hole(6, 12, 5.5/2)
|
|
|
|
|
|
|
|
def render(self):
|
|
|
|
# adjust to the variables you want in the local scope
|
|
|
|
t = self.thickness
|
|
|
|
# Initialize canvas
|
|
|
|
self.open()
|
|
|
|
|
2017-08-01 21:17:35 +02:00
|
|
|
ws = 25
|
|
|
|
lx, ly, lh = 12.4, 23.5, max(self.length, ws+6+t)
|
2017-02-05 18:18:36 +01:00
|
|
|
|
|
|
|
self.ctx.save()
|
|
|
|
# Legs
|
|
|
|
|
2017-02-08 23:38:17 +01:00
|
|
|
c1 = edges.CompoundEdge(self, "FE", (ly-7.0, 7.0))
|
2017-03-11 20:14:29 +01:00
|
|
|
c2 = edges.CompoundEdge(self, "EF", (7.0, lh-7.0))
|
2017-02-08 23:38:17 +01:00
|
|
|
e = [c1, c2, "F", "F"]
|
2017-02-14 19:44:03 +01:00
|
|
|
|
|
|
|
for i in range(2):
|
2017-03-05 16:08:11 +01:00
|
|
|
# front
|
2017-03-11 20:14:29 +01:00
|
|
|
self.rectangularWall(lx, lh-7., [LegEdge(self, None), "f", "F", "f"], callback=[None, lambda:self.fingerHolesAt(ws-7., 0, lx)], move="right")
|
2017-03-05 16:08:11 +01:00
|
|
|
# back
|
2017-02-14 19:44:03 +01:00
|
|
|
self.rectangularWall(lx, lh, "FfFf", callback=[
|
2017-03-12 14:47:21 +01:00
|
|
|
lambda:self.hole(lx/2, 7, self.anklebolt2/2)], move="right")
|
2017-03-05 16:08:11 +01:00
|
|
|
# sides
|
|
|
|
self.rectangularWall(ly, lh, e, callback=[None,
|
2017-08-07 17:03:57 +02:00
|
|
|
lambda:self.fingerHolesAt(ws, 7.0, ly-7.0-3.0)], move="right")
|
2017-02-14 19:44:03 +01:00
|
|
|
self.rectangularWall(ly, lh, e, callback=[
|
2017-08-01 21:17:35 +02:00
|
|
|
lambda:self.rectangularHole(ly/2, ws+3+0.5*t, 12, 6, 3),
|
2017-08-07 17:03:57 +02:00
|
|
|
lambda:self.fingerHolesAt(ws, 7.0, ly-7.0-3.0)], move="right")
|
2017-02-14 19:44:03 +01:00
|
|
|
|
2017-03-05 16:08:11 +01:00
|
|
|
# top
|
2017-08-11 17:46:50 +02:00
|
|
|
self.partsMatrix(2, 1, "right", self.rectangularWall, ly, lx, "ffff",
|
|
|
|
callback=[None, lambda: self.hole(lx/2, ly/2, 2.3)])
|
|
|
|
self.partsMatrix(2, 1, "right", self.rectangularWall, lx, ly, "eeee", callback=[lambda: self.hole(lx/2, ly/2, 1.5)])
|
2017-03-05 16:08:11 +01:00
|
|
|
# hold servo at the front
|
2017-08-11 17:46:50 +02:00
|
|
|
self.partsMatrix(2, 1, "right", self.rectangularWall, 4.6, lx, "efee")
|
2017-08-07 17:03:57 +02:00
|
|
|
# bottom
|
2017-08-11 17:46:50 +02:00
|
|
|
self.partsMatrix(2, 1, "right", self.rectangularWall, lx, ly-7.0, "efff")
|
2017-03-05 16:08:11 +01:00
|
|
|
# hold servo inside
|
2017-08-07 17:03:57 +02:00
|
|
|
self.partsMatrix(2, 1, "right", self.rectangularWall, lx, ly-7.0-3.0, "efef")
|
2017-03-05 16:08:11 +01:00
|
|
|
|
2017-02-05 18:18:36 +01:00
|
|
|
self.ctx.restore()
|
|
|
|
self.rectangularWall(lx, lh, "ffff", move="up only")
|
|
|
|
|
|
|
|
# feet
|
|
|
|
self.foot(60, 40, ly, 30, move="right")
|
|
|
|
self.foot(60, 40, ly, 30, move="right")
|
2017-08-19 22:14:30 +02:00
|
|
|
self.ankles(30, 25, callback=[None, self.ankle1], move="right")
|
|
|
|
self.ankles(30, 25, callback=[None, self.ankle2], move="right")
|
|
|
|
self.partsMatrix(2, 2, "right", self.servoring)
|
2017-02-05 18:18:36 +01:00
|
|
|
self.close()
|
|
|
|
|