Skip to content

Latest commit

 

History

History
173 lines (144 loc) · 11.3 KB

Docs.md

File metadata and controls

173 lines (144 loc) · 11.3 KB

Introduction

This is the documentation for the soft robotic setup. The robot is powerered with high pressure (which is generated by an air compressor and regulated by Festo regulators). Please browse the content using the table of contents below.

Hardware

The setup has some commercially available and some custom-made componenets. Below is the list of the components for one setup with two Festo regulators:

  1. 1x Raspberry Pi 4 (or any different model)
  2. 1x Raspberry Pi compatible power supply
  3. 1x MicroSD card
  4. 1x QWIIC I2C extender HAT (optional)
  5. 1x VEAB control board
  6. 1x 12V power supply
  7. 1x Enclosure (optional)
  8. 2x Festo regulators
  9. 1x Air compressor
  10. 1x Vacuum pump
  11. Tubes and cables

VEAB control board

The VEAB control board has two analog-to-digital converters and two digital-to-analog converters to control the Festo regulators and to read the internal sensor of the regulators. The fabrication of the board is documented in a separate file in the hardware folder. The VEAB board is the intermediary between the Pi and the Festo regulators. The VEAB control board uses I2C to communicate with the Raspberry Pi. It can be either on top of the Pi or connected to the Pi via a QWIIC cable. The two four-pin ports in the middle of the board should be connected to Festo cables with a female end. The two-pin port next to the Festo ports is the 12V power supply port.

Alt text

(To write: Color code for Festo cable)

QWIIC I2C extender HAT

The QWIIC I2C extender HAT allows the use of additional I2C channels of the Raspberry Pi 4. By default, only one channel can be enabled, however, with the HAT, six channels can be used simultaneously. In other words, six I2C devices with the same address can be attached to the setup without having the problem of address conflicts.

Enclosure

The enclosure makes the setup a nice square box. The CAD files are provided in the hardware/enclosure folder

Assembly guide

(Add pictures) For a minimal working setup:

  1. Stack the VEAB control board on top of the Raspberry Pi
  2. Plug a Raspberry Pi OS loaded micro-SD card (See Initial setup) into the Pi
  3. Connect the 12V power line and the Festo cables to the VEAB control board
  4. Connect the pneumatic tubes to the Festo regulators, the air compressor and the vacuum pump (see diagram)
  5. Power on the Pi by plugging in the Pi's power supply
  6. Power on the whole system by turning on the 12V power supply

Software

The software, written in Python (Pi side) and Matlab/Simulink (PC side) is documented in this section.

Initial setup

Before use, the SD card of the Pi must be set up.

Set up Raspberry Pi OS, network and I2C

  1. Download the latest Raspbian OS from Raspberry Pi Homepage (You can skip this step if you use Raspberry Pi Imager)

  2. Write the image on a microSD card (Raspberry Pi Imager or Balena Etcher is recommended for this task)

  3. Prepare for the Raspberry Pi's first boot

    1. SSH: create an empty file named ssh in the boot directory (this will enable SSH upon initial boot and the file will be automatically removed afterwards).
    2. Enable I2C fast mode: Add the following line to /boot/config.txt:
      dtparam=i2c_arm=on,i2c_arm_baudrate=400000
      dtoverlay=i2c7
      dtoverlay=i2c6
      dtoverlay=i2c5
      dtoverlay=i2c4
      dtoverlay=i2c3
      
  4. In case you have a router that connects to the Pi and your host PC

    1. Once powered up, connect the Raspberry pi using the ethernet cable to the router. I think this step is unnecessary because we don't need to know the IP of the host PC
    2. On the host PC, open a terminal and check the IP address of the ethernet connection using ifconfig (for Linux/OSX) or ipconfig (Windows). Look for the line eth0 or enp5s0 or something similar and note the corresponding IP address (for example 192.168.1.123). This is the IP address of the host PC.
    3. Find the IP address of the Pi by running ifconfig on the Pi's terminal. Look for the IP address with the same leading 3 triple digits (for example 192.168.1.321). This is the IP address of the Pi. Now the Pi is accessible via SSH on this IP address.
  5. (Skip this step if you have a router or if you already established a connection to the Pi) In case you do not have a router and need to connect the Pi and the host PC directly using an ethernet cable

    1. Configure the Raspberry Pi as a DHCP server (can be done via SSH or with a monitor and a keyboard attached to the Pi)
      1. Make sure the Pi has a working internet connection. Install dnsmasq by executing sudo apt install dnsmasq
      2. Assign a static IP address to the Pi's Ethernet eth0 by adding these lines to the file /etc/dhcpcd.conf
        interface eth0
            static ip_address=192.168.4.1/24
        
      3. Backup /etc/dnsmasq.conf and create a new file
        sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
        sudo nano /etc/dnsmasq.conf
        
      4. Add to the new file
        interface=eth0 # Listening interface
        dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
                    # Pool of IP addresses served via DHCP
        domain=softrobot     # Local wireless DNS domain
        address=/server.softrobot/192.168.4.1
                    # Alias for this router
        
      5. Restart the services with sudo systemctl reboot
      6. Make sure the Ethernet adapter on your host PC is not static (normally it is not static if you have not deliberately chosen that setting). Plug an Ethernet cable to the ports on the Pi and your host PC. The host PC will be automatically assigned an IP address in the range 192.168.4.2-20 The Pi is accessible at either server.softrobot or 192.168.4.1.

Python script

The main software of the setup, written in Python, is designed in three layers to optimize for speed, convenience, and versatility. The setup can read multiple sensors and control several VEAB regulators simultaneously, as well as communicate with other devices via TCP/IP.

First layer

The first layer of the software provides two base classes: baseSoftRobot.py and baseSensor.py. The class baseSoftRobot.py sets up the multi-processing environment that handles the TCP/IP communication for the array of VEAB regulators and sensors. Multi-processing is used here to process data in parallel, improving not only the speed of the system but also the timing precision. The class baseSensor.py serves as a wrapper for other sensor classes. Both classes act as parents for other classes in the next layer.

The baseSoftRobot class has several functions to set up the TCP communication. The __init__ function initializes the internal variables that the TCP communication uses. The repeatedlySend and receive functions are for continuously exchanging data, and they are called automatically in the createProcesses function. To run the processes, one needs to explicitly call the run function. After run is called, the Python interpreter will execute the next command, thus to prevent Python from exitting, one should call waitForProcesses.

Second layer

The second layer facilitates all communication between the Raspberry Pi and the VEAB control board and/or other sensors. First, necessary libraries are imported. Next, sensor classes are written as children of the baseSensor.py class, and in each sensor class, a function called ReadSensor must be implemented when using sensors. Finally, the class SoftRobot, inheriting all functions of baseSoftRobot.py, is assembled from all software parts relating to the TCP/IP communication, regulators, and sensors. To some extent, the class SoftRobot acts as the main class of the software architecture that encompasses the user's requirement.

Add sensors (for instance, a MPRLS pressure sensor)

The procedure to add sensors to the code is written in this section. In general, if the sensors use I2C connection, it can be added. An example of adding a MPRLS sensor is provided.

  1. Import the sensor library: from adafruit_mprls import MPRLS
  2. Write a class for the sensor, using the baseSensor wrapper (Note that the __init__ and readSensor must be defined)
    class PressureSensor(baseSensor):
     def __init__(self, i2c=1):
         MPR = MPRLS(I2C(i2c), psi_min=0, psi_max=25)
         super().__init__(MPR)
     def readSensor(self):
         return self.instance.pressure
  3. Add a function to the SoftRobot class to handle the change of the number of sensors
    def addMPR(self,i2c = 1):
        self.nSensors = self.nSensors+1
        self.sensors.append(PressureSensor())
        self.sensorsValues = multiprocessing.Array('d',[0.0]*(self.nSensors))
        super().__init__(self.nSensors, self.port)
        print("Adding one MPR sensor on I2C channel ", i2c)
  4. Run addMPR function after a SoftRobot instance has been initialized (see Third layer)

Third layer

The third layer is dispensable and added for the convenience of users. This layer is a Python script that takes the arguments and initialized a SoftRobot object accordingly. Changing the parameters of the software (i.e., number of sensors and actuators, sampling frequency, setting the TCP port) is no longer an arduous task of re-writing the code.

The script initializes the SoftRobot object and runs the required methods. An external controller (Simulink model, Matlab/C programs, etc) should connect to the robot (i.e, the server) after the call of waitForClient.

 robot = SoftRobot() # Some arguments can be parsed to the call
 robot.addMPR # Add MPR Sensor, for example
 robot.waitForClient() # Can be called many times to connect more clients
 robot.createProcesses() # Initialize all the processes needed for I2C sensors, motors, TCP/IP comm
 robot.run() # Start the processes
 robot.waitForProcesses() # Wait for the processes to end

Matlab and Simulink

Please see software/MatlabSimulink for more details.

Examples

Simple send and receive

Feedforward and feedback control

Interface with Unity