How to make ROS2 and micro ros communicate together. - kajmoerk/Brick_Feeder GitHub Wiki
First of all, ROS2 and micro-ros do not inherently work together. Micro-ros uses the eProsima Micro XRCE-DDS protocol which requires a server/agent that acts on behalf of all the connected clients (microcontrollers with Micro-ros). More information can be found here. \
For this guide, it is assumed that you have a working ROS2 node (publisher/subscriber/service/etc.) on a pc and a working (publisher/subscriber/service/etc.) on your microcontroller. It is also assumed that the pc has docker installed and is logged in as well.
1. First we need to start the agent.
sudo docker run -it --rm --net=host microros/micro-ros-agent:galactic udp4 --port 8888 -v6
This begins a docker agent that communicates over UDP protocol at the local IP of the pc and on port 8888. This IP and port should match the same you have written in your micro-ros program.
2. Next we activate the middleware eProsima Fast DDS in ROS2 in a new terminal.
sudo apt install ros-galactic-rmw-fastrtps-cpp
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
Remember to source the workspace.
. install/setup.bash
Extra reading material.
3. Now you should be able to run your ROS2 script and communicate with your micro-ros node.
Remember to define the same topic and msg type for both nodes.
Extra link for troubleshooting