micro-ROS temperature publisher demo
This repository provides a micro-ROS publisher demonstrator. In order to reproduce this example, you need:
A Raspberry Pi 3 that is connected to the Olimex board through a serial connection. This device is the micro-ROS to ROS 2 bridge, which acts as a gateway.
ROS 2 running computer, which is able to retrieve the sensor data published by the MCU.
The MCU runs NuttX RTOS with an application that contains the temperature sensor driver and the micro-ROS client. Once the client connects to the micro-Agent that runs in the Raspberry Pi, is able to create a topic and publish the sensor data. The micro-ROS Client is based in the
The Agent that runs in the Raspberry Pi, acts as a bridge among micro-ROS and ROS 2 world, translating the content the MCU has created. The Agent has the capability of using both standard DDS and XRCE-DDS that micro-ROS uses. Thanks to this is able to talk to the micro-ROS client that runs in the MCU.
The Agent goal is to deliver the temperature data in the local network where the ROS 2 running computer is placed. Thanks to this, the computer is able to run ros2 topic echo and retrieve the temperature sensor data.
You can see the demonstration video here: https://micro-ros.github.io/blog/2019/06/03/micro-ROS_temperature_publisher_demo/
Raspberry Pi based bridge
Use Raspberry Pi cross-compiling tool for creating a micro-ROS Agent self-contained workspaces. This allows to communicate with the micro-ROS client that lives at the Olimex board. It also mirrors the node and the data the micro-ROS client creates to the ROS 2 world.
Once you have cross-compiled the agent, copy the folder to a Raspbian-containing SD card.
micro-ROS publisher Docker
This Docker file will allow you to fetch the dependencies and compile the example based on NuttX. Once you are done, you need to upload the created binary under
nuttx.elf to the board. To do so, please download the next repo (
git clone https://github.com/micro-ROS/docker), build an upload the firmware following the next tutorial.
First, connect the Olimex board and the sensor, like this:
- Olimex D0 -> HIH6130 SDA
- Olimex D1 -> HIH6130 SCL
- Olimex +3.3v -> HIH6130 Vdd
- Olimex GND -> HIH6130 GND
Secondly, connect the Olimex board serial to the Raspberry Pi serial port, like the next image:
- Olimex TX3 -> RPI RX (PIN 10)
- Olimex RX3 -> RPI TX (PIN 8)
- Olimex GND -> RPI GND (PIN 6)
You can see the RPI pinout here.
You need to connect your Raspberry Pi to your local network, so the ROS 2 running computer can retrieve the temperature data. Once everything is ready, you need to do the next steps on the each device.
- Open a terminal on the Rpi (You can connect by SSH for example).
- Configure execution enviroment typing the next command:
- Execute the micro-ROS Agent typing the next command:
./agent_ws/install/lib/micro_ros_agent/micro_ros_agent serial /dev/ttyS0
Now the RPI is ready to work as bridge.
- Open a NuttX console. (NuttX tutorials)
- Execute the app
This will create a node and a topic. Once everything is set-up it will publish the temperature value.
Host PC or any other device on the network.
Note: This PC must have ROS2 crystal.
- Open a terminal and configure the execution enviroment typing:
- We will check if the topic is being published, by typing:
ros2 topic list
- This should return somenthing like this:
/parameter_events /rosout /std_msgs_msg_Int32
- Finally we will echo the topic content, by typing the next command:
ros2 topic echo
- This should return the next:
data: 28 data: 28 data: 28 data: 28