x

Raspberry Pi Setup

This guide will outline the steps taken to setup the baseline software on the Raspberry Pi 4.

Info

This project recommends using a Raspberry Pi with at least 4GB of RAM. Compiler issues have been encounter with the 2GB variant.

Setup OS Installation

  1. Install Raspberry PI Imager https://www.raspberrypi.com/software/
  2. Select gear for advance option to specify a hostname, username, password, and network configurations ^rpi-os-config
  3. Flash Raspberry PI OS 64-bit to Micro SD Card
    1. Alternatively setup NVMe boot with NVMe hat

Setup SSH

  1. Test ssh access ssh <user>@<rpi-local-ip> Use the password you configured in the step
  2. Reserve a static local IP address for within the router's configuration
  3. Reboot the pi
    On host machine: ssh -t <user>@<rpi-local-ip> "reboot"
    Or, within the pi ssh terminal reboot
  4. Test ssh access with machine name
    ssh <user>@<hostname>
  5. Create SHH Key Pair
    On host machine: ssh-keygen -f ~/.ssh/<key-name>
  6. Copy SHH pubic key to the raspberry pi
    On host machine: ssh-copy-id -i ~/.ssh/<key-name> <user>r@<rpi-machine-name>
  7. Add ssh config to host machine ^rpi4-ssh-config
    1. On host machine: xdg-open ~/.ssh/config
    2. Copy-paste the following, this project is using rpi4 as the config-name
Host <config-name>
    HostName <local-reserved-static-ip>
    User bot
    IdentityFile ~/.ssh/<key-name>.pub
    ForwardAgent yes 
    ForwardX11 yes
    ServerAliveInterval 120
  1. Test ssh ssh <config-name>

Setup VS Code and ROS2 Workspace Repository

  1. Open a ssh terminal on the Raspberry Pi 4
  2. Install Visual Studio Code on the pi
sudo apt update
sudo apt install code
  1. Clone the ros2 workspace repo into the Raspberry Pi's home directory for the current user
cd
git clone https://github.com/digitalhabitat/bot_ros2_workspace

Install Docker

  1. Open a ssh terminal on the Raspberry Pi 4
  2. Install docker will the following commands
sudo apt-get update && sudo apt-get upgrade
curl -fsSL https://get.docker.com -o get-docker.sh
 sudo sh get-docker.sh
  1. more Info about script
  2. These next steps maybe necessary for docker to work it VS Code remote development click here for more info
sudo groupadd docker
sudo usermod -aG docker $USER
exit

Setup VS Code Remote Development

  1. Install VS Code on your host machine
  2. Open VS Code on host machine
  3. Install the remote Remote Development extension pack more info about remote development here
  4. Connect to the rpi4 via VS Code on your host machine
    1. With VS Code open press Ctrl + Shift + P and enter "Connect to Host"
    2. You should be prompted with a drop down menu of the known host that was configured in step
  5. Open ros2 workspace folder
    1. With VS Code, Select File, Open Folder, /home/bot/bot_ros2_workspace/ then click okay
  6. Make sure the repo is currently on the humble-rpi4 branch
    1. Check that the bottom left hand corner reads humble-rpi4
    2. if not, on VS Code press Ctrl + Shift + P and enter "Checkout to... "
    3. Select "origin/humble-rpi4"
  7. Open Docker the Humble ROS2 container
    1. on VS Code press Ctrl + Shift + P and enter "Rebuild and Reopen in Container"
    2. Check out the readme for the workspace to get started. Click hereto read a blog about this ROS2 workspace template

Setup GitHub ssh keys

  1. Create private-public key pair and add public key to github
ssh-keygen -t ed25519 -C "<youremail>" -f ~/.ssh/<key_file>
  1. Test credentials
ssh -T -i ~/.ssh/<private-key> git@github.com
  1. Configure global settings
git config --global user.email "youremail@yourdomain.com"
git config --global user.name "Your Name"

Sharing Git credentials with your container

Left-click: follow link, Right-click: select node, Scroll: zoom
x