During the setup process, each robot runs an automatic setup script which clones the firmware from a GitHub repository. By default, the setup script clones the official GTernal repository. This needs to be changed to clone your repository with updated configuration files. If you are not familiar with Git or GitHub, please refer to here: https://docs.github.com/en/get-started/quickstart/fork-a-repo
- Fork this GTernal repository.
- Clone the forked repository to your computer.
- Update 'GTernal/config/env_variables.sh'
- Push the change to your repository.
- Install Teensyduino (https://www.pjrc.com/teensy/td_download.html)
- Copy and paste all library folders in
GTernal/firmware/Teensy/libraries
toArduino/libraries
.
Note
The absolute path for the Arduino/libraries
directory is OS dependent, and this can be found here: https://support.arduino.cc/hc/en-us/articles/4412950938514-Open-the-Sketchbook
Note
The firmware for Teensy requires ArduinoJson 5.13 which is included in GTernal/firmware/Teensy/libraries
.
ArduinoJson 6 is currently not compatible with the firmware.
- Connect a Teensy to the computer using a micro-USB cable.
Note
The micro-USB cable needs to be directly connected to the Teensy and not the micro-USB port on the robot PCB.
- Run Teensyduino and open
defaultOperation.ino
located inGTernal/firmware/defaultOperation
directory. - Select the Teensy board to be flashed under
Tools > Port
- Click the upload icon (right arrow icon).
- Install and run the Raspberry Pi Imager (https://www.raspberrypi.com/software/). The instuction is for Raspberry Pi Imager v.1.8.5
- For 'Raspberry Pi Device,' select the version of the Pi used.
- For 'Operating System,' select
Raspberry Pi OS (other)
and selectRaspberry Pi OS (Legacy, 64-bit) Lite
. For Raspberry Pi Zero 1s, selectRaspberry Pi OS (Legacy, 32-bit) Lite
. - For 'Storage,' choose the micro-SD card to be used.
- Click 'NEXT' and 'EDIT SETTINGS.'
- Under 'GENERAL' tab, check 'Set username and password' and type
pi
for the 'Username' andraspberry
for 'Password.' - Next, check 'Configure wireless LAN' and enter 'SSID' and 'Password' for the router.
- Change 'Wireless LAN country' to 'US.' 'Set locale settings' is optional.
- Under 'SERVICES' tab, check 'Enable SSH' and 'Use password authentication'
- Click 'SAVE' and click 'YES.'
Note
Whenever the Raspberry Pi Imager is restarted, make sure to re-type the passwords for the Pi and the Wifi. The Raspberry Pi Imager seems to be ruining the passwords saved in the advanced setting when the program is restarted even if the 'Image customization options' is set to 'to always use.'
-
Insert the SD card from the previous step into a Raspberry Pi and power it on. It should automatically connect to the wifi specified in Step 2.1.7. The Pi needs some time to boot for the first time.
-
Identify the MAC address of the Raspberry Pi. On a Linux comptuer, this can be done by running
sudo arp-scan -I <network-device-name> -l -t 100 -r 5
Alternatively, you can navigate to the router settings page (typically '192.168.1.1' or '10.0.0.1') using a web browser. The new Pi will appear as 'RASPBERRYPI.'
-
Add the MAC address to 'path-to-parent-directory/GTernal/config/mac_list.json' file as
"<MAC-address-of-Pi>":"base_image"
e.g.,
{ "d8:3a:dd:bc:0c:3c":"base_image" }
-
On your computer, run
cd <path-to-parent-directory>/GTernal/interfacing ./setup.sh setup_base_image
When prompted for password, enter the password of your computer. When prompted 'Enter secrets for robots,' enter the password for the Raspberry Pis,
raspberry
. This will automatically setup the SD card as the base image. Wait for 'DONE SETTING UP BASE IMAGE' message on the terminal. -
In case of using another network for the robot for actual deployment, edit the wireless LAN credentials. First, ssh into the robot.
ssh pi@<ip-address-of-robot>
Then, edit the wpa_supplicant.conf file to update the wireless LAN credentials.
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
-
(Optional) Pull the base firmware image to reduce the setup time.
- If the wireless LAN credential has changed in the previous step, restart the Raspberry Pi.
ssh pi@<ip-address-of-robot> sudo reboot
- Follow the instructions in Section 4 up to 4.1.2.
- Next, ssh into the robot.
ssh pi@<ip-address-of-robot>
- Run
cd <path-to-parent-directory>/GTernal/docker/base_image/ ./docker_pull.sh
- If the wireless LAN credential has changed in the previous step, restart the Raspberry Pi.
-
On the ssh terminal, shutdown the Pi by running
sudo reboot
-
Remove the SD card from the Pi and insert it to your computer.
-
On your computer, identify the name of the SD card by running
sudo fdisk -l
The device name will be something like '/dev/sdb'. Look for the device with the storage size that matches the capacity of the SD card.
Note
You must enter the device name without any numbers. For example, if you see '/dev/sdb1' and '/dev/sdb2', the device name is /dev/sdb
.
- Create the image of the SD card on your computer by running
e.g.,
sudo dd if=<name-of-the-sd-card> of=<desired-directory>/GTernal_base_image.img bs=4M status=progress
sudo dd if=/dev/sdb of=~/GTernal_base_image.img bs=4M status=progress
- Shrink the size of the base image by running
e.g.,
wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh chmod +x ./pishrink.sh sudo ./pishrink.sh <path-to-the-base-image>/GTernal_base_image.img
sudo ./pishrink.sh ~/GTernal_base_image.img
- Insert a new SD card into your computer to load the base image.
- Identify the name of the SD card by running
sudo fdisk -l
- Run
e.g.
sudo mount | grep <device-name>
sudo mount | grep /dev/sdb
to check if any of the partitions of the SD card is mounted.
If the output is not blank, rune.g.sudo umount <device-name1> <device-name2> ... <device-nameN>
sudo umount /dev/sdb1 /dev/sdb2
to unmount all listed partitions of the device. - Load the SD card with the base image by running
e.g.,
sudo dd if=<path-to-the-base-image>/GTernal_base_image.img of=<name-of-the-sd-card> status=progress
sudo dd if=~/GTernal_base_image.img of=/dev/sdb bs=4M status=progress
Note
The status message may stop updating at some point. Please continue waiting for the write process to finish.
- Load as many SD cards as needed with the base image. More detailed instructions on cloning an SD card image can be found here: https://beebom.com/how-clone-raspberry-pi-sd-card-windows-linux-macos/
This section assumes that:
- You have micro-SD cards loaded as detailed in the previous section.
- You have fully assembled robots.
Note
Check if the Pi and Teensy are connected through UART. If the Pi is not connected with a programmed Teensy as instructed in Step 1, the firmware will not be started by the setup script properly in the following steps.
- Only the new robots to be setup are connected to the WiFi.
Warning
The current automatic setup script looks for all robots with the MAC addresses specified in 'GTernal/config/mac_list.json' file and starts the setup process for the robots. Therefore, it will start the setup process even for the robots already with the firmware installed if they are connected to the WiFi. Since this may cause problems for the existing robots, it is advised to only turn on the new robots to be set up.
The "docker_run.sh" script makes each robot pull the firmware image from either Docker Hub of a local Docker registry instead of building the firmware docker image directly on each robot. This saves a lot of time when building multiple robots. Also, with "v2tec/watchtower" image running on the robots, each robot downloads and runs the newest firmware image uploaded to the Docker Hub automatically. Therefore, it is unnecessary to manually update the firmware of each robot when a new firmware image is built and pushed to Docker Hub/local Docker registry.
- Inspect and update the environment variables in
config/env_variables.sh
- Build the base image
cd <path-to-parent-directory>/GTernal/docker/base_image/ ./docker_build.sh
- Log into the Docker Hub with
docker login
- Run
cd <path-to-parent-directory>/GTernal/docker/base_image/ ./docker_push.sh
- Start a local Docker registry
cd <path-to-parent-directory>/GTernal/docker/ ./docker_registry.sh
- Run
cd <path-to-parent-directory>/GTernal/docker/base_image/ ./docker_push_local.sh
- Build the firmware image
cd <path-to-parent-directory>/GTernal/docker/ ./docker_build.sh
- Run
cd <path-to-parent-directory>/GTernal/docker/ ./docker_push.sh
- Run
cd <path-to-parent-directory>/GTernal/docker/ ./docker_push_local.sh
-
Insert the loaded micro-SD cards to the robots' Raspberry Pis and power the robots up using the switch on each PCB. They should automatically connect to the wifi specified in Step 3.7.
-
On your computer, check if all the Raspberry Pis are connected to the WiFi router by running
sudo arp-scan -I <network-device-name> -l -t 100 -r 5
e.g.,
sudo arp-scan -I enp4s0 -l -t 100 -r 5
Check if the number of Raspberry Pis found by the above command matches the total number of Raspberry Pis being set up. Wait a few more minutes and check again if not all Pis show up in the list.
Note
The <network-device-name> can be found by running 'ifconfig' command into the terminal. There may be multiple network devices on your computer. The right device is the one connected to the same WiFi network as the Raspberry Pis. Typically, the local IP address assigned by a network router is '192.168.x.x' or '10.0.x.x.'
- Assign an unallocated robot ID# for the MAC address of a Raspberry Pi found in the previous step. Then, add/replace the robot ID# and the MAC address of the Raspberry Pi in 'GTernal/config/mac_list.json'
Note
When assigning an index to a new robot, assign an Aruco tag ID or the ID engraved on a Vicon hat plate. Make sure not to use any numbers that are already assigned to other robots. The lasercutting design files for the Vicon hats can be found in GTernal/GTernal_design_files
-
Start the setup process by running
cd path-to-parent-directory/GTernal/interfacing ./setup.sh setup_from_base <#-of-robots-being-set-up>
e.g.,
./setup.sh setup_from_base 10
When prompted 'Enter secrets for robots,' enter the password for the Raspberry Pis, 'raspberry'
Note
The config/mac_list.json file of the robots will be updated to the config/mac_list.json file on your computer via SCP.
-
Clone the mqtt_broker repo
git clone https://github.com/robotarium/mqtt_broker.git
-
Run the MQTT broker Docker container
cd <path-to-parent-directory>/mqtt_broker/docker/ ./docker_run.sh <ip-address-of-your-computer>
-
Clone the vizier repository with
git clone https://github.com/robotarium/vizier.git
-
Install vizier with
cd path-to-parent-directory/vizier python3 -m pip install .
-
Check the status of a robot with
python3 -m vizier.vizier --host <ip-address-of-MQTT-host> --get <robot#>/status
e.g.,
python3 -m vizier.vizier --host 192.168.1.8 --get 21/status
-
Send a motor command to a robot with
python3 -m vizier.vizier --host <ip-address-of-MQTT-host> --publish matlab_api/<robot#> '{"v":1.0,"w":0.0}'
e.g.,
python3 -m vizier.vizier --host 192.168.1.8 --publish matlab_api/21 '{"v":1.0,"w":0.0}'
"v" and "w" are the desired linear and angular velocity of the robot, respectively. With this command, the robot will stop after 1 second for safety purposes.