From 94cd173f5ec2d24c6b8c130a509ca7bc1d31546d Mon Sep 17 00:00:00 2001
From: mehtank <mehtank@ucla.edu>
Date: Tue, 20 Sep 2022 19:38:39 +0000
Subject: [PATCH] Components

---
 rocolib/builders/ESPSegBuilder.py |  5 ++-
 rocolib/library/ESPSeg.yaml       |  9 ++--
 rocolib/library/MountedServo.yaml |  2 +-
 rocolib/library/ServoMotor.py     |  2 +-
 rocolib/library/ServoMount.yaml   |  2 +-
 rocolib/library/TwoDOF.py         | 69 ++++++++++++++++---------------
 rocolib/library/Wheel.yaml        |  2 +-
 7 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/rocolib/builders/ESPSegBuilder.py b/rocolib/builders/ESPSegBuilder.py
index ee7f796..1b002b4 100644
--- a/rocolib/builders/ESPSegBuilder.py
+++ b/rocolib/builders/ESPSegBuilder.py
@@ -29,6 +29,7 @@ def depthfn(params = None, fnmod = None):
 # Set microcontroller
 c.addConstraint(("brain", "depth"), *depthfn())
 c.addConstraint(("brain", "length"), "width")
+c.addConstraint(("brain", "width"), "brain", "x.get('width')")
 
 for servo in ("right", "left"):
     c.addConstraint((servo, "length"),
@@ -41,10 +42,10 @@ for servo in ("right", "left"):
 c.addConstConstraint(("right","flip"), True)
 
 # connections
-c.addConnection(("brain", "topedge0"),
+c.addConnection(("brain", "botedge0"),
                 ("right", "topedge0"),
                 angle=-90)
-c.addConnection(("brain", "botedge0"),
+c.addConnection(("brain", "topedge0"),
                 ("left", "botedge0"),
                 angle=-90)
 
diff --git a/rocolib/library/ESPSeg.yaml b/rocolib/library/ESPSeg.yaml
index 28215c3..3743f2b 100644
--- a/rocolib/library/ESPSeg.yaml
+++ b/rocolib/library/ESPSeg.yaml
@@ -1,13 +1,13 @@
 connections:
   connection0:
   - - brain
-    - topedge0
+    - botedge0
   - - right
     - topedge0
   - angle: -90
   connection1:
   - - brain
-    - botedge0
+    - topedge0
   - - left
     - botedge0
   - angle: -90
@@ -145,7 +145,7 @@ parameters:
           shoulderlength: 3.5
         fs90r:
           horndepth: 2
-          hornheight: 16
+          hornheight: 11
           hornlength: 10
           hornoffset: 8
           motorheight: 19
@@ -235,6 +235,9 @@ subcomponents:
         - driveservo
       length:
         parameter: width
+      width:
+        function: x.get('width')
+        parameter: brain
   left:
     classname: Wheel
     kwargs:
diff --git a/rocolib/library/MountedServo.yaml b/rocolib/library/MountedServo.yaml
index 59533ea..8754865 100644
--- a/rocolib/library/MountedServo.yaml
+++ b/rocolib/library/MountedServo.yaml
@@ -150,7 +150,7 @@ parameters:
           shoulderlength: 3.5
         fs90r:
           horndepth: 2
-          hornheight: 16
+          hornheight: 11
           hornlength: 10
           hornoffset: 8
           motorheight: 19
diff --git a/rocolib/library/ServoMotor.py b/rocolib/library/ServoMotor.py
index 969c4a2..47fbbbb 100644
--- a/rocolib/library/ServoMotor.py
+++ b/rocolib/library/ServoMotor.py
@@ -88,7 +88,7 @@ class ServoMotor(FoldedComponent):
             motorheight   = 19,
             shoulderlength= 5,
             hornlength    = 10,
-            hornheight    = 16,
+            hornheight    = 11,
             hornoffset    = 8,
             horndepth     = 2,
         ),
diff --git a/rocolib/library/ServoMount.yaml b/rocolib/library/ServoMount.yaml
index 45d9c9e..c60f158 100644
--- a/rocolib/library/ServoMount.yaml
+++ b/rocolib/library/ServoMount.yaml
@@ -90,7 +90,7 @@ parameters:
           shoulderlength: 3.5
         fs90r:
           horndepth: 2
-          hornheight: 16
+          hornheight: 11
           hornlength: 10
           hornoffset: 8
           motorheight: 19
diff --git a/rocolib/library/TwoDOF.py b/rocolib/library/TwoDOF.py
index 82bbe72..b7edc10 100644
--- a/rocolib/library/TwoDOF.py
+++ b/rocolib/library/TwoDOF.py
@@ -1,33 +1,36 @@
-from rocolib.api.components import FoldedComponent
-from rocolib.api.composables.graph.Face import Rectangle, Face
-
-class TwoDOF(FoldedComponent):
-  def define(self):
-    self.addParameter("mountlength", 40, paramType="length")
-    self.addParameter("handlelength", 15, paramType="length")
-    self.addParameter("thickness", 10, paramType="length")
-    self.addParameter("pitch", 135, paramType="angle")
-    self.addParameter("yaw", 60, paramType="angle")
-
-    self.addEdgeInterface("mountedge", "mount.e0", "width")
-    self.addEdgeInterface("oaredge", "r2.e2", "h")
-
-  def assemble(self):
-    t = self.p.thickness
-    w = self.p.mountlength
-    h = self.p.handlelength
-    p = self.p.pitch
-    y = self.p.yaw
-
-    b = Face("", ((w, 0), (w, t), (w/2,t), (0,t), (0,0)))
-    b0 = Rectangle("", w, 0)
-    r1 = Rectangle("", w/2, t)
-    r2 = Rectangle("", h, t)
-
-    self.addFace(b, "base")
-    self.attachEdge("base.e2", r1, "e0", prefix="r1", angle=-180)
-    self.attachEdge("r1.e3", r2, "e1", prefix="r2", angle=y)
-    self.attachEdge("base.e0", b0, "e2", prefix="mount", angle=p)
-
-if __name__ == "__main__":
-    TwoDOF.test()
+from rocolib.api.components import FoldedComponent
+from rocolib.api.composables.graph.Face import Rectangle, Face
+
+class TwoDOF(FoldedComponent):
+  def define(self):
+    self.addParameter("mountlength", 40, paramType="length")
+    self.addParameter("handlelength", 15, paramType="length")
+    self.addParameter("hingelength", 10, paramType="length")
+    self.addParameter("thickness", 10, paramType="length")
+    self.addParameter("pitch", 135, paramType="angle")
+    self.addParameter("yaw", 60, paramType="angle")
+
+    self.addEdgeInterface("mountedge", "mount.e0", "mountlength")
+    self.addEdgeInterface("outedge", "r2.e2", "handlelength")
+    self.addEdgeInterface("handleedge", "r2.e3", "thickness")
+
+  def assemble(self):
+    t = self.p.thickness
+    w = self.p.mountlength
+    x = self.p.hingelength
+    h = self.p.handlelength
+    p = self.p.pitch
+    y = self.p.yaw
+
+    b = Face("", ((w, 0), (w, t), (w-x,t), (0,t), (0,0)))
+    b0 = Rectangle("", w, 0)
+    r1 = Rectangle("", x, t)
+    r2 = Rectangle("", h, t)
+
+    self.addFace(b, "base")
+    self.attachEdge("base.e2", r1, "e0", prefix="r1", angle=-180)
+    self.attachEdge("r1.e3", r2, "e1", prefix="r2", angle=y)
+    self.attachEdge("base.e0", b0, "e2", prefix="mount", angle=p)
+
+if __name__ == "__main__":
+    TwoDOF.test()
diff --git a/rocolib/library/Wheel.yaml b/rocolib/library/Wheel.yaml
index 6de1d93..00d9c75 100644
--- a/rocolib/library/Wheel.yaml
+++ b/rocolib/library/Wheel.yaml
@@ -156,7 +156,7 @@ parameters:
           shoulderlength: 3.5
         fs90r:
           horndepth: 2
-          hornheight: 16
+          hornheight: 11
           hornlength: 10
           hornoffset: 8
           motorheight: 19
-- 
GitLab