{"id":5186,"date":"2021-04-26T20:50:15","date_gmt":"2021-04-27T00:50:15","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/?p=5186"},"modified":"2021-04-26T20:50:17","modified_gmt":"2021-04-27T00:50:17","slug":"assignment-21-rebecca-k-and-helen","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/5186\/assignment-21-rebecca-k-and-helen\/","title":{"rendered":"Assignment 21: Rebecca K and Helen"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"1024\" src=\"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-1024x1024.jpg\" alt=\"\" class=\"wp-image-5187\" srcset=\"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-1024x1024.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-300x300.jpg 300w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-150x150.jpg 150w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-768x768.jpg 768w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-1536x1536.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-88x88.jpg 88w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-973x973.jpg 973w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60-508x508.jpg 508w, https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-content\/uploads\/2021\/04\/Untitled-60.jpg 2000w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>For the next phase of the project, I fleshed out the details of construction. The general figure and form of the vest is seen in figure A. I want to create panels, attaching them together on the residual vinyl edge using double sided tape. The individual panels can be seen in figure B on the drawing. I also want to attach a strap to the left side of the vest where the hand pump can be tucked in. <\/p>\n\n\n\n<p>I am choosing to focus the changeable elements of the vest on the two breastplates, left and right. The left side will be the inflatable panel and the defense kit will be on the right. For the defense kit, illustrated in figure C, I\u2019ll prop up the string for the hidden elements (right now I am leaning toward pepper spray and a lighter) with a chopstick or other stable form (tubing, cardboard, etc). When the servo motor is activated and it swivels once, it will extricate the chopstick from the chain and the pepper spray\/lighter will fall down, for easy access.<\/p>\n\n\n\n<p>Figure D demonstrates the basic pattern for a vest, which will be a useful checkpoint during construction to make sure all the individual pieces come together as a vest.<\/p>\n\n\n\n<p><strong>Software Progress<\/strong><\/p>\n\n\n\n<p>So far, the pressure sensor has been tested separately to calibrate the sensitivity of touch. When testing the sensitivity using the cp_ticklish.py code, I noticed that constantly squeezing the pressure pump doesn&#8217;t keep the pressure steadily above 0.5. The sensitivity needs to be calibrated to ensure that the rough code below can send consistent signals to the mqtt server in the future. <\/p>\n\n\n\n<p><strong>Code<\/strong><\/p>\n\n\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&quot;&quot;&quot;\nProject 2: Active Proxy Body\n\nHelen Yu (heleny1), Rebecca Kim\n\nWritten by Helen Yu\nLast Updated: 4\/26\/21\n\nSummary: When you clench your pump and inflate your vest, your\npartner's vest leaps into defense mode. A hobby servo helps control\nthe defense mechanism, be it spikes, projectiles, webs, etc.\n\nInputs: Soft Touch Sensor on A2\nOutputs: Hobby Servo on SD A5\n&quot;&quot;&quot;\n# ----------------------------------------------------------------\n# Import any needed standard Python modules.\nimport time, math\n\n# Import the board-specific input\/output library.\nfrom adafruit_circuitplayground import cp\n\n# Import the low-level hardware libraries.\nimport board\nimport digitalio\nimport analogio\nimport pwmio\n\n# Import the Adafruit helper library.\nfrom adafruit_motor import servo\n\n# ----------------------------------------------------------------\n# Initialize hardware.\n\n# Configure the digital input pin used for its pullup resistor bias voltage.\nbias = digitalio.DigitalInOut(board.D10)        # pad A3\nbias.switch_to_input(pull=digitalio.Pull.UP)\n\n# Configure the analog input pin used to measure the sensor voltage.\nsensor = analogio.AnalogIn(board.A2)\nscaling = sensor.reference_voltage \/ (2**16)\n\n# Create a PWMOut object on pad SDA A5 to generate control signals.\npwm = pwmio.PWMOut(board.A5, duty_cycle=0, frequency=50)\n\n# Create a Servo object which controls a hobby servo using the PWMOut.\nactuator = servo.Servo(pwm, min_pulse=1000, max_pulse=2000)\nactuator.angle = 0\n\n# ----------------------------------------------------------------\n# Initialize global variables for the main loop.\n\nremote_touch = [0]\n\n# Measure the time since the last remote move message, and reset after a period without data.\nremote_touch_timer = False\n\n# Convenient time constant expressed in nanoseconds.\nsecond = 1000000000\n\n# Integer time stamp for the next console output.\nsensing_timer = time.monotonic()\n\n# Integer time stamp for next behavior activity to begin.\nnext_activity_time = time.monotonic_ns() + 2 * second\n\n# Flag to trigger motion.\nsweep_slow = False\n\nphase_angle = 0.0\nphase_rate  = 2*math.pi \/ 6.0  # one cycle per six seconds, in radians\/second\n\n# Integer time stamp for next servo update.\nnext_servo_update = time.monotonic_ns()\n\n# The serial port output rate is regulated using the following timer variables.\nserial_timer    = 0.0\nserial_interval = 0.5\n\n# ----------------------------------------------------------------\n# Begin the main processing loop.\nwhile True:\n\n    # Read the current integer clock.\n    now = time.monotonic()\n\n     #---- soft sensor input and display -----------------------------\n    # Read the integer sensor value and scale it to a value in Volts.\n    volts = sensor.value * scaling\n\n    # Normalize the soft sensor reading.  Typically you'll need to adjust these values to your device.\n    low_pressure_voltage  = 0.45\n    high_pressure_voltage = 0.30\n    pressure = (low_pressure_voltage - volts) \/ (low_pressure_voltage - high_pressure_voltage)\n\n     # Check the serial input for new line of remote data\n    if supervisor.runtime.serial_bytes_available:\n        line = sys.stdin.readline()\n        tokens = line.split()\n        if len(tokens) == 1:\n            try:\n                remote_touch = [int(token) &amp;gt; 0 for token in tokens]\n                remote_touch_timer = 4.0\n            except ValueError:\n                pass\n\n    #---- periodic console output -----------------------------------\n    # Poll the time stamp to decide whether to emit console output.\n    if now &amp;gt;= sensing_timer:\n        sensing_timer += 100000000 #0.1sec\n\n    if pressure &amp;gt; 0.5:\n        remote_touch_timer = now + 4000000000 # 4 sec timeout\n\n    if now &amp;gt;= serial_timer:\n        serial_timer += serial_interval\n        touch = [&quot;1&quot; if pressure &amp;gt; 0.5 else &quot;0&quot;]]\n        print(&quot; &quot;.join(touch))\n\n    # If a slow movement has been received, sweep twice at a constant speed\n    if sweep_slow is True:\n        for angle in range(0, 180, 10):\n            actuator.angle = angle\n            time.sleep(0.02)\n            sweep_slow = False\n        print(&quot;Defense activated.&quot;)\n    else:\n        for angle in range(180, 0, -10):\n                actuator.angle = angle\n                time.sleep(0.02)\n        print(&quot;Disengage defense&quot;)\n\n    if any(remote_touch):\n        # Check whether there was any remote movement\n        if remote_touch[0]:\n            sweep_slow = True\n            print(&quot;Engage defense&quot;)\n        remote_touch = [False]\n\n    #---- periodic servo motion commands ----------------------------\n    # If the time has arrived to update the servo command signal:\n    if now &amp;gt;= next_servo_update:\n        next_servo_update += 20000000  # 20 msec in nanoseconds (50 Hz update)\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>For the next phase of the project, I fleshed out the details of construction. The general figure and form of the vest is seen in figure A. I&#8230;<\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts\/5186"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/comments?post=5186"}],"version-history":[{"count":7,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts\/5186\/revisions"}],"predecessor-version":[{"id":5212,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts\/5186\/revisions\/5212"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/media?parent=5186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/categories?post=5186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/tags?post=5186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}