Repo symbol

micro_ros_ei repository

Repo symbol

micro_ros_ei repository

Repo symbol

micro_ros_ei repository

Repo symbol

micro_ros_ei repository

Repository Summary

Description
Checkout URI https://github.com/avibrown/micro_ros_ei.git
VCS Type git
VCS Version main
Last Updated 2023-01-24
Dev Status UNKNOWN
Released UNRELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ei_interfaces 0.0.0

README

For a full tutorial writeup: https://docs.edgeimpulse.com/experts/ros2-part2-microros

Click image for YouTube tutorial video:


Equipment and software

  • Arduino Portenta H7 + vision shield (more boards coming soon!)
  • Linux computer running ROS2

Getting started

You’ll need to install a few things in order to follow along with this tutorial:


micro-ROS Arduino library

Clone the library from this repository and add the .ZIP folder to your Arduino IDE. This library comes precompiled, but we’ll need to rebuild it after we add the custom Edge Impulse ROS2 message types (to be discussed).


Custom Edge Impulse message types

To ease the process of interfacing Edge Impulse with micro-ROS two custom message types were created:

  • EIClassification: Contains a label and value, like {'label': 'cat', 'value': 0.75}. One classification contains one class name and the probability given to that class by the neural network.
  • EIResult: Contains multiple classifications - as many as your neural network needs. A full result looks like this: [{'label': 'cat', 'value': 0.75}, {'label': 'dog', 'value': 0.25}].

In order to use these message types they need to be added to both your ROS2 and micro-ROS environments. Clone the micro-ROS + Edge Impulse repository here and copy the ei_interfaces directory. This folder contains everything you need to build the custom message types.

To add it to your ROS2 system, navigate to:

ros2_ws/src

and paste the ei_interfaces directory inside. cd back to your main ros2_ws directory and from the terminal run colcon build.

You can confirm the message types were added by running the following from the terminal:

ros2 interface list | grep EI

You should see:

ros2 interface list | grep EI
    ei_interfaces/msg/EIClassification
    ei_interfaces/msg/EIResult

To add it to your MicroROS environment, navigate to the micro-ROS Arduino library (that you cloned added to the Arduino IDE). You need to paste the same ei_interfaces directory inside the special extra_packages directory in the Arduino library. For me the path is:

~/Arduino/libraries/micro_ros_arduino-2.0.5-humble/extras/library_generation/extra_packages

Paste the directory there, return to the main micro_ros_arduino-2.0.5-humble directory, and use the docker commands from this part of the MicroROS Arduino readme:

Note: You may need to make the library_generation.sh (in /extras/library_generation) able to run as an executable (right click and change permissions) in order for the library builder to work!

docker pull microros/micro_ros_static_library_builder:humble

docker run -it --rm -v $(pwd):/project --env MICROROS_LIBRARY_FOLDER=extras microros/micro_ros_static_library_builder:humble -p portenta-m7

Note the -p flag at the end - it significantly reduces the build time if you specify your target. You can also run the command without this flag to build for all available targets, but it’ll take a while.


Arduino code

Now it’s time to export your Edge Impulse vision project as an Arduino library, and be sure to add the .ZIP folder to the Arduino IDE.

As for the example code for this project, find it here. Compile and upload the .ino file to your Arduino Portenta, and make sure the .h header file is in the same directory. I won’t be writing a line-by-line explanation of the code here - but here is some info on key points that make this all work.

Make sure to change the name of the included Edge Impulse library to the name of your own project:

// Replace this with <name_of_your_ei_library_inferencing.h>
#include <micro_ros_ei_inferencing.h>

MicroROS publisher

Inside the ei_result_publisher file, note that we include the two message types we added before:

```c++

File truncated at 100 lines see the full file

Repo symbol

micro_ros_ei repository

Repo symbol

micro_ros_ei repository

Repo symbol

micro_ros_ei repository

Repo symbol

micro_ros_ei repository