Skip to content

Commit 46b5005

Browse files
Update pi documentation (UBC-Thunderbots#3571)
* Clarify Systemd section in robot-software-architecture.md Updated the systemd section to clarify the core service and provide a link to the thunderloop.service file. * Fixed incorrect markdown link format * Fixed thunderloop.service link * Modify Raspberry Pi playbook and service name details Updated playbook name for Raspberry Pi setup and clarified valid service names. * Create Raspberry Pi setup guide in setup-pi.md Added a comprehensive setup guide for installing Raspberry Pi OS onto a microSD card, including steps for using the Raspberry Pi Imager and verifying the installation. * Add Raspberry Pi configuration section to setup guide Added configuration instructions for Raspberry Pi with Thunderbots service, including SSH access and prerequisites. * Updated setup-pi.md Added network configuration, thunderloop service setup, and debugging steps to Raspberry Pi setup document. * Fixed formatting * Fix ssh command and imager config * [pre-commit.ci lite] apply automatic fixes * Fixed formatting nit * Clarified path to run bazel ansible command. * Fixed robot name nit * Update setup-pi.md with AppImage execution note * Addressed setup-pi.md nits * Addressed naming nit in useful-robot-commands.md * Minor formatting nits to bazel run ansible command * Revert "[pre-commit.ci lite] apply automatic fixes" This reverts commit b74c9a2. * Minor formatting fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 69827ba commit 46b5005

3 files changed

Lines changed: 125 additions & 6 deletions

File tree

docs/robot-software-architecture.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ More commands available [here](useful-robot-commands.md#off-robot-commands)
3535

3636
## Systemd
3737

38-
[Systemd](https://www.freedesktop.org/wiki/Software/systemd/) allows us to have services which start as soon as we boot the robot, will automatically restart and are individually controllable. All services have the file {service}.service, which controls the configuration of that service. Currently we have a service for thunderloop, announcements and display
39-
40-
To learn more about how it works, [see the RFC](https://docs.google.com/document/d/1hN3Us2Vjr8z6ihqUVp_3L7rrjKc-EZ-l2hZJc31gNOc/edit)
38+
[Systemd](https://www.freedesktop.org/wiki/Software/systemd/) allows us to have services which start as soon as we boot the robot, will automatically restart and are individually controllable. All services have the file {service}.service, which controls the configuration of that service. Our core service brought up by systemd is thunderloop. The thunderloop.service file can be seen [here](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/embedded/linux_configs/systemd/thunderloop.service).
4139

4240
## Redis
4341

docs/setup-pi.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Raspberry Pi Setup Guide
2+
3+
## Install Raspberry Pi OS onto MicroSD card
4+
5+
### Introduction
6+
7+
The microSD card in a Raspberry Pi holds its Operating System and acts as its primary storage area. The Pi will not work without it.
8+
9+
The Raspberry Pi 5 is compatible with many different (primarily Linux-based) operating systems. The one we use is the standard Raspberry Pi OS (also Linux-based).
10+
11+
### Install OS Using Raspberry Pi Imager
12+
13+
To install the Raspberry Pi OS onto a microSD card, we use the Raspberry Pi Imager program. Install it [here](https://www.raspberrypi.com/software/).
14+
15+
*Note: if using the "Download for Linux" option, you will have to right click on the installed `.AppImage` file and select `Properties` &rarr; `Permissions` &rarr; `Allow Executing File as Program` (this may appear as a checkbox)
16+
17+
When you open the imager, you should see something like this:
18+
19+
* <img width="402" height="159" alt="image" src="https://github.com/user-attachments/assets/b31e03e3-0d25-4b99-b0d5-0168387f715d" />
20+
21+
Once installed, follow these steps to set up the Raspberry Pi:
22+
1. Plug the microSD card into your device.
23+
* If your device has an SD card slot, use a microSD to SD card adapter. This adapter is available in the tbots EDC space as of Jan 2026.
24+
* If your device only has a USB slot, use a combination of a microSD to SD card adapter and USB SD card reader. Again, both of these adapters are available in the tbots EDC space.
25+
2. Open and configure the Raspberry Pi Imager program as follows:
26+
* Raspberry Pi Device: Raspberry Pi 5
27+
* Operating System: Raspberry Pi OS (64-bit)
28+
* Storage: `<your_inserted_micro_SD_card>`
29+
* Customization:
30+
* Hostname: `<robot_name>`.local (Ex: `aimbot`.local). The `local` part is autofilled by the Raspberry Pi Imager.
31+
* Localization &rarr; Timezone: America/Vancouver
32+
* User &rarr; Username: robot
33+
* User &rarr; Password: `<password>` (ask someone if you don't know what the correct password is)
34+
* WiFi &rarr; Secure Network &rarr; SSID: `<tbots_wifi_name>` (`tbots` as of Jan 2026)
35+
* WiFi &rarr; Password: `<password>` (ask someone if you don't know what the correct password is)
36+
* Remote Access: Enable SSH and select "Use Password Authentication"
37+
* Click the "Write" button and wait until complete
38+
39+
Once the write process is complete, the Raspberry Pi OS is set up! You can verify the write was successful using several methods; the following is only one of these methods:
40+
* Connect the Raspberry Pi to an HDMI output screen using a microHDMI to HDMI cable.
41+
* You can also use an HDMI to HDMI cable with a microHDMI to HDMI adapter. We have one of these adapters in the tbots EDC space as of Jan 2026.
42+
* The output screen on the HDMI should appear similar to a default laptop/PC screen. If this is the case, the write was successful.
43+
* If you do not see the above, and instead see text on a black screen with messages akin to "Unable to read partition as FAT" - the write was not successful.
44+
45+
## Configure Raspberry Pi with Thunderbots Service
46+
47+
### Introduction
48+
49+
We use the Raspberry Pi OS, which is based on the Linux kernel. The Linux kernel uses systemd as its service manager. Our core service is [thunderloop.service](https://github.com/UBC-Thunderbots/Software/blob/master/src/software/embedded/linux_configs/systemd/thunderloop.service).
50+
51+
To run and manage the thunderloop service on the Pi, however, there are many dependencies (drivers, admin control, internet, etc.) that must be set up first. Luckily, all of this setup can be done using one command with an Ansible playbook.
52+
53+
Read more about Ansible in our robot software architecture documentation [here](https://github.com/UBC-Thunderbots/Software/blob/master/docs/robot-software-architecture.md#ansible).
54+
55+
### Configuration
56+
57+
#### Internet Configuration
58+
59+
Before running the Ansible command, we must do the following to configure internet access to the Pi:
60+
1. Ensure your Raspberry Pi is connected to internet through an ethernet cable. Do this by connecting one end to the Rapsberry Pi and the other to your device (PC/laptop). Ensure your ethernet cable is not broken, as there are many non-functioning ones in the Thunderbots EDC space.
61+
2. On your device (PC/laptop), configure network settings through the following steps:
62+
1. Go to network settings. You should see something like this:
63+
64+
* <img width="446" height="77.5" alt="image" src="https://github.com/user-attachments/assets/20f9b3e5-e629-40c7-ac49-024f34df66ca" />
65+
66+
2. Click the settings icon on the right (seen in the image above).
67+
3. Under the IPv4 tab, select "Shared to other computers"
68+
69+
* <img width="471.5" height="132.5" alt="image" src="https://github.com/user-attachments/assets/ee776fbc-7fec-4e7d-89da-35b48de4df4f" />
70+
71+
4. Under the IPv6 tab, select "Disable"
72+
* <img width="471.5" height="132.5" alt="image" src="https://github.com/user-attachments/assets/7ad2cba4-42bf-4204-a182-a087e7f632e2" />
73+
74+
5. Apply changes
75+
3. Enable IP forwarding from your device to the Pi with the following command (this has to be reconfigured every time you boot your device):
76+
```bash
77+
sudo sysctl -w net.ipv4.ip_forward=1
78+
```
79+
4. Enable Network Address Translation (NAT) between your Pi and device with the following commands (this has to be reconfigured every time you boot your device):
80+
```bash
81+
sudo iptables -t nat -A POSTROUTING -o wlo1 -j MASQUERADE
82+
sudo iptables -A FORWARD -i eno2 -o wlo1 -j ACCEPT
83+
sudo iptables -A FORWARD -i wlo1 -o eno2 -m state --state RELATED,ESTABLISHED -j ACCEPT
84+
```
85+
86+
#### Thunderloop Service Configuration Through Ansible
87+
1. SSH into the Raspberry Pi from your device by connecting to the `tbots` WiFi and typing the following in the command terminal:
88+
* ssh `robot@<robot_name>` (Ex: `ssh robot@aimbot.local`)
89+
* enter the password when prompted
90+
2. Verify that the Pi has internet connection by pinging Google's Public DNS Service with the following command:
91+
```bash
92+
ping -c 3 8.8.8.8
93+
```
94+
* If successful, you should see all packets transmitted and received at some point in the return message. Ex: ```3 packets transmitted, 3 received, 0% packet loss, time 2004ms```.
95+
* If not successful, you will see packets not received. Ex: ```3 packets transmitted, 0 received, 100% packet loss, time 2052ms```.
96+
3. Exit the SSH connection to the Raspberry Pi with the `exit` command.
97+
4. Change directory to `Software/src` and run the bazel ansible command:
98+
```bash
99+
bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:robot --//software/embedded:host_platform=PI -- --playbook setup_pi.yml --hosts <robot_name>.local --ssh_pass <robot_password>
100+
```
101+
* Ensure you configure `<robot_name>` and `<password>` in the command above. Copy/pasting the above won't work.
102+
* This may take a while.
103+
5. Done!
104+
105+
### Common Errors and Debugging
106+
107+
**Cannot SSH into Pi**
108+
A: Confirm that your device is connected to the `tbots` WiFi
109+
110+
**Raspberry Pi shuts off (light turns red, HDMI output disconnects if connected) while the Bazel Ansible command is running**
111+
A: This is a power brownout (voltage drops below required threshold). There are too many peripherals connected. Disconnect some and try again.
112+
113+
**Raspberry Pi unresponsive and LED always solid green**
114+
A: This is usually an indicator that the Pi's SD Card is corrupted or empty. Operational Raspberry Pi's usually have a flickering LED. Fix by reprovisioning the SD Card with the Raspberry Pi Imager (directions above).
115+
116+
117+
118+
119+
120+
121+

docs/useful-robot-commands.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:ro
156156
### Raspberry Pi
157157

158158
```bash
159-
bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:robot --//software/embedded:host_platform=PI -- --playbook setup_raspberry_pi.yml --hosts <robot_ip> --ssh_pass <robot_password>
159+
bazel run //software/embedded/ansible:run_ansible --platforms=//toolchains/cc:robot --//software/embedded:host_platform=PI -- --playbook setup_pi.yml --hosts <robot_ip> --ssh_pass <robot_password>
160160
```
161161

162162
## Robot Diagnostics
@@ -189,7 +189,7 @@ Runs the robot auto test fixture on a robot through Ansible, which tests the mot
189189
From Software/src:
190190

191191
```bash
192-
bazel run //software/embedded/ansible:run_ansible --//software/embedded:host_platform=<platform> --platforms=//toolchains/cc:robot -- --playbook robot_auto_test_playbook.yml --hosts <robot_ip> --ssh_pass <robot_password>
192+
bazel run //software/embedded/ansible:run_ansible --//software/embedded:host_platform=<platform> --platforms=//toolchains/cc:robot -- --playbook robot_auto_test_playbook.yml --hosts <robot_name> --ssh_pass <robot_password>
193193
```
194194

195195
* replace the \<platform\> with the target platform for the robot (either `PI` or `NANO`)
@@ -202,7 +202,7 @@ bazel run //software/embedded/ansible:run_ansible --//software/embedded:host_pla
202202

203203
## Systemd Services
204204

205-
Status shows whether the service is running and some recent logs. More logs can be found using `journalctl` shown below. More control can be achieved with `systemctl`. Valid `<service_name>` are `thunderloop`, `display`, and `wifi_announcements`
205+
Status shows whether the service is running and some recent logs. More logs can be found using `journalctl` shown below. More control can be achieved with `systemctl`. Currently, the only valid `<service_name>` is `thunderloop`.
206206

207207
```bash
208208
service <service_name> status

0 commit comments

Comments
 (0)