diff --git a/rocolib/api/composables/GraphComposable.py b/rocolib/api/composables/GraphComposable.py index e7d79e401da6d62bcf76f8f3a97b709d29b72836..b54783dfbd23eb360aad7b0bea3541fe410d52ff 100644 --- a/rocolib/api/composables/GraphComposable.py +++ b/rocolib/api/composables/GraphComposable.py @@ -92,17 +92,23 @@ class GraphComposable(Composable, BaseGraph): handle("silhouette", "Silhouette cut-and-fold", d.toDXF, "silhouette.dxf", mode="silhouette") handle("autofolding", "autofolding", d.toDXF, "autofold-default.dxf", mode="autofold") handle("autofolding", " -- (graph)", d.toDXF, "autofold-graph.dxf") - handle("stl", "3D", self.toSTL, "model.stl", **kwargs) + handle("stl", "stl", self.to3D, "model.stl", format="stl", **kwargs) + handle("webots", "webots", self.to3D, "model.wbo", format="webots", **kwargs) + if kw("display3D", False) or kw("png"): from rocolib.utils.display import display3D if basename: if kw("stl"): - stl_handle = open(basename+"model.stl", 'rb') + try: + stl_handle = open(basename+"model.stl", 'rb') + except: + log.info("No Stl found") + return else: log.info("STL wasn't selected, making now...") - handle("png", "3D", self.toSTL, None, **kwargs) + handle("png", "stl", self.to3D, None, format="stl") stl_handle = bufs['png'] stl_handle.seek(0) if kw("png"): diff --git a/rocolib/api/composables/graph/Graph.py b/rocolib/api/composables/graph/Graph.py index 46dafa9dee591a9f348754930893ae94b37e2b53..00c202611d03ae5565d267d1ccdf078485170db3 100644 --- a/rocolib/api/composables/graph/Graph.py +++ b/rocolib/api/composables/graph/Graph.py @@ -2,7 +2,9 @@ import logging from rocolib.api.composables.graph.HyperEdge import HyperEdge from rocolib.utils.utils import prefix as prefixString +from rocolib.utils.roco2sim.Node import ShapeNode import rocolib.utils.numsym as np +from rocolib.utils.roco2sim.format_3d import format_wrl log = logging.getLogger(__name__) @@ -23,54 +25,78 @@ def inflate(face, thickness=.1, edges=False): return faces -def STLWrite(faces, fp, **kwargs): - scale = .001 # roco units : mm ; STL units m - from .stlwriter import ASCII_STL_Writer as STL_Writer +def _triangulate(faces, **kwargs): + """Create triangulated faces in 3D space with thickness""" + scale = .001 # roco units : mm ; STL units m import triangle + import numpy as np + + triangles_coord_index = [] + triangles_facet_normal = [] + facets_index = np.empty([1, 3]) + B_add = 0 + k = 0 # index initiated - shells = [] - triangles = [] for i, f in enumerate(faces): - r = f[0] - A = f[1] + r = f[0] # coord transformation matrix + A = f[1] # vertices info + + facets_coord_index = [] + facets_normal = [] facets = [] B = triangle.triangulate(A, opts='p') + if not 'triangles' in B: log.warning("No triangles in " + f[2]) continue thickness = "thickness" in kwargs and kwargs["thickness"] if thickness: - for t in [np.transpose(np.array([list(B['vertices'][x]) + [0,1] for x in (face[0], face[1], face[2])])) for face in B['triangles']]: - facets.extend([np.dot(r, x) * scale for x in inflate(t, thickness=thickness)]) - for t in [np.transpose(np.array([list(A['vertices'][x]) + [0,1] for x in (edge[0], edge[1])])) for edge in A['segments']]: - facets.extend([np.dot(r, x) * scale for x in inflate(t, thickness=thickness, edges=True)]) + for t in [np.transpose(np.array([list(B['vertices'][x]) + [0, 1] for x in (face[0], face[1], face[2])])) for + face in B['triangles']]: + for x in inflate(t, thickness=thickness): + facets_coord_index.extend(np.transpose(np.dot(r, x) * scale)) + facets_normal.extend(np.transpose(np.dot(r, x) * scale)) + index_current = [[k, k + 1, k + 2]] + k = k + 3 + facets_index = np.concatenate((facets_index, index_current), 0) + for t in [np.transpose(np.array([list(A['vertices'][x]) + [0, 1] for x in (edge[0], edge[1])])) for edge in + A['segments']]: + for x in inflate(t, thickness=thickness, edges=True): + facets_coord_index.extend(np.transpose(np.dot(r, x) * scale)) + facets_normal.extend(np.transpose(np.dot(r, x) * scale)) + index_current = [[k, k + 1, k + 2]] + k = k + 3 + facets_index = np.concatenate((facets_index, index_current), 0) else: - for t in [np.transpose(np.array([list(B['vertices'][x]) + [0,1] for x in (face[0], face[1], face[2])])) for face in B['triangles']]: + for t in [np.transpose(np.array([list(B['vertices'][x]) + [0, 1] for x in (face[0], face[1], face[2])])) for + face in B['triangles']]: facets.append(np.dot(r, t) * scale) + facets_coord_index.extend(np.transpose(np.dot(r, t)) * scale) + facets_normal.extend(np.transpose(np.dot(r, t)) * scale) + #B_triangle = B['triangles'] + B_add + #B_add = np.amax(B_triangle) + 1 + index_current = [[k, k + 1, k + 2]] + k = k + 3 + facets_index = np.concatenate((facets_index, index_current), 0) + + + triangles_coord_index.extend(facets_coord_index) + triangles_facet_normal.extend(facets_normal) + + facets_index_return = np.delete(facets_index, 0, 0) + + return format_wrl(triangles_coord_index, triangles_facet_normal, facets_index_return) - triangles.extend(facets) - ''' - # Output each face to its own STL file - if filename: - with open(filename.replace(".stl", "_%02d.stl" % i), 'wb') as fp: - writer = STL_Writer(fp) - writer.add_faces(facets) - writer.close() - ''' - - faces = triangles - writer = STL_Writer(fp) - writer.add_faces(faces) - writer.close() class Graph(): def __init__(self): self.faces = [] self.facelists = [] self.edges = [] + self.shapeNodes=None def addFace(self, f, prefix=None, root=False, faceEdges=None, faceAngles=None, faceFlips=None): if prefix: @@ -303,15 +329,41 @@ class Graph(): e.pts2D = None e.pts3D = None - def toSTL(self, fp, **kwargs): + def toShapeNodes(self, **kwargs): + """Create a shape node list""" self.place() - stlFaces = [] - for face in self.faces: - if face.area > 0: - stlFaces.append([face.transform3D, face.getTriangleDict(), face.name]) - else: - log.info(f"Omitting face {face.name} with area {face.area} from STL") - return STLWrite(stlFaces, fp, **kwargs) + shapeNodes = [] + for i, facesInFacelists in enumerate(self.facelists): + faces = [] + for f in facesInFacelists: + if f.area > 0: + faces.append([f.transform3D, f.getTriangleDict(), f.name]) + else: + log.info(f"Omitting face {f.name} with area {f.area} from wbo") + # Crate 1 shape node per set of faces. + wrl = _triangulate(faces, **kwargs) + shapeNodes.append(ShapeNode(f.name, wrl, f.transform3D)) + + self.shapeNodes = shapeNodes + + def to3D(self, fp, **kwargs): + """stl or webots expects fp instance from handle. if None, not creating it""" + if self.shapeNodes is None: + self.toShapeNodes(**kwargs) + + if kwargs.get('format') == 'stl': + f = [] + for sn in self.shapeNodes: + f.extend(sn.getSTL().face) + from .stlwriter import ASCII_STL_Writer as STL_Writer + writer = STL_Writer(fp) + writer.add_faces(f) + writer.close() + + if kwargs.get('format') == 'webots': + from rocolib.utils.roco2sim.wbo_nodes import wboConverter + fp.write(wboConverter(self.shapeNodes)) + ''' @staticmethod diff --git a/rocolib/builders/CentipedeBuilder.py b/rocolib/builders/CentipedeBuilder.py index 5e275f2ec9d2d13fcd7b4af9e517bf7e9be5310c..3e50c2a9a66204302d8301091355290ee3a3411a 100644 --- a/rocolib/builders/CentipedeBuilder.py +++ b/rocolib/builders/CentipedeBuilder.py @@ -2,97 +2,77 @@ from rocolib.api.components.Component import Component c = Component() -#NEEDS CLEANING +#NEEDS CLEANING - NOT YET COMPLETE + #Don't change n yet, haven't figured out how to make it n-wheeled #8-Wheeled Pivot Car -n = 3 #(number of wheels - 1)/2 -c.addParameter("length", 76, paramType="length", minValue=76) #tested minValue -c.addParameter("height", 36, paramType="length", minValue=36) #tested minValue -c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue - -for i in range(n - 1): - c.addSubcomponent("front%d" %i, "HalfCar") - c.addConstraint(("front%d" %i, "length"), "length") - c.addConstraint(("front%d" %i, "height"), "height") - c.addConstraint(("front%d" %i, "width"), "width") - c.addSubcomponent("middle%d" %i, "HalfCar") - c.addConstraint(("middle%d" %i, "length"), "length") - c.addConstraint(("middle%d" %i, "height"), "height") - c.addConstraint(("middle%d" %i, "width"), "width") - -#Main component of steering wheel car which makes them moveable: trapezoid that connects the two half of the car -for i in range(4 * n): - c.addSubcomponent("midsupport%d" %i, "Trapezoid") - c.addConstraint(("midsupport%d" %i, "width"), "width", "x-10") - c.addConstraint(("midsupport%d" %i, "depth"), "width", "x-37") - c.addConstraint(("midsupport%d" %i, "bangle"), "width", - "float(np.atan((x-37)/5)* 180 * 0.318309)") - -c.addConnection(("middle1", "rect4.l"), ("midsupport0", "botedge")) -c.addConnection(("middle1", "rect4.r"), ("midsupport1", "botedge")) -c.addConnection(("front1", "rect4.l"), ("midsupport2", "botedge")) - -c.addConnection(("middle1", "rect3.r"), ("midsupport3", "botedge")) -c.addConnection(("middle1", "rect3.l"), ("midsupport4", "botedge")) -c.addConnection(("front1", "rect3.l"), ("midsupport5", "botedge")) - -c.addConnection(("middle0", "rect4.l"), ("midsupport6", "botedge")) -c.addConnection(("middle0", "rect4.r"), ("midsupport7", "botedge")) -c.addConnection(("front0", "rect4.l"), ("midsupport8", "botedge")) - -c.addConnection(("middle0", "rect3.r"), ("midsupport9", "botedge")) -c.addConnection(("middle0", "rect3.l"), ("midsupport10", "botedge")) -c.addConnection(("front0", "rect3.l"), ("midsupport11", "botedge")) - -c.addConnection(("midsupport4", "topedge"), ("midsupport5", "topedge")) -c.addConnection(("midsupport10", "topedge"), ("midsupport11", "topedge")) -c.addConnection(("midsupport9", "topedge"), ("midsupport3", "topedge")) - -#Putting the brains in front component of the car +n = 5 #(# of wheels/2) +#Add brain and wheels parameter (Default: Adafruit ESP32 2 Stacks) c.addParameter("brains", "esp32stack", paramType="dimension") c.addParameter("driveservo", "fs90r", paramType="dimension") -for i in range(2): - c.addSubcomponent("split%d" %i, "SplitEdge") - c.addConstraint(("split%d" % i, "toplength"), "length", '(x,)') - c.addConstraint(("split%d" % i, "botlength"), ("length", "height"), - '(x[1], x[0]-x[1])') - c.addSubcomponent("holder%d" %i, "ESP32Stack") - c.addConstraint(("holder%d" %i, "length"), "width") - c.addConstraint(("holder%d" %i, "heightChanger"), ("brains", "height"), ("x[1] - getDim(x[0], 'height')")) - c.addConstraint(("holder%d" %i, "length"), "width") - -c.addConnection(("front0", "rect3.t"), ("split0", "topedge0")) -c.addConnection(("front1", "rect3.t"), ("split1", "topedge0")) +#The height will always match the height of the brains +c.addParameter("length", 80, paramType="length", minValue=80) #tested minValue +c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue +c.addParameter("steerangle", 3.14, paramType="length") #Change this to change direction of car -c.addConnection(("holder0", "rect2.t"), ("front0", "rect2.r"), angle=-90) -c.addConnection(("holder1", "rect2.t"), ("front1", "rect2.r"), angle=-90) +for i in range(n): + c.addSubcomponent("car%d" % i, "HalfCar") + c.addConstraint(("car%d" % i, "length"), ("length", "driveservo", "brains"), "(x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')" + "- getDim(x[2], 'width')))") + c.addConstraint(("car%d" % i, "height"), "brains", '(getDim(x, "height"))') + c.addConstraint(("car%d" % i, "width"), "width") -#Putting servo hinge between cars -for i in range(3): - c.addSubcomponent("hinge%d" %i, "HingeServo") - c.addConstraint(("hinge%d" % i, "length"), "length") - c.addConstraint(("hinge%d" % i, "width"), "width") - c.addSubcomponent("hingeSplit%d" %i, "SplitEdge") - c.addConstraint(("hingeSplit%d" %i, "toplength"), "height", '(x,)') - c.addConstraint(("hingeSplit%d" %i, "botlength"), ("height", "driveservo"), - '((x[0]-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), ' - '(x[0]-getDim(x[1], "motorheight"))/2)') +#Putting the brains in front component of the car (Default: 1 Brain on car0) +c.addSubcomponent("holder", "ESP32Stack") +c.addConstraint(("holder", "length"), "width") -c.addSubcomponent("rectAssist", "Rectangle") -c.addConstraint(("rectAssist", "l"), "driveservo", 'getDim(x, "motorheight")') -c.addConstraint(("rectAssist", "w"), "length") +c.addSubcomponent("holdersplit", "SplitEdge") +c.addConstraint(("holdersplit", "toplength"), "brains", '(getDim(x, "height"),)') +c.addConstraint(("holdersplit", "botlength"), + ("driveservo", "brains"), + "(getDim(x[0], 'motorwidth'), getDim(x[1], 'height') - getDim(x[0], 'motorwidth'))") -c.addConnection(("front0", "rect1.r"), ("hingeSplit0", "topedge0")) -c.addConnection(("hingeSplit0", "botedge1"), ("hinge0", "belt2.r"), angle=-90) +c.addConnection(("holdersplit", "topedge0"), ("holder", "cover.topedge1")) +c.addConnection(("car0", "bright.topedge0"), ("holdersplit", "botedge0"), angle=-90) -c.addConnection(("middle1", "rect1.r"), ("hingeSplit1", "topedge0")) -c.addConnection(("hingeSplit1", "botedge1"), ("hinge1", "belt2.r"), angle=-90) - -c.addConnection(("middle0", "rect2.r"), ("hingeSplit2", "topedge0")) -c.addConnection(("hingeSplit2", "botedge1"), ("rectAssist", "t"), angle=-180) -c.addConnection(("rectAssist", "b"), ("hinge2", "belt0.r"), angle=90) +#Putting servo hinge between cars +for i in range(n): + c.addSubcomponent("hinge%d" %i, "Pivot", inherit="servo.angle") + c.addConstraint(("hinge%d" %i, "length"), "length") + c.addConstraint(("hinge%d" %i, "width"), "width") + c.addSubcomponent("hingeSplit%d" %i, "SplitEdge") + c.addConstraint(("hingeSplit%d" %i, "toplength"), "brains", '(getDim(x, "height"), )') + c.addConstraint(("hingeSplit%d" %i, "botlength"), ("brains", "driveservo"), + '((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), ' + '(getDim(x[0], "height")-getDim(x[1], "motorheight"))/2)') + c.addConnection(("car%d" %i, "rect2.l"), ("hingeSplit%d" %i, "topedge0")) + c.addConnection(("hingeSplit%d" %i, "botedge1"), ("hinge%d" %i, "belt2.r"), angle=-90) + +#Attach hinge on face of Trapezoid to move in Webots +#Main component of steering wheel car which makes them moveable: trapezoid that connects the two half of the car +for i in range(((n - 1) * 4)): + c.addSubcomponent("midsupport%d" % i, "Trapezoid") + c.addConstraint(("midsupport%d" % i, "width"), "width", "x-(2*x*.15)") + c.addConstraint(("midsupport%d" % i, "depth"), "driveservo", "getDim(x, 'motorlength')") + c.addConstraint(("midsupport%d" % i, "bangle"), ("width", "driveservo"), + "float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309)") + +w = 0 +for j in range(1, (n-1), 1): + for i in range(w, j * 4, 4): + c.addConstraint(("hinge%d" % (j + 1), "servo.angle"), "steerangle") + c.addConnection(("car%d" %j, "rect4.l"), ("midsupport%d" % i, "botedge")) + c.addConnection(("car%d" % j, "rect4.r"), ("midsupport%d" % (i+1), "botedge")) + c.addConnection(("car%d" % j, "rect3.l"), ("midsupport%d" % (i+2), "botedge")) + c.addConnection(("car%d" % j, "rect3.r"), ("midsupport%d" % (i+3), "botedge")) + w += 4 + +for j in range(0, n, n-1): + for i in range(w, w + 2, 2): + c.addConnection(("car%d" %j, "rect3.r"), ("midsupport%d" % i, "botedge")) + c.addConnection(("car%d" % j, "rect4.r"), ("midsupport%d" % (i+1), "botedge")) + w += 2 -# c.addConnection(("hinge0", "servo.mount"), ("midsupport4", "face0")) c.toLibrary("Centipede") diff --git a/rocolib/builders/ESP32StackBuilder.py b/rocolib/builders/ESP32StackBuilder.py index 7ca9efdd54f62b404b391392e6b40c1c5ceb59fa..77f8745a9f172d16375ddb6567b1490358d7da56 100644 --- a/rocolib/builders/ESP32StackBuilder.py +++ b/rocolib/builders/ESP32StackBuilder.py @@ -1,6 +1,8 @@ from rocolib.api.components.Component import Component from rocolib.api.Function import Function +#TODO: Change the Holder to a RectBeam + # ESP32 STACK HOLDER specify in dimensions.py if different number of stacks # This is for 3 stacks c = Component() @@ -10,22 +12,10 @@ c.addParameter("brains", "esp32stack", paramType="dimension") #change in dimensi c.addParameter("heightChanger", 0, paramType="length") #Cover/body of the car (I needed one that folds -90; will try on SimpleRectBeam) -for i in range(3): - if i % 2 == 0: - c.addSubcomponent("rect%d" %i, "Rectangle") - c.addConstraint(("rect%d" %i, "l"), ("brains", "heightChanger"), "getDim(x[0], 'height') + x[1]") - c.addConstraint(("rect%d" %i, "w"), "length") - -for i in range(3, 5): - c.addSubcomponent("rect%d" %i, "Rectangle") - c.addConstraint(("rect%d" %i, "l"), "brains", "getDim(x, 'width')") - c.addConstraint(("rect%d" %i, "w"), "length") - -#TODO: ADD TABS FOR ATTACHMENT -# c.addConnection(("rect2", "b"), ("rect3", "t"), angle=90) -c.addConnection(("rect3", "r"), ("rect0", "r"), angle=-90) -c.addConnection(("rect2", "r"), ("rect4", "r"), angle=-90) -c.addConnection(("rect4", "l"), ("rect0", "l"), angle=-90) +c.addSubcomponent("cover", "SimpleRectBeam") +c.addConstraint(("cover", "length"), "length") +c.addConstraint(("cover", "width"), "brains", '(getDim(x, "width"))') +c.addConstraint(("cover", "depth"), "brains", '(getDim(x, "height"))') # Putting the pins of the ESP32 Stack c.addSubcomponent("header", "Header") @@ -34,11 +24,11 @@ c.addConstraint(("header", "ncols"), "brains", "getDim(x, 'ncols')") c.addConstraint(("header", "rowsep"), "brains", "getDim(x, 'rowsep')") c.addConstraint(("header", "colsep"), "brains", "getDim(x, 'colsep')") -c.addConnection(("rect4", "face"), +c.addConnection(("cover", "face0"), ("header", "decoration"), mode="hole", offset=Function(params=("length", "brains"), fnstring="(0, 0)")) -c.addConnection(("rect3", "face"), +c.addConnection(("cover", "face2"), ("header", "decoration"), mode="hole", offset=Function(params=("length", "brains"), fnstring="(0, 0)")) @@ -50,20 +40,16 @@ for i in range(2): c.addConstraint(("accessoryHole%d" %i, "dy"), "brains", "getDim(x, 'height')/1.75") c.addConstraint(("accessoryHole%d" %i, "dx"), "dy", "x-3") -c.addConnection(("rect2", "face"), +c.addConnection(("cover", "face1"), ("accessoryHole0", "decoration"), mode="hole", rotate=True, offset=Function(params=("brains", "length"), fnstring="(getDim(x[0], 'height') * 0.15, x[1] * 0.25)")) -c.addConnection(("rect0", "face"), +c.addConnection(("cover", "face3"), ("accessoryHole1", "decoration"), mode="hole", rotate=True, - offset=Function(params=("brains", "length"), fnstring="(getDim(x[0], 'height') * 0.15, -x[1] * 0.25)")) + offset=Function(params=("brains", "length"), fnstring="(getDim(x[0], 'height') * -0.15, -x[1] * 0.25)")) -for i in range(5): - if i == 1: - continue - else: - c.inheritAllInterfaces("rect%d" %i) +c.inheritAllInterfaces("cover") c.toLibrary("ESP32Stack") \ No newline at end of file diff --git a/rocolib/builders/HalfCarBuilder.py b/rocolib/builders/HalfCarBuilder.py index f4538c93157f6d262a62f915a8ba32aff6b27231..9e7acb0227c09f0b927e293cd8586f81173e4111 100644 --- a/rocolib/builders/HalfCarBuilder.py +++ b/rocolib/builders/HalfCarBuilder.py @@ -2,18 +2,18 @@ from rocolib.api.components.Component import Component c = Component() -#Parameters for the sheath that would cover the wheels and the ESP32 Stack -#Parameters that will change the dimension of the car -c.addParameter("length", 76, paramType="length", minValue=65) #tested minValue -c.addParameter("height", 36, paramType="length", minValue=36) #tested minValue -c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue +# IMPORTANT:There is no specific microcontroller for this car. To use this, create a specific car builder +# and adjust the constraints of this component using your preferred microcontroller. +# Default servo: FS90R servo see dimensions in dimensions.py -#This car will use the customized ESP32 stack in dimensions.py and the FS90R servo -#Change here if you have another board c.addParameter("driveservo", "fs90r", paramType="dimension") -c.addParameter("brains", "esp32stack", paramType="dimension") -#Cover/body of the car (I needed one that folds -90; will try on SimpleRectBeam) +#Parameters for the sheath that would cover the wheels and brains of the car (changing these will change dimension of a car) +c.addParameter("length", 80, paramType="length", minValue=65) #tested minValue +c.addParameter("height", 36, paramType="length", minValue=13) #tested minValue +c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue + +#Cover/body of the car (Separate rectangles because the edges are customized) for i in range(1, 3): c.addSubcomponent("rect%d" %i, "Rectangle") c.addConstraint(("rect%d" %i, "l"), "length") @@ -24,8 +24,6 @@ for i in range(3, 5): c.addConstraint(("rect%d" %i, "l"), "length") c.addConstraint(("rect%d" %i, "w"), "width") -#TODO: ADD TABS FOR ATTACHMENT -# c.addConnection(("rect2", "b"), ("rect3", "t"), angle=90) c.addConnection(("rect3", "b"), ("rect1", "b"), angle=-90) c.addConnection(("rect2", "b"), ("rect4", "b"), angle=-90) c.addConnection(("rect4", "t"), ("rect1", "t"), angle=-90) @@ -35,22 +33,36 @@ c.addSubcomponent("rect0", "Rectangle") c.addConstraint(("rect0", "l"), ("height", "driveservo"), "x[0]-getDim(x[1], 'motorwidth')") c.addConstraint(("rect0", "w"), "driveservo", "getDim(x, 'motorwidth')") -c.addSubcomponent("sheathsplit", "SplitEdge") -c.addConstraint(("sheathsplit", "toplength"), "length", "(x,)") -c.addConstraint(("sheathsplit", "botlength"), ("length", "driveservo"), "(x[0] * 0.0691, getDim(x[1], 'motorwidth'), " - "(x[0]-(getDim(x[1], 'motorwidth') + x[0] * 0.0691)))") +for i in range(2): + c.addSubcomponent("sheathsplit%d" %i, "SplitEdge") + c.addConstraint(("sheathsplit%d" %i, "toplength"), "length", "(x,)") + -c.addConnection(("sheathsplit", "topedge0"), ("rect2", "t")) -c.addConnection(("sheathsplit", "botedge1"), ("rect0", "r"), angle=180) +c.addConstraint(("sheathsplit0", "botlength"), + ("length", "driveservo"), + "(x[0]/2. - getDim(x[1], 'motorwidth') - 2 * getDim(x[1], 'hornoffset'), " + "getDim(x[1], 'motorwidth'), x[0]/2. + 2 * getDim(x[1], 'hornoffset'))") + +c.addConstraint(("sheathsplit1", "botlength"), + ("length", "driveservo"), + "(x[0]/2. + 2 * getDim(x[1], 'hornoffset'), " + "getDim(x[1], 'motorwidth'), x[0]/2. - getDim(x[1], 'motorwidth') - 2 * getDim(x[1], 'hornoffset'))") + +c.addConnection(("sheathsplit0", "topedge0"), ("rect2", "t")) +c.addConnection(("sheathsplit0", "botedge1"), ("rect0", "r"), angle=180) for i in range(2): - c.addSubcomponent("rTriangle%d" %i, "RightTriangle") + c.addSubcomponent("rTriangle%d" %i, "Right45Triangle") c.addConstraint(("rTriangle%d" %i, "base"), "driveservo", "getDim(x, 'motorwidth')") c.addConstraint(("rTriangle%d" %i, "height"), "driveservo", "getDim(x, 'motorwidth')") c.addConnection(("rect0", "l"), ("rTriangle0", "bedge")) c.addConnection(("rTriangle0", "hedge"), ("rTriangle1", "hedge"), angle=180) +#Adding tabs +c.addConnection(("sheathsplit1", "topedge0"), ("rect3", "t")) +c.addConnection(("sheathsplit1", "botedge0"), ("sheathsplit0", "botedge2"), angle=-180, tabWidth=7) + #Four wheels using Wheel.yaml c.addSubcomponent("fleft", "Wheel", invert=True, inherit="angle") c.addSubcomponent("bright", "Wheel", invert=True, inherit="angle") @@ -58,28 +70,29 @@ c.addSubcomponent("bright", "Wheel", invert=True, inherit="angle") #Setting the parameters for the Wheels for servo in ("bright", "fleft"): c.addConstraint((servo, "servo"), "driveservo") - c.addConstraint((servo, "length"), ("length", "brains"), '((x[0] - getDim(x[1], "width")))') + c.addConstraint((servo, "length"), ("length", "driveservo"), '((x[0]/2. + 2 * getDim(x[1], "hornoffset")))') c.addConstConstraint((servo, "center"), False) - c.addConstraint((servo, "radius"), "brains", '(getDim(x, "height") / 1.35)') + c.addConstraint((servo, "radius"), "height", '(x / 1.35)') -#Support for the middle of the front and back wheels so that they won't collapse or wiggle -for i in range(1, 3): - c.addSubcomponent("between%d" %i, "SimpleRectBeam") - c.addConstraint(("between%d" %i, "length"), ("width", "driveservo"), "x[0]- 2 * getDim(x[1], 'motorheight')") - c.addConstraint(("between%d" % i, "depth"), "driveservo", "getDim(x, 'motorwidth')") - c.addConstraint(("between%d" % i, "width"), "driveservo", "getDim(x, 'motorwidth')") +#Support for wheels so that they won't collapse or wiggle +c.addSubcomponent("between1", "SimpleRectBeam") +c.addConstraint(("between1", "length"), ("width", "driveservo"), "x[0]- 2 * getDim(x[1], 'motorheight')") +c.addConstraint(("between1", "depth"), "driveservo", "getDim(x, 'motorwidth')") +c.addConstraint(("between1", "width"), "driveservo", "getDim(x, 'motorwidth')") #Back between support c.addConnection(("fleft", "topedge2"), ("between1", "topedge1"), angle=90) c.addConnection(("between1", "botedge1"), ("bright", "botedge2"), angle=90) -c.addConnection(("between2", "topedge1"), ("bright", "topedge2"), angle=90) -c.addConnection(("between2", "botedge1"), ("fleft", "botedge2"), angle=90, tabWidth=10) + +# c.addConnection(("between2", "topedge1"), ("bright", "topedge2"), angle=90) +# c.addConnection(("between2", "botedge1"), ("fleft", "botedge2"), angle=90, tabWidth=10) # Flipping right wheels to match the orientation of left wheels c.addConstConstraint(("bright", "flip"), True) c.addConnection(("rTriangle1", "bedge"), ("fleft", "botedge0")) +#Inheriting interfaces to make this Component reusable c.inheritAllInterfaces("fleft") c.inheritAllInterfaces("bright") c.inheritAllInterfaces("rect1") diff --git a/rocolib/builders/HingeServoBuilder.py b/rocolib/builders/HingeServoBuilder.py deleted file mode 100644 index 76b4c2d104995c8a7ac37f7099752d352456267f..0000000000000000000000000000000000000000 --- a/rocolib/builders/HingeServoBuilder.py +++ /dev/null @@ -1,43 +0,0 @@ - -from rocolib.api.components.Component import Component - -c = Component() - -c.addParameter("length", 76, paramType="length", minValue=65) #tested minValue -c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue - -c.addSubcomponent("servo", "MountedServo") -c.addParameter("driveservo", "fs90r", paramType="dimension") -c.addConstraint(("servo", "servo"), "driveservo") -c.addConstraint(("servo", "length"), "driveservo", 'getDim(x, "motorlength") + 2 * getDim(x, "shoulderlength")') -c.addConstConstraint(("servo", "center"), False) - -for i in range(5): - c.addSubcomponent("belt%d" %i, "Rectangle") - c.addConstraint(("belt%d"%i, "w"), "driveservo", 'getDim(x, "motorheight")') - -for i in range(3): - c.addConstraint(("belt%d"%i, "l"), ("width", "driveservo"), "(x[0]-getDim(x[1], 'motorwidth'))/2") - -for i in range(3, 5): - c.addConstraint(("belt%d" % i, "l"), "driveservo", 'getDim(x, "motorlength") + 2 * getDim(x, "shoulderlength")') - -# for i in range(6, 10): -# c.addConstraint(("belt%d"%i, "l"), "length") - -c.addConnection(("servo", "botedge3"), ("belt0", "l"), angle=-90) -c.addConnection(("servo", "botedge1"), ("belt1", "l"), angle=-90) -c.addConnection(("servo", "topedge1"), ("belt3", "l"), angle=-180) -c.addConnection(("servo", "topedge3"), ("belt4", "l"), angle=-180) -c.addConnection(("belt2", "l"), ("belt4", "r"), angle=90) - -# c.addConnection(("belt0", "r"), ("belt6", "l"), angle=90) -# c.addConnection(("belt1", "r"), ("belt7", "l"), angle=90) -# c.addConnection(("belt2", "r"), ("belt8", "l"), angle=-90) -# c.addConnection(("belt3", "r"), ("belt9", "l"), angle=-90) - -c.inheritAllInterfaces("servo") -for i in range(3): - c.inheritAllInterfaces("belt%d" %i) - -c.toLibrary("HingeServo") \ No newline at end of file diff --git a/rocolib/builders/NWheeledCarBuilder.py b/rocolib/builders/NWheeledCarBuilder.py index 020c9656a8435bd69e514ee34b6c03a06e86b5df..cd0649d3e53e0b8bc880fb63dbdc67805dcbdbd1 100644 --- a/rocolib/builders/NWheeledCarBuilder.py +++ b/rocolib/builders/NWheeledCarBuilder.py @@ -1,38 +1,56 @@ from rocolib.api.components.Component import Component c = Component() -#N-WHEELED CAR (10-wheeed car) -#Probably need to additional microcontroller in the middle for N > 8 -n = 4 #(number of wheels/2) - 1 -c.addParameter("length", 76, paramType="length", minValue=76) #tested minValue -c.addParameter("height", 36, paramType="length", minValue=36) #tested minValue -c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue +#N-WHEELED CAR (default 4-wheeed car) +#Probably need to put additional microcontroller in the middle for N > 8 +n = 5 #(number of wheels/2) + +#Add brain and wheels parameter (Default: Adafruit ESP32 2 Stacks) +c.addParameter("brains", "esp32stack", paramType="dimension") +c.addParameter("driveservo", "fs90r", paramType="dimension") -c.addSubcomponent("front", "HalfCar") #must always have a front car for the brains -c.addConstraint(("front", "length"), "length") -c.addConstraint(("front", "height"), "height") -c.addConstraint(("front", "width"), "width") +#The height will always match the height of the brains +c.addParameter("length", 80, paramType="length", minValue=80) #tested minValue +c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue #Connecting Each Car for i in range(n): c.addSubcomponent("car%d" %i, "HalfCar") - c.addConstraint(("car%d" %i, "length"), "length") - c.addConstraint(("car%d" %i, "height"), "height") + c.addConstraint(("car%d" %i, "driveservo"), "driveservo") + c.addConstraint(("car%d" %i, "length"), ("length", "driveservo", "brains"), "(x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')" + "- getDim(x[2], 'width')))") + c.addConstraint(("car%d" %i, "height"), "brains", '(getDim(x, "height"))') c.addConstraint(("car%d" %i, "width"), "width") for i in range(n - 1): - c.addConnection(("car%d" %i, "rect4.l"), ("car%d" %(i+1), "rect4.r")) + c.addSubcomponent("between%d" %i, "SimpleRectBeam") + c.addConstraint(("between%d" %i, "length"), ("width", "driveservo"), "x[0]- 2 * getDim(x[1], 'motorheight')") + c.addConstraint(("between%d" %i, "depth"), "driveservo", "getDim(x, 'motorwidth')") + c.addConstraint(("between%d" %i, "width"), "driveservo", "getDim(x, 'motorwidth')") + c.addConnection(("between%d" %i, "topedge1"), ("car%d" %(i+1), "bright.topedge2"), angle=90) + c.addConnection(("between%d" %i, "botedge1"), ("car%d" %(i+1), "fleft.botedge2"), angle=90, tabWidth=10) -c.addConnection(("front", "rect4.l"), ("car%d" %(n-1), "rect4.l")) +for i in range(n - 1): + for j in range(3, 5): + c.addConnection(("car%d" % i, "rect%d.r" % j), ("car%d" % (i + 1), "rect%d.l" % j)) + for j in range(1, 3): + c.addConnection(("car%d" %i, "rect%d.l" %j), ("car%d" %(i+1), "rect%d.r" %j)) -#Putting the brains in the front of the car -c.addParameter("brains", "esp32stack", paramType="dimension") -c.addParameter("driveservo", "fs90r", paramType="dimension") -c.addSubcomponent("holder", "ESP32Stack") +#Put shield for battery +#TODO: add a battery shield -c.addConstraint(("holder", "heightChanger"), ("brains", "height"), ("x[1] - getDim(x[0], 'height')")) +# Putting the brains +c.addSubcomponent("holder", "ESP32Stack") c.addConstraint(("holder", "length"), "width") -c.addConnection(("holder", "rect2.t"), ("front", "rect2.l"), angle=-90) +c.addSubcomponent("holdersplit", "SplitEdge") +c.addConstraint(("holdersplit", "toplength"), "brains", '(getDim(x, "height"),)') +c.addConstraint(("holdersplit", "botlength"), + ("driveservo", "brains"), + "(getDim(x[0], 'motorwidth'), getDim(x[1], 'height') - getDim(x[0], 'motorwidth'))") + +c.addConnection(("holdersplit", "topedge0"), ("holder", "cover.topedge1")) +c.addConnection(("car0", "bright.topedge0"), ("holdersplit", "botedge0"), angle=-90) +#Putting between support c.toLibrary("NWheeledCar") diff --git a/rocolib/builders/PivotCarBuilder.py b/rocolib/builders/PivotCarBuilder.py index ede468dccd7ebbf4326b94a8ee672eaacd639612..c9a58bb10ac4a69860db71e526575a5d16940ecb 100644 --- a/rocolib/builders/PivotCarBuilder.py +++ b/rocolib/builders/PivotCarBuilder.py @@ -2,73 +2,64 @@ from rocolib.api.components.Component import Component c = Component() -#NEEDS CLEANING -#Don't change n yet, haven't figured out how to make it n-wheeled -#4-wheeled pivot car -n = 2 -c.addParameter("length", 76, paramType="length", minValue=76) #tested minValue -c.addParameter("height", 36, paramType="length", minValue=36) #tested minValue +#Add brain and wheels parameter (Default: Adafruit ESP32 2 Stacks) +c.addParameter("brains", "esp32stack", paramType="dimension") +c.addParameter("driveservo", "fs90r", paramType="dimension") + +#The height will always match the height of the brains +c.addParameter("length", 80, paramType="length", minValue=80) #tested minValue c.addParameter("width", 60, paramType="length", minValue=60) #tested minValue +c.addParameter("steerangle", 3.14, paramType="length") #Change this to change direction of car -for i in range(n - 1): - c.addSubcomponent("front%d" % i, "HalfCar") - c.addConstraint(("front%d" % i, "length"), "length") - c.addConstraint(("front%d" % i, "height"), "height") - c.addConstraint(("front%d" % i, "width"), "width") - c.addSubcomponent("middle%d" % i, "HalfCar") - c.addConstraint(("middle%d" % i, "length"), "length") - c.addConstraint(("middle%d" % i, "height"), "height") - c.addConstraint(("middle%d" % i, "width"), "width") +for i in range(2): + c.addSubcomponent("car%d" % i, "HalfCar") + c.addConstraint(("car%d" % i, "length"), ("length", "driveservo", "brains"), "(x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')" + "- getDim(x[2], 'width')))") + c.addConstraint(("car%d" % i, "height"), "brains", '(getDim(x, "height"))') + c.addConstraint(("car%d" % i, "width"), "width") #Main component of steering wheel car which makes them moveable: trapezoid that connects the two half of the car for i in range(4): c.addSubcomponent("midsupport%d" %i, "Trapezoid") - c.addConstraint(("midsupport%d" %i, "width"), "width", "x-10") - c.addConstraint(("midsupport%d" %i, "depth"), "width", "x-37") - c.addConstraint(("midsupport%d" %i, "bangle"), "width", - "float(np.atan((x-37)/5)* 180 * 0.318309)") - -c.addConnection(("middle0", "rect4.l"), ("midsupport0", "botedge")) -c.addConnection(("front0", "rect4.l"), ("midsupport1", "botedge")) + c.addConstraint(("midsupport%d" %i, "width"), "width", "x-(2*x*.15)") + c.addConstraint(("midsupport%d" %i, "depth"), "driveservo", "getDim(x, 'motorlength')") + c.addConstraint(("midsupport%d" %i, "bangle"), ("width", "driveservo"), + "float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309)") -c.addConnection(("middle0", "rect3.l"), ("midsupport2", "botedge")) -c.addConnection(("front0", "rect3.l"), ("midsupport3", "botedge")) +c.addConnection(("car1", "rect4.r"), ("midsupport0", "botedge")) +c.addConnection(("car0", "rect4.r"), ("midsupport1", "botedge")) -c.addConnection(("midsupport2", "topedge"), ("midsupport3", "topedge")) - -#Putting the brains in front component of the car -c.addParameter("brains", "esp32stack", paramType="dimension") -c.addParameter("driveservo", "fs90r", paramType="dimension") +c.addConnection(("car1", "rect3.r"), ("midsupport2", "botedge")) +c.addConnection(("car0", "rect3.r"), ("midsupport3", "botedge")) -for i in range(1): - c.addSubcomponent("split%d" % i, "SplitEdge") - c.addConstraint(("split%d" % i, "toplength"), "length", '(x,)') - c.addConstraint(("split%d" % i, "botlength"), ("length", "height"), - '(x[1], x[0]-x[1])') - c.addSubcomponent("holder%d" % i, "ESP32Stack") - c.addConstraint(("holder%d" % i, "length"), "width") - c.addConstraint(("holder%d" % i, "heightChanger"), ("brains", "height"), ("x[1] - getDim(x[0], 'height')")) - c.addConstraint(("holder%d" % i, "length"), "width") +#Putting Brains +c.addSubcomponent("holder", "ESP32Stack") +c.addConstraint(("holder", "length"), "width") -c.addConnection(("front0", "rect3.t"), ("split0", "topedge0")) +c.addSubcomponent("holdersplit", "SplitEdge") +c.addConstraint(("holdersplit", "toplength"), "brains", '(getDim(x, "height"),)') +c.addConstraint(("holdersplit", "botlength"), + ("driveservo", "brains"), + "(getDim(x[0], 'motorwidth'), getDim(x[1], 'height') - getDim(x[0], 'motorwidth'))") -c.addConnection(("holder0", "rect2.t"), ("front0", "rect2.r"), angle=-90) +c.addConnection(("holdersplit", "topedge0"), ("holder", "cover.topedge1")) +c.addConnection(("car0", "bright.topedge0"), ("holdersplit", "botedge0"), angle=-90) #Putting servo hinge between cars -for i in range(1): - c.addSubcomponent("hinge%d" % i, "HingeServo") - c.addConstraint(("hinge%d" % i, "length"), "length") - c.addConstraint(("hinge%d" % i, "width"), "width") - c.addSubcomponent("hingeSplit%d" % i, "SplitEdge") - c.addConstraint(("hingeSplit%d" % i, "toplength"), "height", '(x,)') - c.addConstraint(("hingeSplit%d" % i, "botlength"), ("height", "driveservo"), - '((x[0]-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), ' - '(x[0]-getDim(x[1], "motorheight"))/2)') +c.addSubcomponent("hinge0", "Pivot", inherit="servo.angle") +c.addConstraint(("hinge0", "length"), "length") +c.addConstraint(("hinge0", "width"), "width") +c.addSubcomponent("hingeSplit0", "SplitEdge") +c.addConstraint(("hingeSplit0", "toplength"), "brains", '(getDim(x, "height"), )') +c.addConstraint(("hingeSplit0", "botlength"), ("brains", "driveservo"), + '((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), ' + '(getDim(x[0], "height")-getDim(x[1], "motorheight"))/2)') -c.addConnection(("front0", "rect1.r"), ("hingeSplit0", "topedge0")) +c.addConnection(("car0", "rect2.l"), ("hingeSplit0", "topedge0")) c.addConnection(("hingeSplit0", "botedge1"), ("hinge0", "belt2.r"), angle=-90) #Attach hinge on face of Trapezoid to move in Webots -# c.addConnection(("hinge0", "servo.mount"), ("midsupport4", "face0")) +c.addConnection(("midsupport2", "topedge"), ("hinge0", "pivotface.topedge"), angle=180) +c.addConstraint(("hinge0", "servo.angle"), "steerangle") c.toLibrary("PivotCar") diff --git a/rocolib/library/Centipede.yaml b/rocolib/library/Centipede.yaml index 11608fb57a6969c30a064f6423589fc65259b4cb..8f811b1f1de5b1d8783f770d193476c2966ea19f 100644 --- a/rocolib/library/Centipede.yaml +++ b/rocolib/library/Centipede.yaml @@ -1,160 +1,172 @@ connections: connection0: - - - middle1 - - rect4.l - - - midsupport0 - - botedge + - - holdersplit + - topedge0 + - - holder + - cover.topedge1 - {} connection1: - - - middle1 - - rect4.r - - - midsupport1 - - botedge - - {} + - - car0 + - bright.topedge0 + - - holdersplit + - botedge0 + - angle: -90 connection10: - - - middle0 - - rect3.l - - - midsupport10 - - botedge + - - car4 + - rect2.l + - - hingeSplit4 + - topedge0 - {} connection11: - - - front0 - - rect3.l - - - midsupport11 - - botedge - - {} + - - hingeSplit4 + - botedge1 + - - hinge4 + - belt2.r + - angle: -90 connection12: - - - midsupport4 - - topedge - - - midsupport5 - - topedge + - - car1 + - rect4.l + - - midsupport0 + - botedge - {} connection13: - - - midsupport10 - - topedge - - - midsupport11 - - topedge + - - car1 + - rect4.r + - - midsupport1 + - botedge - {} connection14: - - - midsupport9 - - topedge - - - midsupport3 - - topedge + - - car1 + - rect3.l + - - midsupport2 + - botedge - {} connection15: - - - front0 - - rect3.t - - - split0 - - topedge0 + - - car1 + - rect3.r + - - midsupport3 + - botedge - {} connection16: - - - front1 - - rect3.t - - - split1 - - topedge0 + - - car2 + - rect4.l + - - midsupport4 + - botedge - {} connection17: - - - holder0 - - rect2.t - - - front0 - - rect2.r - - angle: -90 + - - car2 + - rect4.r + - - midsupport5 + - botedge + - {} connection18: - - - holder1 - - rect2.t - - - front1 - - rect2.r - - angle: -90 + - - car2 + - rect3.l + - - midsupport6 + - botedge + - {} connection19: - - - front0 - - rect1.r + - - car2 + - rect3.r + - - midsupport7 + - botedge + - {} + connection2: + - - car0 + - rect2.l - - hingeSplit0 - topedge0 - {} - connection2: - - - front1 + connection20: + - - car3 - rect4.l - - - midsupport2 + - - midsupport8 - botedge - {} - connection20: + connection21: + - - car3 + - rect4.r + - - midsupport9 + - botedge + - {} + connection22: + - - car3 + - rect3.l + - - midsupport10 + - botedge + - {} + connection23: + - - car3 + - rect3.r + - - midsupport11 + - botedge + - {} + connection24: + - - car0 + - rect3.r + - - midsupport12 + - botedge + - {} + connection25: + - - car0 + - rect4.r + - - midsupport13 + - botedge + - {} + connection26: + - - car4 + - rect3.r + - - midsupport14 + - botedge + - {} + connection27: + - - car4 + - rect4.r + - - midsupport15 + - botedge + - {} + connection3: - - hingeSplit0 - botedge1 - - hinge0 - belt2.r - angle: -90 - connection21: - - - middle1 - - rect1.r + connection4: + - - car1 + - rect2.l - - hingeSplit1 - topedge0 - {} - connection22: + connection5: - - hingeSplit1 - botedge1 - - hinge1 - belt2.r - angle: -90 - connection23: - - - middle0 - - rect2.r + connection6: + - - car2 + - rect2.l - - hingeSplit2 - topedge0 - {} - connection24: + connection7: - - hingeSplit2 - botedge1 - - - rectAssist - - t - - angle: -180 - connection25: - - - rectAssist - - b - - hinge2 - - belt0.r - - angle: 90 - connection3: - - - middle1 - - rect3.r - - - midsupport3 - - botedge - - {} - connection4: - - - middle1 - - rect3.l - - - midsupport4 - - botedge - - {} - connection5: - - - front1 - - rect3.l - - - midsupport5 - - botedge - - {} - connection6: - - - middle0 - - rect4.l - - - midsupport6 - - botedge - - {} - connection7: - - - middle0 - - rect4.r - - - midsupport7 - - botedge - - {} + - belt2.r + - angle: -90 connection8: - - - front0 - - rect4.l - - - midsupport8 - - botedge + - - car3 + - rect2.l + - - hingeSplit3 + - topedge0 - {} connection9: - - - middle0 - - rect3.r - - - midsupport9 - - botedge - - {} + - - hingeSplit3 + - botedge1 + - - hinge3 + - belt2.r + - angle: -90 interfaces: {} parameters: brains: @@ -165,16 +177,30 @@ parameters: defaultValue: fs90r spec: valueType: str - height: - defaultValue: 36 + hinge0.servo.angle: + defaultValue: 0 spec: - minValue: 36 - units: mm + maxValue: null + minValue: null + units: degrees + valueType: (float, int) + hinge1.servo.angle: + defaultValue: 0 + spec: + maxValue: null + minValue: null + units: degrees valueType: (float, int) length: - defaultValue: 76 + defaultValue: 80 spec: - minValue: 76 + minValue: 80 + units: mm + valueType: (float, int) + steerangle: + defaultValue: 3.14 + spec: + minValue: 0 units: mm valueType: (float, int) width: @@ -183,50 +209,124 @@ parameters: minValue: 60 units: mm valueType: (float, int) -source: ..\builders\CentipedeBuilder.py +source: ../builders/CentipedeBuilder.py subcomponents: - front0: + car0: classname: HalfCar kwargs: {} parameters: height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: &id001 + - length + - driveservo + - brains width: parameter: width - front1: + car1: classname: HalfCar kwargs: {} parameters: height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id001 + width: + parameter: width + car2: + classname: HalfCar + kwargs: {} + parameters: + height: + function: (getDim(x, "height")) + parameter: brains + length: + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id001 + width: + parameter: width + car3: + classname: HalfCar + kwargs: {} + parameters: + height: + function: (getDim(x, "height")) + parameter: brains + length: + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id001 + width: + parameter: width + car4: + classname: HalfCar + kwargs: {} + parameters: + height: + function: (getDim(x, "height")) + parameter: brains + length: + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id001 width: parameter: width hinge0: - classname: HingeServo + classname: Pivot kwargs: {} parameters: length: parameter: length + servo.angle: + parameter: hinge0.servo.angle width: parameter: width hinge1: - classname: HingeServo + classname: Pivot kwargs: {} parameters: length: parameter: length + servo.angle: + parameter: hinge1.servo.angle width: parameter: width hinge2: - classname: HingeServo + classname: Pivot + kwargs: {} + parameters: + length: + parameter: length + servo.angle: + parameter: steerangle + width: + parameter: width + hinge3: + classname: Pivot kwargs: {} parameters: length: parameter: length + servo.angle: + parameter: steerangle + width: + parameter: width + hinge4: + classname: Pivot + kwargs: {} + parameters: + length: + parameter: length + servo.angle: + parameter: steerangle width: parameter: width hingeSplit0: @@ -234,260 +334,284 @@ subcomponents: kwargs: {} parameters: botlength: - function: ((x[0]-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), - (x[0]-getDim(x[1], "motorheight"))/2) - parameter: &id001 - - height + function: ((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], + "motorheight"), (getDim(x[0], "height")-getDim(x[1], "motorheight"))/2) + parameter: &id002 + - brains - driveservo toplength: - function: (x,) - parameter: height + function: (getDim(x, "height"), ) + parameter: brains hingeSplit1: classname: SplitEdge kwargs: {} parameters: botlength: - function: ((x[0]-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), - (x[0]-getDim(x[1], "motorheight"))/2) - parameter: *id001 + function: ((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], + "motorheight"), (getDim(x[0], "height")-getDim(x[1], "motorheight"))/2) + parameter: *id002 toplength: - function: (x,) - parameter: height + function: (getDim(x, "height"), ) + parameter: brains hingeSplit2: classname: SplitEdge kwargs: {} parameters: botlength: - function: ((x[0]-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), - (x[0]-getDim(x[1], "motorheight"))/2) - parameter: *id001 + function: ((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], + "motorheight"), (getDim(x[0], "height")-getDim(x[1], "motorheight"))/2) + parameter: *id002 toplength: - function: (x,) - parameter: height - holder0: - classname: ESP32Stack + function: (getDim(x, "height"), ) + parameter: brains + hingeSplit3: + classname: SplitEdge kwargs: {} parameters: - heightChanger: - function: x[1] - getDim(x[0], 'height') - parameter: &id002 - - brains - - height - length: - parameter: width - holder1: - classname: ESP32Stack + botlength: + function: ((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], + "motorheight"), (getDim(x[0], "height")-getDim(x[1], "motorheight"))/2) + parameter: *id002 + toplength: + function: (getDim(x, "height"), ) + parameter: brains + hingeSplit4: + classname: SplitEdge kwargs: {} parameters: - heightChanger: - function: x[1] - getDim(x[0], 'height') + botlength: + function: ((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], + "motorheight"), (getDim(x[0], "height")-getDim(x[1], "motorheight"))/2) parameter: *id002 - length: - parameter: width - middle0: - classname: HalfCar + toplength: + function: (getDim(x, "height"), ) + parameter: brains + holder: + classname: ESP32Stack kwargs: {} parameters: - height: - parameter: height length: - parameter: length - width: parameter: width - middle1: - classname: HalfCar + holdersplit: + classname: SplitEdge kwargs: {} parameters: - height: - parameter: height - length: - parameter: length - width: - parameter: width + botlength: + function: (getDim(x[0], 'motorwidth'), getDim(x[1], 'height') - getDim(x[0], + 'motorwidth')) + parameter: + - driveservo + - brains + toplength: + function: (getDim(x, "height"),) + parameter: brains midsupport0: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: &id003 + - width + - driveservo depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport1: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport10: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport11: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 + depth: + function: getDim(x, 'motorlength') + parameter: driveservo + width: + function: x-(2*x*.15) parameter: width + midsupport12: + classname: Trapezoid + kwargs: {} + parameters: + bangle: + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 + function: getDim(x, 'motorlength') + parameter: driveservo + width: + function: x-(2*x*.15) parameter: width + midsupport13: + classname: Trapezoid + kwargs: {} + parameters: + bangle: + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 + depth: + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width - midsupport2: + midsupport14: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 + depth: + function: getDim(x, 'motorlength') + parameter: driveservo + width: + function: x-(2*x*.15) parameter: width + midsupport15: + classname: Trapezoid + kwargs: {} + parameters: + bangle: + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 + function: getDim(x, 'motorlength') + parameter: driveservo + width: + function: x-(2*x*.15) parameter: width + midsupport2: + classname: Trapezoid + kwargs: {} + parameters: + bangle: + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 + depth: + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport3: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport4: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport5: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport6: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport7: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport8: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport9: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id003 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width - rectAssist: - classname: Rectangle - kwargs: {} - parameters: - l: - function: getDim(x, "motorheight") - parameter: driveservo - w: - parameter: length - split0: - classname: SplitEdge - kwargs: {} - parameters: - botlength: - function: (x[1], x[0]-x[1]) - parameter: &id003 - - length - - height - toplength: - function: (x,) - parameter: length - split1: - classname: SplitEdge - kwargs: {} - parameters: - botlength: - function: (x[1], x[0]-x[1]) - parameter: *id003 - toplength: - function: (x,) - parameter: length diff --git a/rocolib/library/ESP32Stack.yaml b/rocolib/library/ESP32Stack.yaml index 57c748d4bed6e1a6e0a54bfdb38a4804326f7188..5cacdae033ee486e8e8db4c32ba4cd76456813b0 100644 --- a/rocolib/library/ESP32Stack.yaml +++ b/rocolib/library/ESP32Stack.yaml @@ -1,25 +1,7 @@ connections: connection0: - - - rect3 - - r - - - rect0 - - r - - angle: -90 - connection1: - - - rect2 - - r - - - rect4 - - r - - angle: -90 - connection2: - - - rect4 - - l - - - rect0 - - l - - angle: -90 - connection3: - - - rect4 - - face + - - cover + - face0 - &id001 - header - decoration @@ -29,17 +11,17 @@ connections: parameter: &id002 - length - brains - connection4: - - - rect3 - - face + connection1: + - - cover + - face2 - *id001 - mode: hole offset: function: (0, 0) parameter: *id002 - connection5: - - - rect2 - - face + connection2: + - - cover + - face1 - - accessoryHole0 - decoration - mode: hole @@ -49,77 +31,59 @@ connections: - brains - length rotate: true - connection6: - - - rect0 - - face + connection3: + - - cover + - face3 - - accessoryHole1 - decoration - mode: hole offset: - function: (getDim(x[0], 'height') * 0.15, -x[1] * 0.25) + function: (getDim(x[0], 'height') * -0.15, -x[1] * 0.25) parameter: *id003 rotate: true interfaces: - rect0.b: - interface: b - subcomponent: rect0 - rect0.face: - interface: face - subcomponent: rect0 - rect0.l: - interface: l - subcomponent: rect0 - rect0.r: - interface: r - subcomponent: rect0 - rect0.t: - interface: t - subcomponent: rect0 - rect2.b: - interface: b - subcomponent: rect2 - rect2.face: - interface: face - subcomponent: rect2 - rect2.l: - interface: l - subcomponent: rect2 - rect2.r: - interface: r - subcomponent: rect2 - rect2.t: - interface: t - subcomponent: rect2 - rect3.b: - interface: b - subcomponent: rect3 - rect3.face: - interface: face - subcomponent: rect3 - rect3.l: - interface: l - subcomponent: rect3 - rect3.r: - interface: r - subcomponent: rect3 - rect3.t: - interface: t - subcomponent: rect3 - rect4.b: - interface: b - subcomponent: rect4 - rect4.face: - interface: face - subcomponent: rect4 - rect4.l: - interface: l - subcomponent: rect4 - rect4.r: - interface: r - subcomponent: rect4 - rect4.t: - interface: t - subcomponent: rect4 + cover.botedge0: + interface: botedge0 + subcomponent: cover + cover.botedge1: + interface: botedge1 + subcomponent: cover + cover.botedge2: + interface: botedge2 + subcomponent: cover + cover.botedge3: + interface: botedge3 + subcomponent: cover + cover.face0: + interface: face0 + subcomponent: cover + cover.face1: + interface: face1 + subcomponent: cover + cover.face2: + interface: face2 + subcomponent: cover + cover.face3: + interface: face3 + subcomponent: cover + cover.slotedge: + interface: slotedge + subcomponent: cover + cover.tabedge: + interface: tabedge + subcomponent: cover + cover.topedge0: + interface: topedge0 + subcomponent: cover + cover.topedge1: + interface: topedge1 + subcomponent: cover + cover.topedge2: + interface: topedge2 + subcomponent: cover + cover.topedge3: + interface: topedge3 + subcomponent: cover parameters: brains: defaultValue: esp32stack @@ -141,7 +105,7 @@ parameters: minValue: 0 units: mm valueType: (float, int) -source: ..\builders\ESP32StackBuilder.py +source: ../builders/ESP32StackBuilder.py subcomponents: accessoryHole0: classname: Cutout @@ -163,6 +127,18 @@ subcomponents: dy: function: getDim(x, 'height')/1.75 parameter: brains + cover: + classname: SimpleRectBeam + kwargs: {} + parameters: + depth: + function: (getDim(x, "height")) + parameter: brains + length: + parameter: length + width: + function: (getDim(x, "width")) + parameter: brains header: classname: Header kwargs: {} @@ -179,41 +155,3 @@ subcomponents: rowsep: function: getDim(x, 'rowsep') parameter: brains - rect0: - classname: Rectangle - kwargs: {} - parameters: - l: - function: getDim(x[0], 'height') + x[1] - parameter: &id004 - - brains - - heightChanger - w: - parameter: length - rect2: - classname: Rectangle - kwargs: {} - parameters: - l: - function: getDim(x[0], 'height') + x[1] - parameter: *id004 - w: - parameter: length - rect3: - classname: Rectangle - kwargs: {} - parameters: - l: - function: getDim(x, 'width') - parameter: brains - w: - parameter: length - rect4: - classname: Rectangle - kwargs: {} - parameters: - l: - function: getDim(x, 'width') - parameter: brains - w: - parameter: length diff --git a/rocolib/library/HalfCar.yaml b/rocolib/library/HalfCar.yaml index 661a00567a65e661e5bf965379045c10e7868928..af1e363994a75323f9d9e3d3cbdeb42884d8904e 100644 --- a/rocolib/library/HalfCar.yaml +++ b/rocolib/library/HalfCar.yaml @@ -12,12 +12,11 @@ connections: - b - angle: -90 connection10: - - - between2 + - - between1 - botedge1 - - - fleft + - - bright - botedge2 - angle: 90 - tabWidth: 10 connection11: - - rTriangle1 - bedge @@ -31,13 +30,13 @@ connections: - t - angle: -90 connection3: - - - sheathsplit + - - sheathsplit0 - topedge0 - - rect2 - t - {} connection4: - - - sheathsplit + - - sheathsplit0 - botedge1 - - rect0 - r @@ -55,22 +54,23 @@ connections: - hedge - angle: 180 connection7: - - - fleft - - topedge2 - - - between1 - - topedge1 - - angle: 90 + - - sheathsplit1 + - topedge0 + - - rect3 + - t + - {} connection8: - - - between1 - - botedge1 - - - bright + - - sheathsplit1 + - botedge0 + - - sheathsplit0 - botedge2 - - angle: 90 + - angle: -180 + tabWidth: 7 connection9: - - - between2 - - topedge1 - - - bright + - - fleft - topedge2 + - - between1 + - topedge1 - angle: 90 interfaces: bright.botedge0: @@ -236,10 +236,6 @@ interfaces: interface: t subcomponent: rect4 parameters: - brains: - defaultValue: esp32stack - spec: - valueType: str bright.angle: defaultValue: 0 spec: @@ -261,11 +257,11 @@ parameters: height: defaultValue: 36 spec: - minValue: 36 + minValue: 13 units: mm valueType: (float, int) length: - defaultValue: 76 + defaultValue: 80 spec: minValue: 65 units: mm @@ -276,7 +272,7 @@ parameters: minValue: 60 units: mm valueType: (float, int) -source: ..\builders\HalfCarBuilder.py +source: ../builders/HalfCarBuilder.py subcomponents: between1: classname: SimpleRectBeam @@ -287,25 +283,12 @@ subcomponents: parameter: driveservo length: function: x[0]- 2 * getDim(x[1], 'motorheight') - parameter: &id001 + parameter: - width - driveservo width: function: getDim(x, 'motorwidth') parameter: driveservo - between2: - classname: SimpleRectBeam - kwargs: {} - parameters: - depth: - function: getDim(x, 'motorwidth') - parameter: driveservo - length: - function: x[0]- 2 * getDim(x[1], 'motorheight') - parameter: *id001 - width: - function: getDim(x, 'motorwidth') - parameter: driveservo bright: classname: Wheel kwargs: @@ -316,13 +299,13 @@ subcomponents: center: false flip: true length: - function: ((x[0] - getDim(x[1], "width"))) - parameter: &id002 + function: ((x[0]/2. + 2 * getDim(x[1], "hornoffset"))) + parameter: &id001 - length - - brains + - driveservo radius: - function: (getDim(x, "height") / 1.35) - parameter: brains + function: (x / 1.35) + parameter: height servo: parameter: driveservo fleft: @@ -334,15 +317,15 @@ subcomponents: parameter: fleft.angle center: false length: - function: ((x[0] - getDim(x[1], "width"))) - parameter: *id002 + function: ((x[0]/2. + 2 * getDim(x[1], "hornoffset"))) + parameter: *id001 radius: - function: (getDim(x, "height") / 1.35) - parameter: brains + function: (x / 1.35) + parameter: height servo: parameter: driveservo rTriangle0: - classname: RightTriangle + classname: Right45Triangle kwargs: {} parameters: base: @@ -352,7 +335,7 @@ subcomponents: function: getDim(x, 'motorwidth') parameter: driveservo rTriangle1: - classname: RightTriangle + classname: Right45Triangle kwargs: {} parameters: base: @@ -405,16 +388,25 @@ subcomponents: parameter: length w: parameter: width - sheathsplit: + sheathsplit0: classname: SplitEdge kwargs: {} parameters: botlength: - function: (x[0] * 0.0691, getDim(x[1], 'motorwidth'), (x[0]-(getDim(x[1], - 'motorwidth') + x[0] * 0.0691))) - parameter: - - length - - driveservo + function: (x[0]/2. - getDim(x[1], 'motorwidth') - 2 * getDim(x[1], 'hornoffset'), + getDim(x[1], 'motorwidth'), x[0]/2. + 2 * getDim(x[1], 'hornoffset')) + parameter: *id001 + toplength: + function: (x,) + parameter: length + sheathsplit1: + classname: SplitEdge + kwargs: {} + parameters: + botlength: + function: (x[0]/2. + 2 * getDim(x[1], 'hornoffset'), getDim(x[1], 'motorwidth'), + x[0]/2. - getDim(x[1], 'motorwidth') - 2 * getDim(x[1], 'hornoffset')) + parameter: *id001 toplength: function: (x,) parameter: length diff --git a/rocolib/library/HingeServo.yaml b/rocolib/library/HingeServo.yaml deleted file mode 100644 index 994d89c520fb0ca6694505d44926a66f3e3b57ef..0000000000000000000000000000000000000000 --- a/rocolib/library/HingeServo.yaml +++ /dev/null @@ -1,209 +0,0 @@ -connections: - connection0: - - - servo - - botedge3 - - - belt0 - - l - - angle: -90 - connection1: - - - servo - - botedge1 - - - belt1 - - l - - angle: -90 - connection2: - - - servo - - topedge1 - - - belt3 - - l - - angle: -180 - connection3: - - - servo - - topedge3 - - - belt4 - - l - - angle: -180 - connection4: - - - belt2 - - l - - - belt4 - - r - - angle: 90 -interfaces: - belt0.b: - interface: b - subcomponent: belt0 - belt0.face: - interface: face - subcomponent: belt0 - belt0.l: - interface: l - subcomponent: belt0 - belt0.r: - interface: r - subcomponent: belt0 - belt0.t: - interface: t - subcomponent: belt0 - belt1.b: - interface: b - subcomponent: belt1 - belt1.face: - interface: face - subcomponent: belt1 - belt1.l: - interface: l - subcomponent: belt1 - belt1.r: - interface: r - subcomponent: belt1 - belt1.t: - interface: t - subcomponent: belt1 - belt2.b: - interface: b - subcomponent: belt2 - belt2.face: - interface: face - subcomponent: belt2 - belt2.l: - interface: l - subcomponent: belt2 - belt2.r: - interface: r - subcomponent: belt2 - belt2.t: - interface: t - subcomponent: belt2 - servo.botedge0: - interface: botedge0 - subcomponent: servo - servo.botedge1: - interface: botedge1 - subcomponent: servo - servo.botedge2: - interface: botedge2 - subcomponent: servo - servo.botedge3: - interface: botedge3 - subcomponent: servo - servo.face0: - interface: face0 - subcomponent: servo - servo.face1: - interface: face1 - subcomponent: servo - servo.face2: - interface: face2 - subcomponent: servo - servo.face3: - interface: face3 - subcomponent: servo - servo.horn: - interface: horn - subcomponent: servo - servo.mount: - interface: mount - subcomponent: servo - servo.mount.decoration: - interface: mount.decoration - subcomponent: servo - servo.slotedge: - interface: slotedge - subcomponent: servo - servo.tabedge: - interface: tabedge - subcomponent: servo - servo.topedge0: - interface: topedge0 - subcomponent: servo - servo.topedge1: - interface: topedge1 - subcomponent: servo - servo.topedge2: - interface: topedge2 - subcomponent: servo - servo.topedge3: - interface: topedge3 - subcomponent: servo -parameters: - driveservo: - defaultValue: fs90r - spec: - valueType: str - length: - defaultValue: 76 - spec: - minValue: 65 - units: mm - valueType: (float, int) - width: - defaultValue: 60 - spec: - minValue: 60 - units: mm - valueType: (float, int) -source: HingeServoBuilder.py -subcomponents: - belt0: - classname: Rectangle - kwargs: {} - parameters: - l: - function: (x[0]-getDim(x[1], 'motorwidth'))/2 - parameter: &id001 - - width - - driveservo - w: - function: getDim(x, "motorheight") - parameter: driveservo - belt1: - classname: Rectangle - kwargs: {} - parameters: - l: - function: (x[0]-getDim(x[1], 'motorwidth'))/2 - parameter: *id001 - w: - function: getDim(x, "motorheight") - parameter: driveservo - belt2: - classname: Rectangle - kwargs: {} - parameters: - l: - function: (x[0]-getDim(x[1], 'motorwidth'))/2 - parameter: *id001 - w: - function: getDim(x, "motorheight") - parameter: driveservo - belt3: - classname: Rectangle - kwargs: {} - parameters: - l: - function: getDim(x, "motorlength") + 2 * getDim(x, "shoulderlength") - parameter: driveservo - w: - function: getDim(x, "motorheight") - parameter: driveservo - belt4: - classname: Rectangle - kwargs: {} - parameters: - l: - function: getDim(x, "motorlength") + 2 * getDim(x, "shoulderlength") - parameter: driveservo - w: - function: getDim(x, "motorheight") - parameter: driveservo - servo: - classname: MountedServo - kwargs: {} - parameters: - center: false - length: - function: getDim(x, "motorlength") + 2 * getDim(x, "shoulderlength") - parameter: driveservo - servo: - parameter: driveservo diff --git a/rocolib/library/NWheeledCar.py b/rocolib/library/NWheeledCar.py deleted file mode 100644 index dc5caa742bcece72b9e1e1a9adf97fcd417bc529..0000000000000000000000000000000000000000 --- a/rocolib/library/NWheeledCar.py +++ /dev/null @@ -1,13 +0,0 @@ -from rocolib.api.components import Component -from rocolib.utils.utils import copyDecorations2 - -class NWheeledCar(Component): - def assemble(self): - copyDecorations2(self, ("holderface0", ("holder", "rect4.face", 0)), - ("bodyface0", ("front", "rect3.face", 0)), 0) - copyDecorations2(self, ("holderface1", ("holder", "rect3.face", 0)), - ("bodyface1", ("front", "rect4.face", 0)), 0) - - -if __name__ == "__main__": - NWheeledCar.test() diff --git a/rocolib/library/NWheeledCar.yaml b/rocolib/library/NWheeledCar.yaml index 3562647d5248acf5b4f51402a46a2556d354d126..d39bf86a847f063607c5fd5c84b84062284d11a8 100644 --- a/rocolib/library/NWheeledCar.yaml +++ b/rocolib/library/NWheeledCar.yaml @@ -1,34 +1,164 @@ connections: connection0: + - - between0 + - topedge1 + - - car1 + - bright.topedge2 + - angle: 90 + connection1: + - - between0 + - botedge1 + - - car1 + - fleft.botedge2 + - angle: 90 + tabWidth: 10 + connection10: - - car0 - - rect4.l + - rect1.l - - car1 - - rect4.r + - rect1.r - {} - connection1: + connection11: + - - car0 + - rect2.l + - - car1 + - rect2.r + - {} + connection12: + - - car1 + - rect3.r + - - car2 + - rect3.l + - {} + connection13: - - car1 + - rect4.r + - - car2 - rect4.l + - {} + connection14: + - - car1 + - rect1.l + - - car2 + - rect1.r + - {} + connection15: + - - car1 + - rect2.l + - - car2 + - rect2.r + - {} + connection16: + - - car2 + - rect3.r + - - car3 + - rect3.l + - {} + connection17: - - car2 - rect4.r + - - car3 + - rect4.l + - {} + connection18: + - - car2 + - rect1.l + - - car3 + - rect1.r + - {} + connection19: + - - car2 + - rect2.l + - - car3 + - rect2.r - {} connection2: + - - between1 + - topedge1 - - car2 - - rect4.l + - bright.topedge2 + - angle: 90 + connection20: - - car3 - - rect4.r + - rect3.r + - - car4 + - rect3.l - {} - connection3: - - - front - - rect4.l + connection21: - - car3 + - rect4.r + - - car4 - rect4.l - {} - connection4: - - - holder - - rect2.t - - - front + connection22: + - - car3 + - rect1.l + - - car4 + - rect1.r + - {} + connection23: + - - car3 - rect2.l + - - car4 + - rect2.r + - {} + connection24: + - - holdersplit + - topedge0 + - - holder + - cover.topedge1 + - {} + connection25: + - - car0 + - bright.topedge0 + - - holdersplit + - botedge0 - angle: -90 + connection3: + - - between1 + - botedge1 + - - car2 + - fleft.botedge2 + - angle: 90 + tabWidth: 10 + connection4: + - - between2 + - topedge1 + - - car3 + - bright.topedge2 + - angle: 90 + connection5: + - - between2 + - botedge1 + - - car3 + - fleft.botedge2 + - angle: 90 + tabWidth: 10 + connection6: + - - between3 + - topedge1 + - - car4 + - bright.topedge2 + - angle: 90 + connection7: + - - between3 + - botedge1 + - - car4 + - fleft.botedge2 + - angle: 90 + tabWidth: 10 + connection8: + - - car0 + - rect3.r + - - car1 + - rect3.l + - {} + connection9: + - - car0 + - rect4.r + - - car1 + - rect4.l + - {} interfaces: {} parameters: brains: @@ -39,16 +169,10 @@ parameters: defaultValue: fs90r spec: valueType: str - height: - defaultValue: 36 - spec: - minValue: 36 - units: mm - valueType: (float, int) length: - defaultValue: 76 + defaultValue: 80 spec: - minValue: 76 + minValue: 80 units: mm valueType: (float, int) width: @@ -57,66 +181,156 @@ parameters: minValue: 60 units: mm valueType: (float, int) -source: ..\builders\NWheeledCarBuilder.py +source: ../builders/NWheeledCarBuilder.py subcomponents: + between0: + classname: SimpleRectBeam + kwargs: {} + parameters: + depth: + function: getDim(x, 'motorwidth') + parameter: driveservo + length: + function: x[0]- 2 * getDim(x[1], 'motorheight') + parameter: &id001 + - width + - driveservo + width: + function: getDim(x, 'motorwidth') + parameter: driveservo + between1: + classname: SimpleRectBeam + kwargs: {} + parameters: + depth: + function: getDim(x, 'motorwidth') + parameter: driveservo + length: + function: x[0]- 2 * getDim(x[1], 'motorheight') + parameter: *id001 + width: + function: getDim(x, 'motorwidth') + parameter: driveservo + between2: + classname: SimpleRectBeam + kwargs: {} + parameters: + depth: + function: getDim(x, 'motorwidth') + parameter: driveservo + length: + function: x[0]- 2 * getDim(x[1], 'motorheight') + parameter: *id001 + width: + function: getDim(x, 'motorwidth') + parameter: driveservo + between3: + classname: SimpleRectBeam + kwargs: {} + parameters: + depth: + function: getDim(x, 'motorwidth') + parameter: driveservo + length: + function: x[0]- 2 * getDim(x[1], 'motorheight') + parameter: *id001 + width: + function: getDim(x, 'motorwidth') + parameter: driveservo car0: classname: HalfCar kwargs: {} parameters: + driveservo: + parameter: driveservo height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: &id002 + - length + - driveservo + - brains width: parameter: width car1: classname: HalfCar kwargs: {} parameters: + driveservo: + parameter: driveservo height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id002 width: parameter: width car2: classname: HalfCar kwargs: {} parameters: + driveservo: + parameter: driveservo height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id002 width: parameter: width car3: classname: HalfCar kwargs: {} parameters: + driveservo: + parameter: driveservo height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id002 width: parameter: width - front: + car4: classname: HalfCar kwargs: {} parameters: + driveservo: + parameter: driveservo height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id002 width: parameter: width holder: classname: ESP32Stack kwargs: {} parameters: - heightChanger: - function: x[1] - getDim(x[0], 'height') - parameter: - - brains - - height length: parameter: width + holdersplit: + classname: SplitEdge + kwargs: {} + parameters: + botlength: + function: (getDim(x[0], 'motorwidth'), getDim(x[1], 'height') - getDim(x[0], + 'motorwidth')) + parameter: + - driveservo + - brains + toplength: + function: (getDim(x, "height"),) + parameter: brains diff --git a/rocolib/library/PivotCar.yaml b/rocolib/library/PivotCar.yaml index be78e52a6cbde097081a2b109f931eb5c121cdf4..254e32d2ce26661aeb74274f9352ae6b38cb31ce 100644 --- a/rocolib/library/PivotCar.yaml +++ b/rocolib/library/PivotCar.yaml @@ -1,58 +1,58 @@ connections: connection0: - - - middle0 - - rect4.l + - - car1 + - rect4.r - - midsupport0 - botedge - {} connection1: - - - front0 - - rect4.l + - - car0 + - rect4.r - - midsupport1 - botedge - {} connection2: - - - middle0 - - rect3.l + - - car1 + - rect3.r - - midsupport2 - botedge - {} connection3: - - - front0 - - rect3.l + - - car0 + - rect3.r - - midsupport3 - botedge - {} connection4: - - - midsupport2 - - topedge - - - midsupport3 - - topedge - - {} - connection5: - - - front0 - - rect3.t - - - split0 + - - holdersplit - topedge0 + - - holder + - cover.topedge1 - {} - connection6: - - - holder0 - - rect2.t - - - front0 - - rect2.r + connection5: + - - car0 + - bright.topedge0 + - - holdersplit + - botedge0 - angle: -90 - connection7: - - - front0 - - rect1.r + connection6: + - - car0 + - rect2.l - - hingeSplit0 - topedge0 - {} - connection8: + connection7: - - hingeSplit0 - botedge1 - - hinge0 - belt2.r - angle: -90 + connection8: + - - midsupport2 + - topedge + - - hinge0 + - pivotface.topedge + - angle: 180 interfaces: {} parameters: brains: @@ -63,16 +63,16 @@ parameters: defaultValue: fs90r spec: valueType: str - height: - defaultValue: 36 + length: + defaultValue: 80 spec: - minValue: 36 + minValue: 80 units: mm valueType: (float, int) - length: - defaultValue: 76 + steerangle: + defaultValue: 3.14 spec: - minValue: 76 + minValue: 0 units: mm valueType: (float, int) width: @@ -81,24 +81,45 @@ parameters: minValue: 60 units: mm valueType: (float, int) -source: ..\builders\PivotCarBuilder.py +source: ../builders/PivotCarBuilder.py subcomponents: - front0: + car0: classname: HalfCar kwargs: {} parameters: height: - parameter: height + function: (getDim(x, "height")) + parameter: brains length: - parameter: length + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: &id001 + - length + - driveservo + - brains + width: + parameter: width + car1: + classname: HalfCar + kwargs: {} + parameters: + height: + function: (getDim(x, "height")) + parameter: brains + length: + function: (x[0] - (x[0]/2. - 2 * getDim(x[1], 'hornoffset')- getDim(x[2], + 'width'))) + parameter: *id001 width: parameter: width hinge0: - classname: HingeServo + classname: Pivot kwargs: {} parameters: length: parameter: length + servo.angle: + parameter: steerangle width: parameter: width hingeSplit0: @@ -106,96 +127,84 @@ subcomponents: kwargs: {} parameters: botlength: - function: ((x[0]-getDim(x[1], "motorheight"))/2, getDim(x[1], "motorheight"), - (x[0]-getDim(x[1], "motorheight"))/2) + function: ((getDim(x[0], "height")-getDim(x[1], "motorheight"))/2, getDim(x[1], + "motorheight"), (getDim(x[0], "height")-getDim(x[1], "motorheight"))/2) parameter: - - height + - brains - driveservo toplength: - function: (x,) - parameter: height - holder0: + function: (getDim(x, "height"), ) + parameter: brains + holder: classname: ESP32Stack kwargs: {} parameters: - heightChanger: - function: x[1] - getDim(x[0], 'height') - parameter: - - brains - - height length: parameter: width - middle0: - classname: HalfCar + holdersplit: + classname: SplitEdge kwargs: {} parameters: - height: - parameter: height - length: - parameter: length - width: - parameter: width + botlength: + function: (getDim(x[0], 'motorwidth'), getDim(x[1], 'height') - getDim(x[0], + 'motorwidth')) + parameter: + - driveservo + - brains + toplength: + function: (getDim(x, "height"),) + parameter: brains midsupport0: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: &id002 + - width + - driveservo depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport1: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id002 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport2: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id002 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width midsupport3: classname: Trapezoid kwargs: {} parameters: bangle: - function: float(np.atan((x-37)/5)* 180 * 0.318309) - parameter: width + function: float(np.atan(getDim(x[1], 'motorlength')/(x[0]*.15))* 180 * 0.318309) + parameter: *id002 depth: - function: x-37 - parameter: width + function: getDim(x, 'motorlength') + parameter: driveservo width: - function: x-10 + function: x-(2*x*.15) parameter: width - split0: - classname: SplitEdge - kwargs: {} - parameters: - botlength: - function: (x[1], x[0]-x[1]) - parameter: - - length - - height - toplength: - function: (x,) - parameter: length diff --git a/rocolib/library/RightTriangle.py b/rocolib/library/RightTriangle.py deleted file mode 100644 index 818d15087479b251a4b64e93d34dd209ddc59fcf..0000000000000000000000000000000000000000 --- a/rocolib/library/RightTriangle.py +++ /dev/null @@ -1,28 +0,0 @@ -from rocolib.api.components import FoldedComponent -from rocolib.api.composables.graph.Face import Face - -class RightTriangle(FoldedComponent): - - def define(self): - self.addParameter("height", 3, paramType="length") - self.addParameter("base", 4, paramType="length") - self.addParameter("hypotenuse", 5, paramType="length") - self.addParameter("angle", 45, paramType="angle", minValue=45, maxValue=45) - - self.addEdgeInterface("hedge", "r0.e0", "height") - self.addEdgeInterface("bedge", "r0.e1", "base") - self.addEdgeInterface("hypoedge", "r0.e2", "hypotenuse") - - def assemble(self): - h = self.getParameter("height") - b = self.getParameter("base") - x = h**2 + b**2 - - rs = [] - rs.append(Face("", ((b, 0), (0,0), (0, -h)))) - self.attachEdge(None, rs[0], "e0", prefix="r0", angle=90) - - -if __name__ == "__main__": - RightTriangle.test() - diff --git a/rocolib/library/Trapezoid.py b/rocolib/library/Trapezoid.py index 59d4021f2cb176115fa3611e0383afeae882e09d..f2e40ad2a808aa749a1c72c0c5f6ca27e60218e3 100644 --- a/rocolib/library/Trapezoid.py +++ b/rocolib/library/Trapezoid.py @@ -13,10 +13,10 @@ class Trapezoid(FoldedComponent): self.addParameter("side", 10, paramType="length") #float(self.getParameter("depth") * np.sqrt(2.)) - self.addEdgeInterface("topedge", "r0.e2", "width") - self.addEdgeInterface("ledge", "r0.e1", "side") - self.addEdgeInterface("redge", "r0.e3", "side") - self.addEdgeInterface("botedge", "r0.e0", "width") + self.addEdgeInterface("topedge", "e2", "width") + self.addEdgeInterface("ledge", "e1", "side") + self.addEdgeInterface("redge", "e3", "side") + self.addEdgeInterface("botedge", "e0", "width") self.addFaceInterface("face0", "f") def assemble(self): @@ -24,9 +24,10 @@ class Trapezoid(FoldedComponent): w = self.getParameter("width") x = d / np.tan(np.deg2rad(self.getParameter("bangle"))) - rs = [] - rs.append(Face("f", ((0, 0), (x, -d), (x + w, -d), (x + x + w, 0)))) - self.attachEdge(None, rs[0], "e0", prefix="r0", angle=90) + # rs = [] + # rs.append(Face("f", ((0, 0), (x, -d), (x + w, -d), (x + x + w, 0)))) + self.addFace(Face("f", ((0, 0), (x, -d), (x + w, -d), (x + x + w, 0)))) + # self.attachEdge(None, rs[0], "e0", prefix="r0", angle=90) if __name__ == "__main__": diff --git a/rocolib/utils/dimensions.py b/rocolib/utils/dimensions.py index 0e451f7721ae55f6f7a9b22f32c0000c704b39a7..c36de935cfcc2808963cb194abb13d7e03276da6 100644 --- a/rocolib/utils/dimensions.py +++ b/rocolib/utils/dimensions.py @@ -97,6 +97,8 @@ Should horn be a different object? ''' +#Below "horn+shoulder" is hornoffset + shoulderlength +#Below "hingeattach" is used in Pivot cars or HingeServo Component dims["s4303r"] = { "type" : "servo", "motorlength" : 31, "motorwidth" : 17, @@ -128,6 +130,19 @@ dims["fs90r"] = { "type" : "servo", "hornheight" : 16, "hornoffset" : 8, "horndepth" : 2, + "hingeattach" : 10, +} + +#Default: FS90R +dims["pivotservo"] = { "type" : "servo", + "motorlength" : 23, + "motorwidth" : 13, + "motorheight" : 19, + "shoulderlength": 5, + "hornlength" : 10, + "hornheight" : 8.4, + "hornoffset" : 8, + "horndepth" : 2, } l, w, h, r, c, rs, cs = symbols("brainLength brainWidth brainHeight brainNRows brainNCols brainRowSep brainColSep", positive=True) diff --git a/rocolib/utils/utils.py b/rocolib/utils/utils.py index a82784d96ce50fac6a11135e6b92a455f62455a7..1c6084f1a9fb7b78d73d79bdc172857d08bc94e2 100644 --- a/rocolib/utils/utils.py +++ b/rocolib/utils/utils.py @@ -1,85 +1,79 @@ import rocolib.utils.numsym as np from rocolib.utils.transforms import RotateZ, Translate - def prefix(s1, s2): - if s1 and s2: - return s1 + "." + s2 - return s1 or s2 - + if s1 and s2: + return s1 + "." + s2 + return s1 or s2 def tryImport(module, attribute): - try: - mod = __import__(module, fromlist=[attribute]) - obj = getattr(mod, attribute) - return obj - except ImportError: - mod = __import__("rocolib.library." + module, fromlist=[attribute]) - obj = getattr(mod, attribute) - return obj - + try: + mod = __import__(module, fromlist=[attribute]) + obj = getattr(mod, attribute) + return obj + except ImportError: + mod = __import__("rocolib.library." + module, fromlist=[attribute]) + obj = getattr(mod, attribute) + return obj def decorateGraph(face, decoration, offset=(0, 0), rotate=False, mode=None): - try: - dfaces = decoration.faces - except AttributeError: - dfaces = [decoration] - - if mode is None: - mode = "hole" + try: + dfaces = decoration.faces + except AttributeError: + dfaces = [decoration] - if rotate is False: - rotate = 0 - elif rotate is True: - rotate = -90 + if mode is None: + mode = "hole" - for f in dfaces: - t2d = transformDecorations(face, f.pts2d, offset=offset, rotate=rotate, mode=mode) - f.transform2D = t2d - f.addFace(face, np.inv(t2d)) + if rotate is False: + rotate = 0 + elif rotate is True: + rotate = -90 + for f in dfaces: + t2d = transformDecorations(face, f.pts2d, offset=offset, rotate=rotate, mode=mode) + f.transform2D = t2d + f.addFace(face, np.inv(t2d)) -def transformDecorations(face, pts2d, offset=(0, 0), rotate=0, flip=False, mode=None): +def transformDecorations(face, pts2d, offset=(0,0), rotate=0, flip=False, mode=None): a = np.deg2rad(rotate) c = np.cos(a) s = np.sin(a) face.addDecoration(([ - (c * p[0] - s * p[1] + offset[0], s * p[0] + c * p[1] + offset[1]) - for p in pts2d], mode)) + (c*p[0] - s*p[1] + offset[0], s*p[0] + c*p[1] + offset[1]) + for p in pts2d], mode)) return np.dot(Translate([offset[0], offset[1], 0]), RotateZ(rotate)) - def copyDecorations(self, deco_1, deco_2): - (ni1, (sc1, i1, p1a, p1b)) = deco_1 - (ni2, (sc2, i2, p2a, p2b)) = deco_2 + (ni1, (sc1, i1, p1a, p1b)) = deco_1 + (ni2, (sc2, i2, p2a, p2b)) = deco_2 - self.inheritInterface(ni1, (sc1, i1)) - self.inheritInterface(ni2, (sc2, i2)) + self.inheritInterface(ni1, (sc1, i1)) + self.inheritInterface(ni2, (sc2, i2)) - f1 = self.getInterface(ni1).getFace() - f2 = self.getInterface(ni2).getFace() - - p1o = f1.pts2d[p1a] - p1x = f1.pts2d[p1b] - p2o = f2.pts2d[p2a] - p2x = f2.pts2d[p2b] + f1 = self.getInterface(ni1).getFace() + f2 = self.getInterface(ni2).getFace() - a1 = np.arctan2(p1x[1] - p1o[1], p1x[0] - p1o[0]) - a2 = np.arctan2(p2x[1] - p2o[1], p2x[0] - p2o[0]) + p1o = f1.pts2d[p1a] + p1x = f1.pts2d[p1b] + p2o = f2.pts2d[p2a] + p2x = f2.pts2d[p2b] - for pts, mode in f1.decorations: - transformDecorations( - f2, - [(px - p1o[0], py - p1o[1]) for (px, py) in pts], - offset=p2o, - rotate=np.rad2deg(a2 - a1), - mode=mode - ) + a1 = np.arctan2(p1x[1]-p1o[1], p1x[0]-p1o[0]) + a2 = np.arctan2(p2x[1]-p2o[1], p2x[0]-p2o[0]) + for pts, mode in f1.decorations: + transformDecorations( + f2, + [(px - p1o[0], py - p1o[1]) for (px, py) in pts], + offset = p2o, + rotate = np.rad2deg(a2-a1), + mode = mode + ) -def copyDecorations2(self, deco_1, deco_2, angle): + def copyDecorations2(self, deco_1, deco_2, angle): (ni1, (sc1, i1, p1a)) = deco_1 (ni2, (sc2, i2, p2a)) = deco_2 @@ -93,10 +87,10 @@ def copyDecorations2(self, deco_1, deco_2, angle): p2o = f2.pts2d[p2a] for pts, mode in f1.decorations: - transformDecorations( - f2, - [(px - p1o[0], py - p1o[1]) for (px, py) in pts], - offset=p2o, - rotate=angle, - mode=mode - ) \ No newline at end of file + transformDecorations( + f2, + [(px - p1o[0], py - p1o[1]) for (px, py) in pts], + offset=p2o, + rotate=angle, + mode=mode + ) \ No newline at end of file