From 3bbc9d5076ef601cbd1a9c082e140a4007e647d8 Mon Sep 17 00:00:00 2001
From: pjil27 <jillpantigcs@gmail.com>
Date: Tue, 3 Aug 2021 14:31:49 -0700
Subject: [PATCH] Adding boat with mounts

---
 rocolib/builders/BoatWithMountBuilder.py |  47 +++++++
 rocolib/library/BoatWithMount.yaml       | 160 +++++++++++++++++++++++
 2 files changed, 207 insertions(+)
 create mode 100644 rocolib/builders/BoatWithMountBuilder.py
 create mode 100644 rocolib/library/BoatWithMount.yaml

diff --git a/rocolib/builders/BoatWithMountBuilder.py b/rocolib/builders/BoatWithMountBuilder.py
new file mode 100644
index 0000000..7c4a020
--- /dev/null
+++ b/rocolib/builders/BoatWithMountBuilder.py
@@ -0,0 +1,47 @@
+from rocolib.api.components.Component import Component
+
+c = Component()
+
+c.addSubcomponent("boat", "BoatBase")
+
+#the length of the both should always be a multiple of the width of the motor
+#as of now i will be setting the length to 117 (so that means 9 * width of the motor which is 13)
+c.addParameter("length", 130, paramType="length")
+c.addParameter("width", 50, paramType="length")
+c.addParameter("depth", 40, paramType="length")
+
+c.addConstraint(("boat", "boat.length"), "length")
+c.addConstraint(("boat", "boat.width"), "width")
+c.addConstraint(("boat", "boat.depth"), "depth")
+
+c.addParameter("driveservo", "fs90r", paramType="dimension")
+
+for i in range(3):
+    c.addSubcomponent("mount%d" %i, "MountedServo")
+    c.addConstraint(("mount%d" %i, "servo"), "driveservo")
+    c.addConstraint(("mount%d" %i, "length"), "width")
+    c.addConstConstraint(("mount%d" %i, "center"), False)
+
+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", "driveservo"),
+                    '(getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"),'
+                    'getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"), x[0]- 9 * getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"),'
+                    'getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"))')
+    c.addSubcomponent("rect%d" % i, "Rectangle")
+    c.addConstraint(("rect%d" %i, "l"), "depth")
+    c.addConstraint(("rect%d" %i, "w"), "driveservo", "getDim(x, 'motorwidth')")
+
+c.addConnection(("boat", "staredge"), ("split0", "topedge0"))
+c.addConnection(("boat", "portedge"), ("split1", "topedge0"))
+
+c.addConnection(("mount0", "beam.botedge2"), ("split0", "botedge4"), angle=-180)
+c.addConnection(("mount1", "beam.botedge2"), ("split1", "botedge5"), angle=-180)
+
+c.addConnection(("rect0", "l"), ("split0", "botedge6"), angle=-180, tabWidth=8)
+c.addConnection(("rect0", "r"), ("mount2", "beam.botedge2"), angle=-90)
+c.addConnection(("rect1", "r"), ("mount2", "beam.topedge2"), angle=-90)
+c.addConnection(("rect1", "l"), ("split1", "botedge3"), angle=-180, tabWidth=8)
+
+c.toLibrary("BoatWithMount")
\ No newline at end of file
diff --git a/rocolib/library/BoatWithMount.yaml b/rocolib/library/BoatWithMount.yaml
new file mode 100644
index 0000000..250214f
--- /dev/null
+++ b/rocolib/library/BoatWithMount.yaml
@@ -0,0 +1,160 @@
+connections:
+  connection0:
+  - - boat
+    - staredge
+  - - split0
+    - topedge0
+  - {}
+  connection1:
+  - - boat
+    - portedge
+  - - split1
+    - topedge0
+  - {}
+  connection2:
+  - - mount0
+    - beam.botedge2
+  - - split0
+    - botedge4
+  - angle: -180
+  connection3:
+  - - mount1
+    - beam.botedge2
+  - - split1
+    - botedge5
+  - angle: -180
+  connection4:
+  - - rect0
+    - l
+  - - split0
+    - botedge6
+  - angle: -180
+    tabWidth: 8
+  connection5:
+  - - rect0
+    - r
+  - - mount2
+    - beam.botedge2
+  - angle: -90
+  connection6:
+  - - rect1
+    - r
+  - - mount2
+    - beam.topedge2
+  - angle: -90
+  connection7:
+  - - rect1
+    - l
+  - - split1
+    - botedge3
+  - angle: -180
+    tabWidth: 8
+interfaces: {}
+parameters:
+  depth:
+    defaultValue: 40
+    spec:
+      minValue: 0
+      units: mm
+      valueType: (float, int)
+  driveservo:
+    defaultValue: fs90r
+    spec:
+      valueType: str
+  length:
+    defaultValue: 130
+    spec:
+      minValue: 0
+      units: mm
+      valueType: (float, int)
+  width:
+    defaultValue: 50
+    spec:
+      minValue: 0
+      units: mm
+      valueType: (float, int)
+source: ..\builders\BoatWithMountBuilder.py
+subcomponents:
+  boat:
+    classname: BoatBase
+    kwargs: {}
+    parameters:
+      boat.depth:
+        parameter: depth
+      boat.length:
+        parameter: length
+      boat.width:
+        parameter: width
+  mount0:
+    classname: MountedServo
+    kwargs: {}
+    parameters:
+      center: false
+      length:
+        parameter: width
+      servo:
+        parameter: driveservo
+  mount1:
+    classname: MountedServo
+    kwargs: {}
+    parameters:
+      center: false
+      length:
+        parameter: width
+      servo:
+        parameter: driveservo
+  mount2:
+    classname: MountedServo
+    kwargs: {}
+    parameters:
+      center: false
+      length:
+        parameter: width
+      servo:
+        parameter: driveservo
+  rect0:
+    classname: Rectangle
+    kwargs: {}
+    parameters:
+      l:
+        parameter: depth
+      w:
+        function: getDim(x, 'motorwidth')
+        parameter: driveservo
+  rect1:
+    classname: Rectangle
+    kwargs: {}
+    parameters:
+      l:
+        parameter: depth
+      w:
+        function: getDim(x, 'motorwidth')
+        parameter: driveservo
+  split0:
+    classname: SplitEdge
+    kwargs: {}
+    parameters:
+      botlength:
+        function: (getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"), getDim(x[1],
+          "motorwidth"),getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"), x[0]-
+          9 * getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"),getDim(x[1],
+          "motorwidth"), getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"))
+        parameter: &id001
+        - length
+        - driveservo
+      toplength:
+        function: (x,)
+        parameter: length
+  split1:
+    classname: SplitEdge
+    kwargs: {}
+    parameters:
+      botlength:
+        function: (getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"), getDim(x[1],
+          "motorwidth"),getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"), x[0]-
+          9 * getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"),getDim(x[1],
+          "motorwidth"), getDim(x[1], "motorwidth"), getDim(x[1], "motorwidth"))
+        parameter: *id001
+      toplength:
+        function: (x,)
+        parameter: length
-- 
GitLab