Building for microcontroller · Issue #5 · Pico-ROS/Pico-ROS-software · GitHub
Skip to content

Building for microcontroller #5

Open

Description

@xopxe

Should it be possible to build this for ESP32 microcontrollers, whether using Platformio or esp-idf?

The project's files (content in src) appear to be buildable.
Zenoh-pico seems to be buildable and already available as a library when using Platformio.
The problem is Micro-CDR, which is rather complex.

I quickly threw the code into an empty esp-idf project and added the following to the project's CMakeList.txt

add_definitions(-DZENOH_ESPIDF)
ExternalProject_Add(pico-ros-software
    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Pico-ROS-software
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Pico-ROS-software/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Pico-ROS-software/thirdparty/zenoh-pico/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Pico-ROS-software/thirdparty/Micro-CDR/include)

This does not work when building Micro-CDR (some config.h files are misplaced, the user_types.h file is missing). But before diving into this I'd like to know if this is feasible at all, and if so any help would be welcome.

Activity

  1. changed the title [-]Building for microcontroler[/-] [+]Building for microcontroller[/+] on Aug 27, 2025
  2. g4sp3r commented on Aug 27, 2025

    @g4sp3r
    Collaborator

    Hi @xopxe.
    It's possible. Please see esp-idf example project here. There is also esp-idf component for easier integration.

    For platformIO on Arduino framework I think you could find some inspiration in roscon2025_control_workshop.

  3. xopxe commented on Aug 27, 2025

    @xopxe
    ContributorAuthor

    Great! Will try it.

  4. g4sp3r commented on Aug 28, 2025

    @g4sp3r
    Collaborator

    @xopxe, could you please check if #6 helps with the issues you were having originally?

  5. xopxe commented on Aug 28, 2025

    @xopxe
    ContributorAuthor

    @g4sp3r, as a note I successfully built and ran code based on the esp-idf component.

    With this branch I did the following:

    • Created an empty esp-idf project (using VS-Code).
    • Cloned this repo inside the main directory (alongside the main.c)
    • In the repo ran git checkout ucdr_config and git submodule update --init --recursive
    • Added to the main/CMakeLists.txt.
    add_definitions(-DZENOH_ESPIDF)
    ExternalProject_Add(pico-ros-software
        SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Pico-ROS-software
    )
    
    • Hit Full Clean and Build.

    The build failed with:

    ...
    [161/163] Linking C executable batteryState_publisher
    [162/163] Building C object CMakeFiles/test_examples_types_serdes.dir/test/test_picoserdes.c.o
    [163/163] Linking C executable test_examples_types_serdes
    [1012/1018] Performing install step for 'pico-ros-software'
    FAILED: esp-idf/main/pico-ros-software-prefix/src/pico-ros-software-stamp/pico-ros-software-install /workspaces/pico-ros-espidf-test/build/esp-idf/main/pico-ros-software-prefix/src/pico-ros-software-stamp/pico-ros-software-install 
    cd /workspaces/pico-ros-espidf-test/build/esp-idf/main/pico-ros-software-prefix/src/pico-ros-software-build && /opt/esp/tools/cmake/4.0.3/bin/cmake --build . --target install && /opt/esp/tools/cmake/4.0.3/bin/cmake -E touch /workspaces/pico-ros-espidf-test/build/esp-idf/main/pico-ros-software-prefix/src/pico-ros-software-stamp/pico-ros-software-install
    ninja: error: unknown target 'install'
    [1013/1018] Generating esp-idf/esp_system/ld/sections.ld
    ninja: build stopped: subcommand failed.
    

    The full build output is here

  6. g4sp3r commented on Aug 31, 2025

    @g4sp3r
    Collaborator

    Hey @xopxe, great that you got the idf-component working.

    Thanks for testing the PR. I could get a bit further with ExternalProject_Add by setting INSTALL_COMMAND="" but then decided on this way...

    main/CMakeLists.txt:

    #idf_component_register(...)
    
    add_definitions(-DZENOH_ESPIDF)
    include_directories(
        "."
        "picoros/thirdparty/config"
        "picoros/src/"
        "picoros/thirdparty/Micro-CDR/include/"
        "picoros/thirdparty/zenoh-pico/include/"
        "picoros/thirdparty/zenoh-pico/include/zenoh-pico/"
    )
    add_definitions(-DUSER_TYPE_FILE="my_types.h")
    set(PICOROS_BUILD_EXAMPLES OFF)
    set(PICOROS_BUILD_EXAMPLES OFF)
    add_compile_options(-Wno-error=maybe-uninitialized)
    add_subdirectory(picoros)
    include_directories(${IDF_PATH}/components/esp_driver_uart/include/)
    target_link_libraries(zenohpico_static idf::driver)
    # target_link_libraries(main picoros picoserdes)
    # target_link_libraries(idf:main picoros picoserdes)

    It now fails at linking step with unresolved references. I can't seem to find the correct name for target which should be main according to the docs

    I think for ESP32 on ESP-IDF framework idf-component is currently a cleaner approach.

    I will merge the PR but leave this issue open. Maybe somebody will find a better solution.

  7. xopxe commented on Sep 1, 2025

    @xopxe
    ContributorAuthor

    Good to know @g4sp3r.
    Just to keep you informed, I also got it to work with Arduino over Platformio based on roscon2025_control_workshop, as you recommended. The process is not pretty, involving cloning stuff right in the build directory and manually placing files from Micro-CDR in the source tree, but it works.

  8. g4sp3r commented on Sep 1, 2025

    @g4sp3r
    Collaborator

    Great that you got it working @xopxe.
    The build process and project setup outlined in the workshop could probably be improved.

    My experience with PlatformIO is unfortunately limited and currently I don't have the cycles to test myself. I think the above PR should at least help a bit.

    If something comes up I would be happy to accept PRs to better support PlatformIO or any other framework.
    Example projects for different targets and frameworks would also be useful.

  9. xopxe commented on Sep 2, 2025

    @xopxe
    ContributorAuthor

    Thanks for the support @g4sp3r.
    As soon as I finish this project I'll try to clean it up and at least provide clear instructions for building.

  10. Alvin0523 commented on Dec 19, 2025

    @Alvin0523

    Hihi i used platformio and managed to use espidf framework and i was able to discover the ROS Topic. But i was not able to echo the data for some reason.... Anyone facing the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions