-
Notifications
You must be signed in to change notification settings - Fork 110
Add ESP32 Ethernet transport #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
684ba1e
wip
patrickwasp 19325c5
wip
patrickwasp d95de37
wip
patrickwasp e6e65a2
wip
patrickwasp eae7992
wip
patrickwasp 72120c5
wip
patrickwasp 182601c
single callback
patrickwasp 042e4c4
update example
patrickwasp 918abcf
wip
patrickwasp df003c8
wip
patrickwasp 12721a4
wip
patrickwasp b460b07
wip
patrickwasp 65c38c1
Update README.md
patrickwasp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # micro-ROS Ethernet Publisher/Subscriber Example | ||
|
|
||
| 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. | ||
|
|
||
| ## Overview | ||
|
|
||
| The ESP32 node: | ||
| - Subscribes to the topic `micro_ros_name` | ||
| - When it receives a name (e.g., "John"), it publishes "Hello John!" to the topic `micro_ros_response` | ||
| - Uses Ethernet for communication with the ROS 2 system | ||
| - Operates on ROS 2 domain ID 8 | ||
|
|
||
| ## Hardware Requirements | ||
|
|
||
| - ESP32 development board | ||
| - LAN8710 or LAN8720 Ethernet PHY module | ||
| - Ethernet cable | ||
|
|
||
| ### Ethernet PHY Wiring | ||
|
|
||
| Connect the LAN8720 module to the ESP32 using the following pins: | ||
|
|
||
| | ESP32 GPIO | LAN87XX Pin | Description | | ||
| |------------|-------------|-------------| | ||
| | GPIO 5 | POWER | PHY Power | | ||
| | GPIO 23 | MDC | Clock | | ||
| | GPIO 18 | MDIO | Data | | ||
| | GPIO 17 | Clock | 50MHz Clock | | ||
|
|
||
| ## Network Configuration | ||
|
|
||
| The example uses the following network configuration (configurable in `main.cpp`): | ||
|
|
||
| - ESP32 IP: 10.4.4.177 | ||
| - Gateway: 10.4.4.1 | ||
| - Netmask: 255.255.255.0 | ||
| - Agent IP: 10.4.4.187 | ||
| - Agent Port: 8888 | ||
|
|
||
| ## Software Setup | ||
|
|
||
| 1. Install PlatformIO (if not already installed) | ||
| 2. Install Docker and Docker Compose | ||
| 3. Clone this repository | ||
| 4. Navigate to the example directory: | ||
| ```bash | ||
| cd examples/ethernet_pubsub | ||
| ``` | ||
|
|
||
| ## Building and Flashing | ||
|
|
||
| 1. Build and flash the firmware: | ||
| ```bash | ||
| pio run -t upload | ||
| ``` | ||
|
|
||
| 2. (Optional) Monitor the serial output: | ||
| ```bash | ||
| pio device monitor | ||
| ``` | ||
|
|
||
| ## Running the micro-ROS Agent and RQT | ||
|
|
||
| 1. Allow X11 connections from Docker (needed for RQT): | ||
| ```bash | ||
| xhost +local:docker | ||
| ``` | ||
|
|
||
| 2. Start the micro-ROS agent and RQT: | ||
| ```bash | ||
| docker compose up | ||
| ``` | ||
|
|
||
| This will start: | ||
| - A micro-ROS agent listening on UDP port 8888 | ||
| - RQT with proper X11 forwarding for visualization | ||
|
|
||
| ## Testing the Example | ||
|
|
||
| 1. In RQT: | ||
| - Click on Plugins -> Topics -> Message Publisher | ||
| - Add the topic `/micro_ros_name` | ||
| - Set the message type to `std_msgs/String` | ||
| - Enter a name in the `data` field and click the checkbox to publish | ||
|
|
||
| 2. To view responses: | ||
| - In RQT, click on Plugins -> Topics -> Topic Monitor | ||
| - Subscribe to `/micro_ros_response` | ||
| - You should see responses like "Hello <name>!" when you publish names | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| - If RQT doesn't appear, ensure X11 forwarding is properly set up with `xhost +local:docker` | ||
| - Check the serial monitor for connection status and debugging information | ||
| - Verify that your network configuration matches the settings in `main.cpp` | ||
| - Ensure all Ethernet pins are properly connected | ||
|
|
||
| ## Cleaning Up | ||
|
|
||
| 1. Stop the Docker containers: | ||
| ```bash | ||
| docker compose down | ||
| ``` | ||
|
|
||
| 2. Revoke X11 permissions (optional): | ||
| ```bash | ||
| xhost -local:docker | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| version: "2.1" | ||
|
|
||
| services: | ||
| micro-ros-agent: | ||
| image: microros/micro-ros-agent:humble | ||
| container_name: micro-ros-agent | ||
| network_mode: host | ||
| stdin_open: true | ||
| tty: true | ||
| environment: | ||
| - ROS_DOMAIN_ID=8 | ||
| ports: | ||
| - 8888:8888/udp | ||
| command: udp4 --port 8888 --verbose 6 | ||
|
|
||
| rqt: | ||
| image: osrf/ros:humble-desktop | ||
| container_name: rqt-visualizer | ||
| network_mode: host | ||
| ipc: host | ||
| pid: host | ||
| tty: true | ||
| privileged: true | ||
| device_cgroup_rules: | ||
| - 'c 189:* rmw' | ||
| environment: | ||
| - ROS_DOMAIN_ID=8 | ||
| - DISPLAY=${DISPLAY} | ||
| - QT_X11_NO_MITSHM=1 | ||
| volumes: | ||
| - /tmp/.X11-unix:/tmp/.X11-unix:rw | ||
| command: bash -c "source /opt/ros/humble/setup.bash && rqt" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [env:esp32dev] | ||
| platform = espressif32 | ||
| board = esp32dev | ||
| framework = arduino | ||
| board_microros_transport = ethernet | ||
| monitor_speed = 115200 | ||
| lib_deps = | ||
| https://github.com/micro-ROS/micro_ros_platformio |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.