This project aim to enable the comunication between ROS2 and STM32 boards using micro-ros. You can choose to use the code in the repository or to build it from scratch. The project was tested on a NUCLEO board but it should work on others board too
If you want to speedup the process you can directly use the code in this repository:
- Clone this repository in your STM32CubeIDE workspace folder
- Go to the Library Installation section
This library installation section will follow what is written in the official micro-ROS for STM32 page, if you want go more in detail or want to install it using Windows follow this guide
- Open this project folder and run
git clone --branch humble https://github.com/micro-ROS/micro_ros_stm32cubemx_utils.git
- Go to
d
and ind
add `` - Add micro-ROS include directory. In
Project -> Settings -> C/C++ Build -> Settings -> Tool Settings Tab -> MCU GCC Compiler -> Include paths
add../micro_ros_stm32cubemx_utils/microros_static_library_ide/libmicroros/include
- Add the micro-ROS precompiled library. In
Project -> Settings -> C/C++ Build -> Settings -> MCU GCC Linker -> Libraries
- Add
../micro_ros_stm32cubemx_utils/microros_static_library_ide/libmicroros
inLibrary search path (-L)
- Add
microros
inLibraries(-l)
- Add
- Add the following source code files to your project, dragging them to source folder:
extra_sources/microros_time.c
extra_sources/microros_allocators.c
extra_sources/custom_memory_manager.c
extra_sources/microros_transports/dma_transport.c
or your transport selection
- Build and run the project
- Go to the Agent installation section
Micro-ROS require an Agent that act as a middleware between the STM32 board and the rest of the ROS infrastructure. First create a new folder that will be used as ROS2 workspace then follow these steps:
- Clone the microros repository in your workspace
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup rosdep update && rosdep install --from-path src --ignore-src -y colcon build source install/local_setup.bash
- Build the agent (ingore some warning that could appear)
ros2 run micro_ros_setup create_agent_ws.sh ros2 run micro_ros_setup build_agent.sh source install/local_setup.sh
- Start the micro-ros-agent
ros2 run micro_ros_agent micro_ros_agent serial -b 115200 --dev /dev/ttyACM0