Home

Awesome

banner banner

micro-ROS for PlatformIO

This is a micro-ROS library for bare metal projects based on platformIO.

The build process for ROS 2 and micro-ROS is based on custom meta-build system tools and CMake. PlatformIO will handle the full build process, including dependencies, compilation and linkage.

Supported boards

Supported boards are:

BoardPlatformFrameworkTransportsDefault meta file
portenta_h7_m7ststm32arduinoserial <br/> wificolcon.meta
teensy41teensyarduinoserial <br/> native_ethernetcolcon.meta
teensy40teensyarduinoserialcolcon.meta
teensy36 <br/> teensy35 <br/> teensy31teensyarduinoserialcolcon_lowmem.meta
dueatmelsamarduinoserialcolcon_verylowmem.meta
zeroatmelsamarduinoserialcolcon_verylowmem.meta
olimex_e407ststm32arduinoserialcolcon.meta
esp32devespressif32arduinoserial <br/> wificolcon.meta
nanorp2040connectraspberrypiarduinoserial <br/> wifi_ninacolcon_verylowmem.meta
picoraspberrypiarduinoserialcolcon.meta

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

Requirements

Platform specific requirements

MacOS

XCode command line tools are distributed with toolchain that is not fully compatible with micro-ROS build process. To fix this, install GNU binutils using Homebrew:

brew install binutils

How to add to your project

The library can be included as a regular git library dependence on your platform.ini file:

...
lib_deps =
    https://github.com/micro-ROS/micro_ros_platformio

Now to proceed with the PlatformIO workflow:

pio lib install # Install dependencies
pio run # Build the firmware
pio run --target upload # Flash the firmware

After the library is compiled for first time the build process will be skipped, to trigger a library build and apply library modifications on your next platformIO build:

pio run --target clean_microros  # Clean library

Library configuration

This section details the different configuration parameters available on the project platform.ini file. A explanation for adding custom targets is also present

ROS 2 distribution

The target ROS 2 distribution can be configured with the board_microros_distro = <distribution>, supported values are:

Transport configuration

The transport can be configured with the board_microros_transport = <transport>, supported values and configurations are:

Extra packages

Colcon packages can be added to the build process using this two methods:

This should be used for example when adding custom messages types or custom micro-ROS packages.

Other configuration

Library packages can be configured with a customized meta file on the project main folder: board_microros_user_meta = <file_name.meta>.

This allows the user to customize the library memory resources or activate optional functionality such as multithreading, including configuration of user Extra packages.

Extend library targets

This library can be easily adapted to different boards, transports or RTOS, to achieve this the user shall provide:

Transport implementation

New transport implementations shall follow the signatures shown on micro_ros_platformio.h, the provided sources can be used as reference along this documentation. Contributed transport source code shall be added on the ./platform_code/<framework>/<board_microros_transport> path. Example:

Time source

micro-ROS needs a time source to handle executor spins and synchronize reliable communication. To achieve this, a clock_gettime POSIX compliant implementation is required, with a minimum resolution of 1 millisecond.

This method shall be included on a clock_gettime.cpp source file under the ./platform_code/<framework>/ path, an example implementation can be found on clock_gettime.cpp

Using the micro-ROS Agent

It is possible to use a micro-ROS Agent just by using this docker command:

# UDPv4 micro-ROS Agent
docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:$ROS_DISTRO udp4 --port 8888 -v6

# Serial micro-ROS Agent
docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:$ROS_DISTRO serial --dev [YOUR BOARD PORT] -v6

# TCPv4 micro-ROS Agent
docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:$ROS_DISTRO tcp4 --port 8888 -v6

# CAN-FD micro-ROS Agent
docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:$ROS_DISTRO canfd --dev [YOUR CAN INTERFACE] -v6

For the supported transports, only the serial and udp4 versions shall be used, although users can develop and use the agent to test their own tcp4 and canfd custom transports.

It is also possible to use custom transports on a micro-XRCE Agent instance. More info available here.

Examples

A simple publisher project using serial transport is available on the examples directory, this examples is meant to be modified with the user board.

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