Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [teensy41, teensy40, teensy36, teensy35, teensy31, due, zero, olimex_e407, esp32dev, nanorp2040connect, portenta_h7_m7, teensy41_eth, nanorp2040connect_wifi, portenta_h7_m7_wifi, esp32dev_wifi, portenta_h7_m7_humble, portenta_h7_m7_jazzy, portenta_h7_m7_rolling, teensy41_custom, pico]
platform: [teensy41, teensy40, teensy36, teensy35, teensy31, due, zero, olimex_e407, esp32dev, nanorp2040connect, portenta_h7_m7, teensy41_eth, nanorp2040connect_wifi, portenta_h7_m7_wifi, esp32dev_wifi, esp32dev_ethernet, portenta_h7_m7_humble, portenta_h7_m7_jazzy, portenta_h7_m7_rolling, teensy41_custom, pico]

steps:
- uses: actions/checkout@v3
Expand Down
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ PlatformIO will handle the full build process, including dependencies, compilati
## Supported boards
Supported boards are:

| Board | Platform | Framework | Transports | Default meta file |
| -------------------------------------------- | ------------- | ----------- | -------------------------------- | ------------------------ |
| `portenta_h7_m7` | `ststm32` | `arduino` | `serial` <br/> `wifi` | `colcon.meta` |
| `teensy41` | `teensy` | `arduino` | `serial` <br/> `native_ethernet` | `colcon.meta` |
| `teensy40` | `teensy` | `arduino` | `serial` | `colcon.meta` |
| `teensy36` <br/> `teensy35` <br/> `teensy31` | `teensy` | `arduino` | `serial` | `colcon_lowmem.meta` |
| `due` | `atmelsam` | `arduino` | `serial` | `colcon_verylowmem.meta` |
| `zero` | `atmelsam` | `arduino` | `serial` | `colcon_verylowmem.meta` |
| `olimex_e407` | `ststm32` | `arduino` | `serial` | `colcon.meta` |
| `esp32dev` | `espressif32` | `arduino` | `serial` <br/> `wifi` | `colcon.meta` |
| `nanorp2040connect` | `raspberrypi` | `arduino` | `serial` <br/> `wifi_nina` | `colcon_verylowmem.meta` |
| `pico` | `raspberrypi` | `arduino` | `serial` | `colcon.meta`|
| Board | Platform | Framework | Transports | Default meta file |
| -------------------------------------------- | ------------- | ----------- | ---------------------------------------- | ------------------------ |
| `portenta_h7_m7` | `ststm32` | `arduino` | `serial` <br/> `wifi` | `colcon.meta` |
| `teensy41` | `teensy` | `arduino` | `serial` <br/> `native_ethernet` | `colcon.meta` |
| `teensy40` | `teensy` | `arduino` | `serial` | `colcon.meta` |
| `teensy36` <br/> `teensy35` <br/> `teensy31` | `teensy` | `arduino` | `serial` | `colcon_lowmem.meta` |
| `due` | `atmelsam` | `arduino` | `serial` | `colcon_verylowmem.meta` |
| `zero` | `atmelsam` | `arduino` | `serial` | `colcon_verylowmem.meta` |
| `olimex_e407` | `ststm32` | `arduino` | `serial` | `colcon.meta` |
| `esp32dev` | `espressif32` | `arduino` | `serial` <br/> `wifi` <br/> `ethernet`* | `colcon.meta` |
| `nanorp2040connect` | `raspberrypi` | `arduino` | `serial` <br/> `wifi_nina` | `colcon_verylowmem.meta` |
| `pico` | `raspberrypi` | `arduino` | `serial` | `colcon.meta` |

\* The ESP32 ethernet transport is community contributed.

The community is encouraged to open pull request with custom use cases.

Expand Down Expand Up @@ -133,6 +135,19 @@ The transport can be configured with the `board_microros_transport = <transport>
set_microros_native_ethernet_transports(local_mac, local_ip, agent_ip, agent_port);
```

- `ethernet`

```c
IPAddress client_ip(192, 168, 1, 177);
IPAddress gateway(192, 168, 1, 1);
IPAddress netmask(255, 255, 255, 0);
IPAddress agent_ip(192, 168, 1, 113);
size_t agent_port = 8888;

// Optional hostname, defaults to nullptr (no hostname set)
set_microros_ethernet_transports(client_ip, gateway, netmask, agent_ip, agent_port, "my-microros-device");
```

- `custom`

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/)
Expand Down
8 changes: 8 additions & 0 deletions ci/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ board_microros_transport = native_ethernet
lib_deps =
../

[env:esp32dev_ethernet]
platform = espressif32
board = esp32dev
framework = arduino
board_microros_transport = ethernet
lib_deps =
../

; WiFi platforms

[env:portenta_h7_m7_wifi]
Expand Down
10 changes: 10 additions & 0 deletions ci/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#if defined(MICRO_ROS_TRANSPORT_ARDUINO_WIFI)
#include <WiFi.h>
#elif defined(MICRO_ROS_TRANSPORT_ARDUINO_ETHERNET)
#include <ETH.h>
#endif

#include <micro_ros_platformio.h>
Expand Down Expand Up @@ -78,6 +80,14 @@ void setup() {
char psk[]= "WIFI_PSK";

set_microros_wifi_transports(ssid, psk, agent_ip, agent_port);
#elif defined(MICRO_ROS_TRANSPORT_ARDUINO_ETHERNET)
IPAddress local_ip(192, 168, 1, 177);
IPAddress gateway(192, 168, 1, 1);
IPAddress netmask(255, 255, 255, 0);
IPAddress agent_ip(192, 168, 1, 113);
size_t agent_port = 8888;

set_microros_ethernet_transports(local_ip, gateway, netmask, agent_ip, agent_port, "micro-ros-eth");
#elif defined(MICRO_ROS_TRANSPORT_ARDUINO_CUSTOM)
rmw_uros_set_custom_transport(
MICROROS_TRANSPORTS_FRAMING_MODE,
Expand Down
108 changes: 108 additions & 0 deletions examples/ethernet_pubsub/README.md
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
```
33 changes: 33 additions & 0 deletions examples/ethernet_pubsub/docker-compose.yaml
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"

8 changes: 8 additions & 0 deletions examples/ethernet_pubsub/platformio.ini
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
Loading
Loading