Skip to content

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

  1. Download the Raspberry Pi imager
  2. Select Raspberry Pi 5 as the board
  3. Select Raspberry Pi OS (64-bit)
  4. Select your micro SD card.
  5. Select your configuration settings. Recommended settings include:
    • Host Name: hexapod-
    • User: hexapod
    • Enable SSH via authentication.
  6. Click save + wait.
  7. Once flashed, plug your micro SD card into your Pi and connect peripherals.

Install Docker

  1. Update the system:

    sudo apt update && sudo apt full-upgrade -y
    

  2. Download the Docker install script:

    curl -fsSL https://get.docker.com -o get-docker.sh
    

  3. Install Docker:

    sudo sh get-docker.sh
    

  4. Add your user to the docker group:

    sudo usermod -aG docker $USER
    

  5. Log out and back in (or reboot) for the group change to take effect:

    sudo reboot
    

  6. Verify the installation:

    docker --version
    docker compose version
    docker run hello-world
    

Add the Necessary Config Overrides

  1. Access the config file:

    sudo nano /boot/firmware/config.txt
    
  2. 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

  1. Install can-utils, which provides the ip link ... type can support used below, along with candump/cansend for debugging:

    sudo apt install can-utils
    

  2. Get the path to ip:

    which ip
    

    /usr/sbin/ip
    
  3. Create the file /etc/systemd/system/canbus.service with 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
    

  4. Bring the service up:

    sudo systemctl start canbus.service
    

Connect Xbox Core (Series S, X, etc) Controller

  1. Connect the controller via Raspberry Pi OS's Bluetooth UI or via terminal.

Update Docker User Config

  1. Navigate to non_real_time/container/src/ros2_ws/src/hexapod_manager/config/robot_name.local.txt.
  2. Add your Hexapod name to robot_name.local.txt. This should be the only text in the file.
  3. Make sure the robot name is in non_real_time/container/src/ros2_ws/src/hexapod_manager/launch/hexapod.launch.py with a unique ROS_DOMAIN_ID.
  4. Trigger a build:

    1. Initialize the dev container:

      ./init_dev.sh
      
    2. Get a new shell:

      ./new_dev_shell.sh
      
    3. Build the ROS2 Nodes

      colcon build
      
    4. 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