Raspberry Pi
The Raspberry Pi is one of the most versatile devices in a RosFit deployment. It can serve as a full ROS 2 compute node running navigation stacks, a lightweight MQTT gateway that aggregates sensor data from nearby ESP32 devices, or a micro-ROS Agent host that bridges MCU nodes into the ROS 2 graph.
As a ROS 2 node
A Raspberry Pi 4 or 5 running Ubuntu arm64 is powerful enough to run ROS 2 navigation stacks, camera pipelines, and the RosFit bridge simultaneously.
OS setup
Flash Ubuntu Server arm64 to your SD card or NVMe drive:
| Raspberry Pi model | Recommended OS | Notes |
|---|---|---|
| Raspberry Pi 4 (4 GB+) | Ubuntu 22.04 arm64 | ROS 2 Humble (LTS) |
| Raspberry Pi 5 (4 GB+) | Ubuntu 24.04 arm64 | ROS 2 Jazzy (LTS), best performance |
# After first boot, update and install ROS 2
sudo apt update && sudo apt upgrade -y
sudo apt install -y software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install -y curl gnupg lsb-release
# Add ROS 2 repository
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \
-o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" \
| sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt install -y ros-humble-ros-base ros-humble-navigation2 ros-humble-slam-toolbox
Connect to RosFit
Install the RosFit bridge and configure it exactly as you would on any ROS 2 machine:
pip install rosfit-bridge
rosfit bridge start --config bridge.yaml
Both rosbridge and MQTT bridge connections are supported. For headless robots behind NAT, the MQTT bridge is recommended.
Camera pipelines
The Raspberry Pi supports several depth and RGB cameras commonly used in robotics:
| Camera | Interface | ROS 2 package | Notes |
|---|---|---|---|
| Intel RealSense D435/D455 | USB 3.0 | realsense2_camera | Depth + RGB, requires USB 3.0 port |
| Luxonis OAK-D / OAK-D Lite | USB 3.0 | depthai_ros | On-device neural inference |
| USB webcam (UVC) | USB 2.0+ | usb_cam / v4l2_camera | Basic RGB, good for prototyping |
| Raspberry Pi Camera Module 3 | CSI | camera_ros | Native CSI, low latency |
RosFit can stream compressed image topics to the cloud for remote monitoring. Use image_transport with compressed or theora encoding to reduce bandwidth:
bridges:
- ros_topic: /camera/image_raw/compressed
mqtt_topic: rosfit/rpi-bot-01/telemetry/camera
direction: ros_to_mqtt
qos: 0
max_rate_hz: 5
SLAM and Nav2 on Raspberry Pi 5
The Raspberry Pi 5 has enough compute to run SLAM Toolbox and Nav2 for indoor navigation:
# Launch SLAM Toolbox in online async mode
ros2 launch slam_toolbox online_async_launch.py \
slam_params_file:=./mapper_params.yaml
# Launch Nav2
ros2 launch nav2_bringup navigation_launch.py \
params_file:=./nav2_params.yaml
RosFit streams the resulting /map, /amcl_pose, and /plan topics to the cloud dashboard, giving remote operators a live view of the robot's navigation state.
As an MQTT gateway
A Raspberry Pi can act as a local gateway that aggregates data from nearby ESP32 or other BLE/UART devices and forwards it to RosFit over MQTT. This pattern is useful when MCU devices lack direct internet access.
Architecture
┌──────────┐ BLE/UART ┌──────────────┐ MQTT/TLS ┌─────────────┐
│ ESP32 │──────────────▶│ Raspberry Pi │─────────────▶│ RosFit │
│ sensor │ │ gateway │ │ cloud │
└──────────┘ └──────────────┘ └─────────────┘
┌──────────┐ BLE/UART │
│ ESP32 │─────────────────────┘
│ actuator│
└──────────┘
Gateway script
A minimal Python gateway using paho-mqtt and bleak (BLE) or pyserial (UART):
import json
import time
import paho.mqtt.client as mqtt
import serial
MQTT_HOST = "cloud.rosfit.io"
MQTT_PORT = 8883
DEVICE_ID = "rpi-gateway-01"
MQTT_TOKEN = "mqtt_tok_xxxxx"
# Serial connection to ESP32
ser = serial.Serial("/dev/ttyUSB0", 115200, timeout=1)
client = mqtt.Client(client_id=DEVICE_ID)
client.username_pw_set(DEVICE_ID, MQTT_TOKEN)
client.tls_set()
client.connect(MQTT_HOST, MQTT_PORT)
client.loop_start()
def forward_telemetry():
while True:
line = ser.readline().decode("utf-8").strip()
if not line:
continue
try:
data = json.loads(line)
esp_id = data.pop("device_id", "unknown")
topic = f"rosfit/{esp_id}/telemetry"
client.publish(topic, json.dumps(data), qos=1)
except json.JSONDecodeError:
pass
if __name__ == "__main__":
forward_telemetry()
systemd service
Create a systemd unit so the gateway starts automatically on boot:
# /etc/systemd/system/rosfit-gateway.service
[Unit]
Description=RosFit MQTT Gateway
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/rosfit-gateway
ExecStart=/usr/bin/python3 gateway.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable rosfit-gateway.service
sudo systemctl start rosfit-gateway.service
As a micro-ROS agent host
The Raspberry Pi is an ideal host for the micro-ROS Agent, allowing multiple ESP32 or STM32 devices to join the ROS 2 graph through a single agent process.
Run the agent in Docker
The easiest way to run the micro-ROS Agent on a Raspberry Pi is via Docker:
docker run -d --name micro-ros-agent \
--network host \
--device /dev/ttyUSB0 \
--device /dev/ttyUSB1 \
microros/micro-ros-agent:humble \
multiserial --devs /dev/ttyUSB0 /dev/ttyUSB1 -b 115200
For UDP transport (Wi-Fi-connected ESP32 devices):
docker run -d --name micro-ros-agent \
--network host \
microros/micro-ros-agent:humble \
udp4 --port 8888
Multiple ESP32 connections
A single micro-ROS Agent can handle multiple MCU clients simultaneously. Each ESP32 registers as a separate ROS 2 node with its own publishers and subscribers:
| ESP32 device | Transport | ROS 2 node name | Published topics |
|---|---|---|---|
| Motor controller | Serial /dev/ttyUSB0 | /esp32_motor | /wheel_odom, /motor_status |
| IMU sensor | Serial /dev/ttyUSB1 | /esp32_imu | /imu/data, /imu/mag |
| Lidar adapter | UDP Wi-Fi | /esp32_lidar | /scan |
| Environment sensor | UDP Wi-Fi | /esp32_env | /temperature, /humidity |
Agent discovery
The RosFit bridge running on the same Raspberry Pi automatically discovers all topics published by micro-ROS nodes through the agent. No additional configuration is needed — just ensure the bridge's discover_topics: true flag is set in fleet.yaml.
fleet:
- device_id: rpi-bot-01
connection: rosbridge
host: localhost
port: 9090
discover_topics: true
All topics from the connected ESP32 nodes will appear in the RosFit dashboard as sub-topics of the Raspberry Pi device.