Skip to content

Navigation Menu

Sign in
Sign up

micro-ROS for PlatformIO - Call to action! #2

pablogs9 started this conversation in General
Discussion options

Hi, micro-ROS community!

As you might know, PlatformIO has become a really popular solution for embedded development, it provides a complete embedded development environment compatible with tons of boards, frameworks, and platforms.

Most of you have been using our micro-ROS for Arduino library to integrate micro-ROS in the PlatformIO environment, but we think that we can do it much better. So, we have been developing a proper solution for integrating the micro-ROS build system in the PlatformIO build system.

micro-ROS for Arduino provide a precompiled set of libraries due to the lack of advanced features for building the micro-ROS stack in the Arduino IDE/CLI development environment. Meanwhile, PlatformIO allows complex build processes where the micro-ROS library can be compiled just in time for the used platform avoiding cross-compilation compatibility issues. Also, it provides a much more flexible way of configuring the micro-ROS library with custom packages and/or custom middleware configurations.

We have reached a semi-functional status where some platforms are supported but we need your help to provide feedback and comments about your needs as micro-ROS developers. So we are opening a beta testing period before releasing this tool on the PlatformIO registry.

We ask the community to:

  • test current available boards and transports
  • add / request / recommend new boards and transports
  • test the whole functionality and advice new features

Sincerely, the micro-ROS team.

Technical details

The micro-ROS library for PlatformIO is designed to be modular. It relies on the advanced scripting features of the build system. As you can see in extra_script.py, the library is being built on the fly using the compiler and flags that the environment provides.

In platform_code folder we include sources related to the framework. In this case, only arduino is implemented.

This way, arduino/clock_gettime.cpp provides a the timing functionality required by micro-ROS using the Arduino API. As you can see, there are much more interesting frameworks such as CMSIS, FreeRTOS, libopencm3 or Zephyr RTOS. That means that those frameworks should be integrated creating [FRAMEWORK]/clock_gettime.cpp and adding the corresponding scripting here.

Regarding the transports, they are also included in the framework folder. For example, the Serial transport for arduino is implemented using the Serial API of the Arduino framework. One more time, the extra_script.py takes care of building the required transport. In the same way, by adding folders to this directory tree, more transports can be implemented using different frameworks APIs.

This way you can create a PlaformIO project with the following .ini:

[env:portenta_h7_m7]
platform = ststm32
board = portenta_h7_m7
framework = arduino
microros_transport = serial
microros_distro = galactic
lib_deps =
 https://github.com/micro-ROS/micro_ros_platformio

.meta files can be added to the enviroment configuration just using microros_user_meta = [PATH TO YOUR META] . This will override parameters of the micro-ROS build.

Tasks to be done

The following tasks should be addressed:

Task PR Owner
Update repo README.md #3 micro-ROS team
Add support for Rolling #17 micro-ROS team
Implement extra_packages #12 micro-ROS team
Create example projects #16 micro-ROS team
Remove PlatformIO from micro-ROS for Arduino repo micro-ROS/micro_ros_arduino#957 micro-ROS team
Add clean step for micro-ROS library #15 micro-ROS team
Create a Renode CI/CD

Board testing

The following use cases shall be tested in hardware:

Board Platform Framework Transport Owner Status
portenta_h7_m7 ststm32 arduino serial @pablogs9 Working
teensy41 teensy arduino serial @pablogs9 Working
teensy40 teensy arduino serial
teensy36 teensy arduino serial
teensy35 teensy arduino serial
teensy31 teensy arduino serial @pablogs9 Working
due atmelsam arduino serial
zero atmelsam arduino serial
olimex_e407 ststm32 arduino serial @pablogs9 Working
esp32dev espressif32 arduino serial
nanorp2040connect raspberrypi arduino serial @pablogs9 Working
teensy41 teensy arduino native_ethernet
nanorp2040connect raspberrypi arduino wifi_nina @pablogs9 Working
portenta_h7_m7 ststm32 arduino wifi @pablogs9 Working
esp32dev espressif32 arduino wifi
You must be logged in to vote

Replies: 8 comments 28 replies

Comment options

Hi @pablogs9,

