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.

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’ll 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.

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.

Software Progress

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’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.

Code

"""
Project 2: Active Proxy Body

Helen Yu (heleny1), Rebecca Kim

Written by Helen Yu
Last Updated: 4/26/21

Summary: When you clench your pump and inflate your vest, your
partner's vest leaps into defense mode. A hobby servo helps control
the defense mechanism, be it spikes, projectiles, webs, etc.

Inputs: Soft Touch Sensor on A2
Outputs: Hobby Servo on SD A5
"""
# ----------------------------------------------------------------
# Import any needed standard Python modules.
import time, math

# Import the board-specific input/output library.
from adafruit_circuitplayground import cp

# Import the low-level hardware libraries.
import board
import digitalio
import analogio
import pwmio

# Import the Adafruit helper library.
from adafruit_motor import servo

# ----------------------------------------------------------------
# Initialize hardware.

# Configure the digital input pin used for its pullup resistor bias voltage.
bias = digitalio.DigitalInOut(board.D10)        # pad A3
bias.switch_to_input(pull=digitalio.Pull.UP)

# Configure the analog input pin used to measure the sensor voltage.
sensor = analogio.AnalogIn(board.A2)
scaling = sensor.reference_voltage / (2**16)

# Create a PWMOut object on pad SDA A5 to generate control signals.
pwm = pwmio.PWMOut(board.A5, duty_cycle=0, frequency=50)

# Create a Servo object which controls a hobby servo using the PWMOut.
actuator = servo.Servo(pwm, min_pulse=1000, max_pulse=2000)
actuator.angle = 0

# ----------------------------------------------------------------
# Initialize global variables for the main loop.

remote_touch = [0]

# Measure the time since the last remote move message, and reset after a period without data.
remote_touch_timer = False

# Convenient time constant expressed in nanoseconds.
second = 1000000000

# Integer time stamp for the next console output.
sensing_timer = time.monotonic()

# Integer time stamp for next behavior activity to begin.
next_activity_time = time.monotonic_ns() + 2 * second

# Flag to trigger motion.
sweep_slow = False

phase_angle = 0.0
phase_rate  = 2*math.pi / 6.0  # one cycle per six seconds, in radians/second

# Integer time stamp for next servo update.
next_servo_update = time.monotonic_ns()

# The serial port output rate is regulated using the following timer variables.
serial_timer    = 0.0
serial_interval = 0.5

# ----------------------------------------------------------------
# Begin the main processing loop.
while True:

    # Read the current integer clock.
    now = time.monotonic()

     #---- soft sensor input and display -----------------------------
    # Read the integer sensor value and scale it to a value in Volts.
    volts = sensor.value * scaling

    # Normalize the soft sensor reading.  Typically you'll need to adjust these values to your device.
    low_pressure_voltage  = 0.45
    high_pressure_voltage = 0.30
    pressure = (low_pressure_voltage - volts) / (low_pressure_voltage - high_pressure_voltage)

     # Check the serial input for new line of remote data
    if supervisor.runtime.serial_bytes_available:
        line = sys.stdin.readline()
        tokens = line.split()
        if len(tokens) == 1:
            try:
                remote_touch = [int(token) > 0 for token in tokens]
                remote_touch_timer = 4.0
            except ValueError:
                pass

    #---- periodic console output -----------------------------------
    # Poll the time stamp to decide whether to emit console output.
    if now >= sensing_timer:
        sensing_timer += 100000000 #0.1sec

    if pressure > 0.5:
        remote_touch_timer = now + 4000000000 # 4 sec timeout

    if now >= serial_timer:
        serial_timer += serial_interval
        touch = ["1" if pressure > 0.5 else "0"]]
        print(" ".join(touch))

    # If a slow movement has been received, sweep twice at a constant speed
    if sweep_slow is True:
        for angle in range(0, 180, 10):
            actuator.angle = angle
            time.sleep(0.02)
            sweep_slow = False
        print("Defense activated.")
    else:
        for angle in range(180, 0, -10):
                actuator.angle = angle
                time.sleep(0.02)
        print("Disengage defense")

    if any(remote_touch):
        # Check whether there was any remote movement
        if remote_touch[0]:
            sweep_slow = True
            print("Engage defense")
        remote_touch = [False]

    #---- periodic servo motion commands ----------------------------
    # If the time has arrived to update the servo command signal:
    if now >= next_servo_update:
        next_servo_update += 20000000  # 20 msec in nanoseconds (50 Hz update)