Raspberry Pi Setup
This section will walk you through configuring the Raspberry Pi 5 with Raspberry Pi OS, Docker, and ROS2.
Requirements
- Raspberry Pi 5
- Micro SD Card (64GB+ preferred).
- Micro HDMI to HDMI cable.
- USB connected keyboard.
- USB connected mouse.
Flash the SD Card
- Download the Raspberry Pi imager
- Select
Raspberry Pi 5as the board - Select
Raspberry Pi OS (64-bit) - Select your micro SD card.
- Select your configuration settings. Recommended settings include:
- Host Name: hexapod-
- User: hexapod
- Enable SSH via authentication.
- Host Name: hexapod-
- Click save + wait.
- Once flashed, plug your micro SD card into your Pi and connect peripherals.
Install Docker
-
Update the system:
sudo apt update && sudo apt full-upgrade -y -
Download the Docker install script:
curl -fsSL https://get.docker.com -o get-docker.sh -
Install Docker:
sudo sh get-docker.sh -
Add your user to the
dockergroup:sudo usermod -aG docker $USER -
Log out and back in (or reboot) for the group change to take effect:
sudo reboot -
Verify the installation:
docker --version docker compose version docker run hello-world
Add the Necessary Config Overrides
-
Access the config file:
sudo nano /boot/firmware/config.txt -
Add the following lines to the end of the file:
dtparam=spi=on dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
Automatically Launch CAN at Startup
-
Install
can-utils, which provides theip link ... type cansupport used below, along withcandump/cansendfor debugging:sudo apt install can-utils -
Get the path to
ip:which ip/usr/sbin/ip -
Create the file
/etc/systemd/system/canbus.servicewith the following contents, using the path from the step above:[Unit] Description=CAN Bus Interface [Service] ExecStart=/usr/sbin/ip link set can0 up type can bitrate 500000 Type=oneshot RemainAfterExit=yes [Install] WantedBy=multi-user.target -
Bring the service up:
sudo systemctl start canbus.service
Connect Xbox Core (Series S, X, etc) Controller
- Connect the controller via Raspberry Pi OS's Bluetooth UI or via terminal.
Update Docker User Config
- Navigate to
non_real_time/container/src/ros2_ws/src/hexapod_manager/config/robot_name.local.txt. - Add your Hexapod name to
robot_name.local.txt. This should be the only text in the file. - Make sure the robot name is in
non_real_time/container/src/ros2_ws/src/hexapod_manager/launch/hexapod.launch.pywith a unique ROS_DOMAIN_ID. -
Trigger a build:
-
Initialize the dev container:
./init_dev.sh -
Get a new shell:
./new_dev_shell.sh -
Build the ROS2 Nodes
colcon build -
Next time you restart the pi, the changes will take effect. To test you can also run:
docker compose -f docker-compose-prod.yml up
-