Overview
Before building your robot software, you must verify that your PC and Raspberry Pi can communicate over ROS2. This ensures nodes on different machines can discover and exchange data.Multi-Machine ROS2: By default, ROS2 uses DDS (Data Distribution Service) for automatic discovery on local networks. No manual configuration needed for simple setups!
Network Prerequisites
Both Devices on Same Network
1
Verify WiFi Connection
On PC:On Raspberry Pi (via SSH):Important: Both should have IPs in same subnet (e.g., 192.168.1.x)
2
Test Basic Connectivity
From PC to RPi:From RPi to PC:Expected: Continuous ping replies. Press Ctrl+C to stop.
ROS2 Discovery Mechanism
ROS2 uses DDS Discovery to find nodes on the network:- Multicast Discovery: Nodes broadcast their presence via UDP multicast
- Automatic Connection: Nodes with matching topic/service names connect
- No Central Server: Fully distributed (unlike ROS1 roscore)
Domain ID
Domain ID isolates ROS2 networks. Nodes with different domain IDs cannot communicate.Test 1: Talker-Listener (Same Machine)
First, test on single machine to verify ROS2 installation.On PC
Terminal 1:If listener doesn't receive messages
If listener doesn't receive messages
Solutions:
- Restart ROS2 daemon:
ros2 daemon stop && ros2 daemon start - Check firewall (allow UDP ports 7400-7500)
- Verify ROS_DOMAIN_ID matches in both terminals
Test 2: PC → Raspberry Pi Communication
Setup
On PC (Terminal 1):Success! Your Raspberry Pi is receiving messages from PC. This proves multi-machine ROS2 works!
Reverse Direction
On Raspberry Pi:Test 3: Node List Verification
While talker/listener running: On PC:Topic List
Topic Info
Test 4: Velocity Command Test
Simulate robot control: PC sends velocity commands, RPi listens.On Raspberry Pi
On PC
- PC (development computer) sends velocity commands
- RPi (onboard robot computer) receives them for motor control
- This is exactly how teleop will work!
Test 5: Service Call Across Machines
On PC (Server):Test 6: RQT Graph Visualization
On PC (requires Desktop):- You’ll see nodes and topics graphically
- Arrows show publisher → subscriber connections
- Great for debugging communication issues
Troubleshooting Multi-Machine Communication
Nodes don't see each other
Nodes don't see each other
Symptoms:
ros2 node listonly shows local nodes- Messages not received across machines
-
Check same network:
-
Verify ping works:
-
Check ROS_DOMAIN_ID matches:
-
Restart DDS daemon:
-
Check firewall:
Messages delayed or intermittent
Messages delayed or intermittent
Causes:
- WiFi signal weak
- Network congestion
- QoS (Quality of Service) mismatch
-
Check WiFi signal:
-
Use wired Ethernet (if possible):
- More reliable than WiFi
- Lower latency
-
Reduce message rate:
- For high-bandwidth topics (images, laserscan)
- Example: Publish at 10Hz instead of 30Hz
-
Check QoS settings:
- Publisher and subscriber QoS must be compatible
- Default is usually fine
Only works one direction
Only works one direction
Symptom: PC → RPi works, but RPi → PC doesn’t (or vice versa)Likely Cause: Asymmetric firewallSolution:
High CPU usage from discovery
High CPU usage from discovery
Cause: Many ROS2 systems on same network continuously discoveringSolutions:
-
Use different domain IDs:
-
Use ROS_LOCALHOST_ONLY (for single machine):
-
Static peer discovery (advanced):
- Configure specific IPs instead of multicast
- See: https://docs.ros.org/en/jazzy/How-To-Guides/DDS-tuning.html
Works wired but not WiFi
Works wired but not WiFi
Cause: Some routers block multicast over WiFiSolutions:
-
Enable multicast/IGMP on router:
- Check router settings for “multicast filtering”
- Disable AP isolation
-
Use different router:
- Some cheap routers don’t support multicast properly
-
Wired connection for Raspberry Pi:
- More reliable for robot operation anyway
Advanced: ROS_DOMAIN_ID Best Practices
Single Robot in Lab
Multiple Robots in Same Lab
Robot Alpha (PC and RPi):Development + Robot Testing
Robot (operating):Performance Testing
Measure Latency
Terminal 1:Measure Bandwidth
Large Message Test (Simulating LiDAR)
On PC:Communication Checklist
Before proceeding to robot development:- PC and RPi on same network (verified with ping)
- ROS2 talker/listener works PC → RPi
- ROS2 talker/listener works RPi → PC
-
ros2 node listshows nodes from both machines -
ros2 topic echoreceives data across network - Service calls work across machines
- ROS_DOMAIN_ID configured if multiple robots
- Firewall configured to allow ROS2 traffic
- Latency acceptable (<50ms for local network)
- No discovery issues (nodes appear within 2-3 seconds)
Network Architecture for Robot
/cmd_vel- PC sends velocity commands → RPi/odom- RPi publishes odometry → PC/scan- RPi publishes LiDAR data → PC/imu- RPi publishes IMU data → PC/joint_states- RPi publishes encoder data → PC
Next Steps
Robot Description
Create URDF model of your Mecanum robot
ROS2 Control
Set up ros2_control framework
Teleop Control
Control robot with keyboard
Troubleshooting
Common ROS2 communication errors