• Stars
    star
    163
  • Rank 231,102 (Top 5 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A set of utilities for integrating micro-ROS in a STM32CubeMX project

banner banner

micro-ROS for STM32CubeMX/IDE

This tool aims to ease the micro-ROS integration in a STM32CubeMX/IDE project.

Middlewares available

This package support the usage of micro-ROS on top of two different middlewares:

  • eProsima Micro XRCE-DDS: the default micro-ROS middleware.
  • embeddedRTPS: an experimental implementation of a RTPS middleware compatible with ROS 2. Instructions on how to use it available here.

Using this package with STM32CubeMX

  1. Clone this repository in your STM32CubeMX project folder. A sample project can be generated with the provided sample_project.ioc.

  2. Make sure that your STM32CubeMX project is using a Makefile toolchain under Project Manager -> Project

  3. Make sure that if you are using FreeRTOS, the micro-ROS task has more than 10 kB of stack: Detail

  4. Configure the transport interface on the STM32CubeMX project, check the Transport configuration section for instructions on the custom transports provided.

  5. Modify the generated Makefile to include the following code before the build the application section:

    #######################################
    # micro-ROS addons
    #######################################
    LDFLAGS += micro_ros_stm32cubemx_utils/microros_static_library/libmicroros/libmicroros.a
    C_INCLUDES += -Imicro_ros_stm32cubemx_utils/microros_static_library/libmicroros/microros_include
    
    # Add micro-ROS utils
    C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/custom_memory_manager.c
    C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/microros_allocators.c
    C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/microros_time.c
    
    # Set here the custom transport implementation
    C_SOURCES += micro_ros_stm32cubemx_utils/extra_sources/microros_transports/dma_transport.c
    
    print_cflags:
       @echo $(CFLAGS)
  6. Execute the static library generation tool. Compiler flags will retrieved automatically from your Makefile and user will be prompted to check if they are correct.

    docker pull microros/micro_ros_static_library_builder:iron
    docker run -it --rm -v $(pwd):/project --env MICROROS_LIBRARY_FOLDER=micro_ros_stm32cubemx_utils/microros_static_library microros/micro_ros_static_library_builder:iron
  7. Modify your main.c to use micro-ROS. An example application can be found in sample_main.c.

  8. Continue your usual workflow building your project and flashing the binary:

    make -j$(nproc)

Using this package with STM32CubeIDE

micro-ROS can be used with SMT32CubeIDE following these steps:

  1. Clone this repository in your STM32CubeIDE project folder

  2. Go to Project -> Properties -> C/C++ Build -> Settings -> Build Steps Tab and in Pre-build steps add:

    docker pull microros/micro_ros_static_library_builder:iron && docker run --rm -v ${workspace_loc:/${ProjName}}:/project --env MICROROS_LIBRARY_FOLDER=micro_ros_stm32cubemx_utils/microros_static_library_ide microros/micro_ros_static_library_builder:iron
  3. Add micro-ROS include directory. In Project -> Properties -> C/C++ Build -> Settings -> Tool Settings Tab -> MCU GCC Compiler -> Include paths add micro_ros_stm32cubemx_utils/microros_static_library_ide/libmicroros/include

  4. Add the micro-ROS precompiled library. In Project -> Settings -> C/C++ Build -> Settings -> MCU GCC Linker -> Libraries

    • add <ABSOLUTE_PATH_TO>/micro_ros_stm32cubemx_utils/microros_static_library_ide/libmicroros in Library search path (-L)
    • add microros in Libraries (-l)
  5. 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.
  6. Make sure that if you are using FreeRTOS, the micro-ROS task has more than 10 kB of stack: Detail

  7. Configure the transport interface on the STM32CubeMX project, check the Transport configuration section for instructions on the custom transports provided.

  8. Build and run your project

Windows 11 (Community Contributed)

micro-ROS can be used with SMT32CubeIDE in Windows 11 OS, following these steps:

  1. Install Docker Desktop and open it
  2. Clone this repository in your STM32CubeIDE project folder
  3. Open a terminal in the project folder and run:
    docker pull microros/micro_ros_static_library_builder:humble
    docker run --rm -v <ABSOLUTE_PATH_TO_PROJECT>:/project --env MICROROS_LIBRARY_FOLDER=micro_ros_stm32cubemx_utils/microros_static_library_ide microros/micro_ros_static_library_builder:humble

Follow steps 4 to 8. Noticed that thist steps where tested with ROS 2 Humble, but should work on any distribution. micro-ROS Agent could be build and run in Ubuntu using WSL.

Transport configuration

Available transport for this platform are:

U(S)ART with DMA

Steps to configure:

  • Enable U(S)ART in your STM32CubeMX
  • For the selected USART, enable DMA for Tx and Rx under DMA Settings
  • Set the DMA priotity to Very High for Tx and Rx
  • Set the DMA mode to Circular for Rx: Detail
  • For the selected, enable global interrupt under NVIC Settings: Detail

U(S)ART with Interrupts

Steps to configure:

  • Enable U(S)ART in your STM32CubeMX
  • For the selected USART, enable global interrupt under NVIC Settings: Detail

USB CDC

Steps to configure:

  • Enable the USB in your STM32CubeMX Connectivity tab.

  • Select the Communication Device Class (Virtual Port Com) mode on the Middleware -> USB_DEVICE configuration.

    Note: The micro-ROS transport will override the autogenerated USB_DEVICE/App/usbd_cdc_if.c methods.

UDP

Steps to configure:

  • Enable Ethernet in your STM32CubeMX/IDE Connectivity tab.

  • Enable LwIP in your STM32CubeMX/IDE Middleware tab.

  • Make sure that LwIP has the following configuration:

    Platform Setting according to your own board
    LwIP -> General Settings -> LWIP_DHCP -> Disabled
    LwIP -> General Settings -> IP Address Settings (Set here the board address and mask)
    LwIP -> General Settings -> LWIP UDP -> Enabled
    LwIP -> General Settings -> Procols Options -> MEMP_NUM_UDP_PCB -> 15
    LwIP -> Key Options -> LWIP_SO_RCVTIMEO -> Enable
    

Note: Ensure your board and Agent are within the same LAN. The default port is 8888. You can modify it in udp_transport.c.If you are using a board from the STM32H7 series, please set up the MPU correctly.

  • Use sample_main_udp.c as a reference for writing your application code.

  • Start the micro-ROS Agent with the following arguments:

    ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v 6
    

Customizing the micro-ROS library

All the micro-ROS configuration can be done in colcon.meta file before step 3. You can find detailed information about how to tune the static memory usage of the library in the Middleware Configuration tutorial.

Adding custom packages

Note that folders added to microros_static_library/library_generation/extra_packages/ and entries added to /microros_static_library/library_generation/extra_packages/extra_packages.repos will be taken into account by this build system.

Purpose of the Project

This software is not ready for production use. It has neither been developed nor tested for a specific use case. However, the license conditions of the applicable Open Source licenses allow you to adapt the software to your needs. Before using it in a safety relevant setting, make sure that the software fulfills your requirements and adjust it according to any applicable safety standards, e.g., ISO 26262.

License

This repository is open-sourced under the Apache-2.0 license. See the LICENSE file for details.

For a list of other open-source components included in this repository, see the file 3rd-party-licenses.txt.

Known Issues/Limitations

There are no known limitations.

More Repositories

1

micro_ros_arduino

micro-ROS library for Arduino
C
437
star
2

micro_ros_setup

Support macros for building micro-ROS-based firmware.
Shell
365
star
3

micro_ros_espidf_component

micro-ROS ESP32 IDF component and sample code
C
254
star
4

micro_ros_platformio

micro-ROS library for Platform.IO
Python
209
star
5

micro-ROS.github.io

A platform for seamless integration of resource constrained devices in the ROS ecosystem.
SCSS
110
star
6

micro-ROS-Agent

ROS 2 package using Micro XRCE-DDS Agent.
C++
101
star
7

NuttX

Official micro-ROS RTOS
C
88
star
8

micro-ROS-demos

Sample code using rclc and rclcpp implementations.
C
84
star
9

freertos_apps

Sample applications for FreeRTOS + micro-ROS
C
81
star
10

micro_ros_zephyr_module

micro-ROS Zephyr module and sample code
C
54
star
11

docker

Docker-related material to setup, configure and develop with micro-ROS hardware.
Dockerfile
49
star
12

system_modes

System modes for ROS 2 and micro-ROS
C++
43
star
13

rmw_microxrcedds

RMW implementation using Micro XRCE-DDS middleware.
C
35
star
14

micro-ROS_moveit2_demo

Provides a demo of micro-ROS and MoveIt2 based on ST Disco L475 IOT01 board IMU sensors.
C++
22
star
15

zephyr_apps

Sample applications for Zephyr + micro-ROS
C
19
star
16

micro_ros_mbed

micro-ROS mbed sample code
Makefile
18
star
17

micro-ROS_crazyflie_demo

Provides a demo of micro-ROS based on a Crazyflie.
Python
18
star
18

micro-ROS_openmanipulator_demo

Provides a demo of micro-ROS based on ROBOTIS OpenManipulator, Olimex STM32 E407 and VL53L1X ToF sensor.
C++
14
star
19

micro-ROS_kobuki_demo

Provides a demo of micro-ROS based on a Kobuki and an Olimex STM32-E407 board.
Python
14
star
20

rmw_embeddedrtps

RMW implementation for EmbeddedRTPS middleware
C++
13
star
21

micro-ROS_sensors_demo

Provides a demo of micro-ROS based on ST Disco L475 IOT01 board.
Shell
12
star
22

micro_ros_nuttx_app

An standalone micro-ROS app for Nuttx
Makefile
11
star
23

nuttx_apps

C
10
star
24

micro_ros_azure_rtos_app

micro-ROS app for Azure RTOS
C
8
star
25

micro_ros_utilities

General utilities for easing the usage of micro-ROS on different platforms
C
8
star
26

micro_ros_diagnostics

Diagnostics framework for micro-ROS
C
8
star
27

micro-ROS-bridge_RPI

Shell
7
star
28

micro_ros_rtthread_component

Python
7
star
29

micro_ros_msgs

Collection of ROS 2 message definitions used throughout the implementation of micro-ROS, both in the agent and client endpoints.
CMake
6
star
30

micro_ros_renesas2estudio_component

A set of utilities for integrating micro-ROS in a Renesas e2 studio project
C
6
star
31

micro-ROS_warehouse_demo

Python
5
star
32

rosidl_typesupport_microxrcedds

Type support for Micro XRCE-DDS
EmberScript
4
star
33

micro_ros_renesas_testbench

micro-ROS hardware in the loop testing
C
4
star
34

micro_ros_tivac_launchpad_app

micro-ROS app for TI Tiva C Series TM4C123GXL LaunchPad
C
4
star
35

micro_ros_vitis_component

Shell
4
star
36

micro_ros_renesas_demos

Demo code for Renesas e2 studio
C
4
star
37

benchmarking

A sets a tools and framework to develop embedded system benchmarks
C
4
star
38

benchmarking_shadow-builder

Repositiory containing the shadow-builder benchmarking tool
C++
3
star
39

executor_testbench

Executor modul for rcl with customizable scheduling semantics
C
2
star
40

raspbian_apps

C
2
star
41

micro-ROS_thumper_demo

A 6 wheel mobile robot contraller over 6LoWPAN and micro-ROS
Shell
2
star
42

micro-ROS-rtt

Micro-ROS Round-Trip Tests
C++
1
star
43

benchmarking-results

Benchmarking results
HTML
1
star
44

micro-ROS_demobox_demo

The demo box is a portable suitcase demonstration, showing advantage of using micro-ROS over ROS2 by showing power measurement and bootup time.
Shell
1
star
45

.github

micro-ROS GitHub Organization-wide files
1
star