You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The user will need to write transport functions in app code and provide it to the micro-ROS library using [`rmw_uros_set_custom_transport()` API](https://micro.ros.org/docs/tutorials/advanced/create_custom_transports/)
This example demonstrates how to create a micro-ROS node on an ESP32 that communicates over Ethernet with a ROS 2 system. The node implements a simple request-response pattern where it listens for names and responds with greetings.
4
+
5
+
## Overview
6
+
7
+
The ESP32 node:
8
+
- Subscribes to the topic `micro_ros_name`
9
+
- When it receives a name (e.g., "John"), it publishes "Hello John!" to the topic `micro_ros_response`
10
+
- Uses Ethernet for communication with the ROS 2 system
11
+
- Operates on ROS 2 domain ID 8
12
+
13
+
## Hardware Requirements
14
+
15
+
- ESP32 development board
16
+
- LAN8710 or LAN8720 Ethernet PHY module
17
+
- Ethernet cable
18
+
19
+
### Ethernet PHY Wiring
20
+
21
+
Connect the LAN8720 module to the ESP32 using the following pins:
22
+
23
+
| ESP32 GPIO | LAN87XX Pin | Description |
24
+
|------------|-------------|-------------|
25
+
| GPIO 5 | POWER | PHY Power |
26
+
| GPIO 23 | MDC | Clock |
27
+
| GPIO 18 | MDIO | Data |
28
+
| GPIO 17 | Clock | 50MHz Clock |
29
+
30
+
## Network Configuration
31
+
32
+
The example uses the following network configuration (configurable in `main.cpp`):
33
+
34
+
- ESP32 IP: 10.4.4.177
35
+
- Gateway: 10.4.4.1
36
+
- Netmask: 255.255.255.0
37
+
- Agent IP: 10.4.4.187
38
+
- Agent Port: 8888
39
+
40
+
## Software Setup
41
+
42
+
1. Install PlatformIO (if not already installed)
43
+
2. Install Docker and Docker Compose
44
+
3. Clone this repository
45
+
4. Navigate to the example directory:
46
+
```bash
47
+
cd examples/ethernet_pubsub
48
+
```
49
+
50
+
## Building and Flashing
51
+
52
+
1. Build and flash the firmware:
53
+
```bash
54
+
pio run -t upload
55
+
```
56
+
57
+
2. (Optional) Monitor the serial output:
58
+
```bash
59
+
pio device monitor
60
+
```
61
+
62
+
## Running the micro-ROS Agent and RQT
63
+
64
+
1. Allow X11 connections from Docker (needed for RQT):
65
+
```bash
66
+
xhost +local:docker
67
+
```
68
+
69
+
2. Start the micro-ROS agent and RQT:
70
+
```bash
71
+
docker compose up
72
+
```
73
+
74
+
This will start:
75
+
- A micro-ROS agent listening on UDP port 8888
76
+
- RQT with proper X11 forwarding for visualization
77
+
78
+
## Testing the Example
79
+
80
+
1. In RQT:
81
+
- Click on Plugins -> Topics -> Message Publisher
82
+
- Add the topic `/micro_ros_name`
83
+
- Set the message type to `std_msgs/String`
84
+
- Enter a name in the `data` field and click the checkbox to publish
85
+
86
+
2. To view responses:
87
+
- In RQT, click on Plugins -> Topics -> Topic Monitor
88
+
- Subscribe to `/micro_ros_response`
89
+
- You should see responses like "Hello <name>!" when you publish names
90
+
91
+
## Troubleshooting
92
+
93
+
- If RQT doesn't appear, ensure X11 forwarding is properly set up with `xhost +local:docker`
94
+
- Check the serial monitor for connection status and debugging information
95
+
- Verify that your network configuration matches the settings in `main.cpp`
0 commit comments