Skip to content

A set of utilities for integrating micro-ROS in a Renesas e2 studio project

License

Notifications You must be signed in to change notification settings

micro-ROS/micro_ros_renesas2estudio_component

Repository files navigation

banner banner

micro-ROS for Renesas e2 studio

micro-ROS HIL tests micro-ROS HIL agent

This package eases the integration of micro-ROS in a Renesas e2 studio. This components targets Renesas RA family, an ARM Cortex-M based MCU series, enabling a full micro-ROS compatibility for developing robotics and IoT applications.


Supported platforms

MCU Family Reference board Transports
RA6M5 RA Series EK-RA6M5 USB-CDC
Serial UART
UDP (FreeRTOS + TCP)
UDP (ThreadX + NetX)
TCP (AWS Secure Sockets)
CAN FD
RA6T2 RA Series MCK-RA6T2 Serial UART
CAN FD

Requirements

  • Renesas e2 studio for Linux1
  • FSP v5.6.0 board packs for Renesas e2 studio: Details.
  • GNU Arm Embedded Toolchain v10.3.1.20210824 (Other compatible toolchain may work).
  • Install rsync: apt -y install rsync
  • Install colcon and dependencies, for example with:
pip3 install colcon-common-extensions catkin_pkg lark-parser empy

1 Currently only support for Linux is available

Getting started

A ready-to-use example of this component can be found in micro-ROS demos for Renesas e2 studio repo.

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

# 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

# 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

# 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

There are some other options for using the micro-ROS Agent:

Integrating micro-ROS in your project

micro-ROS can be integrated with a Renesas e2 studio project following these steps:

  1. Clone this repository in your Renesas e2 studio project folder.

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

cd ../micro_ros_renesas2estudio_component/library_generation && ./library_generation.sh "${cross_toolchain_flags}"
  1. Add micro-ROS include directory.

    Steps

    In Project -> Settings -> C/C++ Build -> Settings -> Tool Settings Tab -> GNU ARM Cross C Compiler -> Includes

    • add "${workspace_loc:/${ProjName}/micro_ros_renesas2estudio_component/libmicroros/include}" in Include paths (-l)
  2. Add the micro-ROS precompiled library.

    Steps

    In Project -> Settings -> C/C++ Build -> Settings -> Tool Settings Tab -> GNU ARM Cross C Linker -> Libraries

    • add "${workspace_loc:/${ProjName}/micro_ros_renesas2estudio_component/libmicroros}" in Library search path (-L)
    • add microros in Libraries (-l)
  3. 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/microros_allocators.h
    • extra_sources/microros_transports.h
  4. Configure micro-ROS time reference.

    Steps

    Configure g_timer0 as an r_agt

    1. Double click on the configuration.xml file of your project and go to the Stacks tab.

    2. Select New Stack -> Timer Low-Power (r_agt).

    3. Modify the clock period on the component properties (Module g_timer0 Timer, Low-Power (r_agt) -> General -> Period) to 100

    4. Modify the clock period unit on the component properties (Module g_timer0 Timer, Low-Power (r_agt) -> General -> Period Unit) to Microseconds

    5. Modify the count source on the component properties (Module g_timer0 Timer, Low-Power (r_agt) -> General -> Count Source) to PCLKB

    6. Modify the interrupt callback on the component properties (Module g_timer0 Timer, Low-Power (r_agt) -> Interrupt -> Callback) to micro_ros_timer_cb

    7. Modify the underflow interrupt priority on the component properties (Module g_timer0 Timer, Low-Power (r_agt) -> Interrupt -> Underflow Interrupt Priority) to Priority 12

      image

    8. Save the modifications by clicking on Generate Project Content.

  5. Configure micro-ROS memory requirements.

    Bare Metal

    Configure the stack and heap size:

    1. On the configuration.xml menu, go to the BSP tab.

    2. Go to the RA Common section and set the Main stack size (bytes) and Heap size (bytes) fields to 5000 B:

      image

    3. Save the modifications by clicking on Generate Project Content.

    FreeRTOS

    Create and configure the micro-ROS FreeRTOS task:

    1. On the configuration.xml menu, go to the Stacks tab and create a new thread for micro-ROS.

    2. Click on the created thread, then select New Stack -> FreeRTOS Heap 4.

    3. Configure the micro-ROS thread properties:

      1. Set the name of the thread entry function under Thread -> Symbol to micro_ros_thread.
      2. Set Thread -> Stack size (bytes) to 5000 B.
      3. Set Common -> Memory Allocation -> Support Dynamic Allocation to Enable.
      4. Set Common -> Memory Allocation -> Support Static Allocation to Enable.
      5. Set Common -> Memory Allocation -> Total Heap Size to 65000 B.

      image

    4. On the configuration.xml menu, go to the BSP tab.

    5. Go to the RA Common section and set the Main stack size (bytes) and Heap size (bytes) fields to 5000 B:

      image

      Note: It is required to have some heap outside FreeRTOS heap because newlib will use it

    6. Save the modifications clicking on Generate Project Content.

    7. Check that the file thread_microros_entry.c has been created on the project source directory.

    ThreadX

    Create and configure the micro-ROS ThreadX thread:

    1. On the configuration.xml menu, go to the Stacks tab and create a new thread for micro-ROS.

    2. Configure the micro-ROS thread properties:

      1. Set the name of the thread entry function under Thread -> Symbol to micro_ros_thread.
      2. Set and the thread stack size Thread -> Stack size (bytes) to 5000 B.
      3. Increase thread timer resolution Common -> Timer -> Timer Ticks Per Second to 1000 ticks per second.

      image

    3. On the configuration.xml menu, go to the BSP tab.

    4. Go to the RA Common section and set the Main stack size (bytes) and Heap size (bytes) fields to 5000 B:

      image

    5. Save the modifications by clicking on Generate Project Content.

    6. Check that the file thread_microros_entry.c has been created on the project source directory.

  6. Configure the micro-ROS transports: Details.

  7. Add micro-ROS code in your codebase.

  8. Build and run your project.

Adding custom packages to the micro-ROS build

In order to include a custom package in the micro-ROS build, just copy the package folder into library_generation/extra_packages folder. The build system will automatically detect the package and build it along with the micro-ROS library.

Note that a library rebuild is needed to include the package, this can be achieved by deleting the libmicroros generated folder and building your project afterwards.

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.

About

A set of utilities for integrating micro-ROS in a Renesas e2 studio project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •