Awesome
micro-ROS for Renesas e<sup>2</sup> studio
This package eases the integration of micro-ROS in a Renesas e<sup>2</sup> 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 <br /> Serial UART <br /> UDP (FreeRTOS + TCP) <br /> UDP (ThreadX + NetX) <br /> TCP (AWS Secure Sockets) <br /> CAN FD |
RA6T2 | RA Series | MCK-RA6T2 | Serial UART <br /> CAN FD |
Requirements
- Renesas e<sup>2</sup> studio for Linux<sup>1</sup>
- FSP v5.6.0 board packs for Renesas e<sup>2</sup> 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
<sup>1</sup> 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 e<sup>2</sup> 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:
- Building it in a ROS 2 environment: Details.
- Using a snap package.
Integrating micro-ROS in your project
micro-ROS can be integrated with a Renesas e<sup>2</sup> studio project following these steps:
-
Clone this repository in your Renesas e<sup>2</sup> studio project folder.
-
Go to
Project -> Properties -> C/C++ Build -> Settings -> Build Steps Tab
and inPre-build steps
add:
cd ../micro_ros_renesas2estudio_component/library_generation && ./library_generation.sh "${cross_toolchain_flags}"
-
Add <b>micro-ROS include directory</b>.
<details> <summary>Steps</summary>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}"
inInclude paths (-l)
- add
-
Add the micro-ROS precompiled library.
<details> <summary>Steps</summary>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}"
inLibrary search path (-L)
- add
microros
inLibraries (-l)
- add
-
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
-
Configure micro-ROS time reference.
<details> <summary>Steps</summary>Configure
g_timer0
as anr_agt
-
Double click on the
configuration.xml
file of your project and go to theStacks
tab. -
Select
New Stack -> Timer Low-Power (r_agt)
. -
Modify the clock period on the component properties (
Module g_timer0 Timer, Low-Power (r_agt) -> General -> Period
) to100
-
Modify the clock period unit on the component properties (
Module g_timer0 Timer, Low-Power (r_agt) -> General -> Period Unit
) toMicroseconds
-
Modify the count source on the component properties (
Module g_timer0 Timer, Low-Power (r_agt) -> General -> Count Source
) toPCLKB
-
Modify the interrupt callback on the component properties (
Module g_timer0 Timer, Low-Power (r_agt) -> Interrupt -> Callback
) tomicro_ros_timer_cb
-
Modify the underflow interrupt priority on the component properties (
Module g_timer0 Timer, Low-Power (r_agt) -> Interrupt -> Underflow Interrupt Priority
) toPriority 12
-
Save the modifications by clicking on
Generate Project Content
.
-
-
Configure micro-ROS memory requirements.
<details> <summary>Bare Metal</summary>Configure the stack and heap size:
-
On the
configuration.xml
menu, go to theBSP
tab. -
Go to the
RA Common
section and set theMain stack size (bytes)
andHeap size (bytes)
fields to 5000 B: -
Save the modifications by clicking on
Generate Project Content
.
Create and configure the micro-ROS FreeRTOS task:
-
On the
configuration.xml
menu, go to theStacks
tab and create a new thread for micro-ROS. -
Click on the created thread, then select
New Stack -> FreeRTOS Heap 4
. -
Configure the micro-ROS thread properties:
- Set the name of the thread entry function under
Thread -> Symbol
tomicro_ros_thread
. - Set
Thread -> Stack size (bytes)
to 5000 B. - Set
Common -> Memory Allocation -> Support Dynamic Allocation
toEnable
. - Set
Common -> Memory Allocation -> Support Static Allocation
toEnable
. - Set
Common -> Memory Allocation -> Total Heap Size
to 65000 B.
- Set the name of the thread entry function under
-
On the
configuration.xml
menu, go to theBSP
tab. -
Go to the
RA Common
section and set theMain stack size (bytes)
andHeap size (bytes)
fields to 5000 B:Note: It is required to have some heap outside FreeRTOS heap because newlib will use it
-
Save the modifications clicking on
Generate Project Content
. -
Check that the file
thread_microros_entry.c
has been created on the project source directory.
Create and configure the micro-ROS ThreadX thread:
-
On the
configuration.xml
menu, go to theStacks
tab and create a new thread for micro-ROS. -
Configure the micro-ROS thread properties:
- Set the name of the thread entry function under
Thread -> Symbol
tomicro_ros_thread
. - Set and the thread stack size
Thread -> Stack size (bytes)
to 5000 B. - Increase thread timer resolution
Common -> Timer -> Timer Ticks Per Second
to 1000 ticks per second.
- Set the name of the thread entry function under
-
On the
configuration.xml
menu, go to theBSP
tab. -
Go to the
RA Common
section and set theMain stack size (bytes)
andHeap size (bytes)
fields to 5000 B: -
Save the modifications by clicking on
Generate Project Content
. -
Check that the file
thread_microros_entry.c
has been created on the project source directory.
-
-
Configure the micro-ROS transports: Details.
-
Add micro-ROS code in your codebase.
-
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.