Thanks for using PlatformIO! 😊 A few comments for integration:

  1. microros_transport = serial, users will see a warning about the unknowing configuration option. Please use board_microros.transport = upload. Later you can get this data via env.BoardConfig().get("microros.transport")

  2. global_env['LIBS'].append(, global_env['_CPPDEFFLAGS'], please don't operate with private SCons scopes. See https://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-flags

Please ping me when you apply changes in https://github.com/micro-ROS/micro_ros_platformio/blob/main/extra_script.py

Thanks for your work!

You must be logged in to vote
19 replies
Comment options

@ivankravets Of course, there you go:

issue_example.zip

Comment options

Add micro-ROS defines to user application

The user's application has its own isolated environment named projenv. See example https://docs.platformio.org/en/latest/manifests/library-json/fields/build/extrascript.html

Please note that you will need to use the latest PIO Core Dev (pio upgrade --dev). Accessing projenv in library extra script was added in PIO Core 6.0.3 that has not been released yet.

Does it work now?

Comment options

Yes!

Is there a way to get the used PIO Core version inside the extrascript?
I would like to keep this working for users with older versions.

Comment options

Sorry for the delay, PlaformIO Core 6.1 is out! Please upgrade https://github.com/platformio/platformio-core/releases/tag/v6.1.0

Comment options

Thanks! Upgrading on #36

Comment options

Just merged extra_packages functionality on #12.
Usage is documented on README.md PR #3.

You must be logged in to vote
0 replies
Comment options

I will try to use this library in my project. It should go fairly easy as it already uses PlatformIO. The project requires support for:

  • custom meta file
  • custom transport
  • custom clock_gettime
  • extra packages

As all of this is possible now, I'll start trying to switch to this library and report any issues or ask questions when unsure about something.

You must be logged in to vote
0 replies
Comment options

What should I set board_microros_transport to when I use a custom transport?

You must be logged in to vote
5 replies
Comment options

You have to create a <framework>/<board_microros_transport> folder on the [platform_code](https://github.com/micro-ROS/micro_ros_platformio/tree/main/platform_code) folder.

For example:

Comment options

I would rather avoid modifying this project to add my custom transport. I currently have the sources for the custom transport under my project's src directory. The library script:

 # Add platformio library general include path
 global_env.Append(CPPPATH=[
 main_path + "/platform_code",
 main_path + "/platform_code/{}/{}".format(framework, microros_transport)])
 # Add platformio library general to library include path
 env.Append(CPPPATH=[
 main_path + "/platform_code",
 main_path + "/platform_code/{}/{}".format(framework, microros_transport)])

will still add additional include paths no matter what I set board_microros_transport to.

Could we, for example, make setting the board_microros_transport to custom not add the additional include paths?

Comment options

pablogs9 Apr 27, 2022
Maintainer Author

That's a good idea. We will take a look at that.

Comment options

pablogs9 Apr 27, 2022
Maintainer Author

Working on it here: #21

Comment options

#21 merged, the additional include paths will only add the aux micro_ros_platformio.h header.

You can check the custom transport section on the repository README and an actual example on our CI project source, under the #if defined(MICRO_ROS_TRANSPORT_ARDUINO_CUSTOM) conditionals.

@bjsowa Also, we would be happy to add your use case's transport to the repository, feel free to open a PR.

Comment options

Main task completed and merged, we are ready for Remove PlatformIO from micro-ROS for Arduino repo step.

You must be logged in to vote
2 replies
Comment options

pablogs9 Apr 21, 2022
Maintainer Author

Go ahead

Comment options

Done! micro-ROS/micro_ros_arduino#957
Also added to micro_ros_setup docs: micro-ROS/micro_ros_setup#504

Comment options

I've tested the seeed_xiao and mkrzero boards with serial and they seem to work fine.

You must be logged in to vote
0 replies
Comment options

I have been developing my own custom messages within the extra_packages folder. This is working well so far, but I find the required re-compilation process of microROS to be a little annoying.

It is very slow and downloads many things behind the scenes, so it is a bit inefficient. Is there a way to force a recompilation of libraries without downloading everything again?

You must be logged in to vote
2 replies
Comment options

pablogs9 Jun 16, 2023
Maintainer Author

Comment options

It is very slow and downloads many things behind the scenes, so it is a bit inefficient. Is there a way to force a recompilation of libraries without downloading everything again?

No, this is not possible right now.

You can modify the build script to avoid deleting the sources, triggering a colcon build over the updated extra_packages.
But this is not trivial and may take an excesive ammount of time.

Maybe you can use a Linux app to test your micro-ROS app, the rebuild would be quite faster with this approach.

Comment options

Hello, community!
I was spending many time struggling with that error comes from strdup.c library.
The project includes esp32 platform.
Build command:

pio run -e esp32-espidf

Screen of error.
Untitled
Learning of solutions in www didn't provide me any positive effect. Could it be fixed somehow? Please, take a look.

UPD:
I detected that context of strdup.c file which comes after classical installation from here differs from context provided this platformio repository.
In the classical we have call rcutils_strndup(str, strlen(str), allocator)
In PlatformIO we have call rcutils_strndup(str, SIZE_MAX, allocator)
There is the root of error behaviour. Could versions of code be aligned in the future?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /