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.
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:
- 1x Raspberry Pi 4 (or any different model)
- 1x Raspberry Pi compatible power supply
- 1x MicroSD card
- 1x QWIIC I2C extender HAT (optional)
- 1x VEAB control board
- 1x 12V power supply
- 1x Enclosure (optional)
- 2x Festo regulators
- 1x Air compressor
- 1x Vacuum pump
- Tubes and cables
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.
(To write: Color code for Festo cable)
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.
The enclosure makes the setup a nice square box. The CAD files are provided in the hardware/enclosure
folder
(Add pictures) For a minimal working setup:
- Stack the VEAB control board on top of the Raspberry Pi
- Plug a Raspberry Pi OS loaded micro-SD card (See Initial setup) into the Pi
- Connect the 12V power line and the Festo cables to the VEAB control board
- Connect the pneumatic tubes to the Festo regulators, the air compressor and the vacuum pump (see diagram)
- Power on the Pi by plugging in the Pi's power supply
- Power on the whole system by turning on the 12V power supply
The software, written in Python (Pi side) and Matlab/Simulink (PC side) is documented in this section.
Before use, the SD card of the Pi must be set up.
-
Download the latest Raspbian OS from Raspberry Pi Homepage (You can skip this step if you use Raspberry Pi Imager)
-
Write the image on a microSD card (Raspberry Pi Imager or Balena Etcher is recommended for this task)
-
Prepare for the Raspberry Pi's first boot
- SSH: create an empty file named
ssh
in theboot
directory (this will enable SSH upon initial boot and the file will be automatically removed afterwards). - 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
- SSH: create an empty file named
-
In case you have a router that connects to the Pi and your host PC
- 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
- On the host PC, open a terminal and check the IP address of the ethernet connection using
ifconfig
(for Linux/OSX) oripconfig
(Windows). Look for the lineeth0
orenp5s0
or something similar and note the corresponding IP address (for example192.168.1.123
). This is the IP address of the host PC. - 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 example192.168.1.321
). This is the IP address of the Pi. Now the Pi is accessible via SSH on this IP address.
-
(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
- Configure the Raspberry Pi as a DHCP server (can be done via SSH or with a monitor and a keyboard attached to the Pi)
- Make sure the Pi has a working internet connection. Install
dnsmasq
by executingsudo apt install dnsmasq
- 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
- Backup
/etc/dnsmasq.conf
and create a new filesudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo nano /etc/dnsmasq.conf
- 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
- Restart the services with
sudo systemctl reboot
- 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 eitherserver.softrobot
or192.168.4.1
.
- Make sure the Pi has a working internet connection. Install
- Configure the Raspberry Pi as a DHCP server (can be done via SSH or with a monitor and a keyboard attached to the Pi)
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.
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
.
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.
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.
- Import the sensor library:
from adafruit_mprls import MPRLS
- Write a class for the sensor, using the
baseSensor
wrapper (Note that the__init__
andreadSensor
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
- Add a function to the
SoftRobot
class to handle the change of the number of sensorsdef 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)
- Run
addMPR
function after aSoftRobot
instance has been initialized (see 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
Please see software/MatlabSimulink
for more details.