Issues using Micro-ROS's precompiled libraries with Arduino and Teensy

youngrobo

New member
BLUF: I am unable to use Teensy with Micro-ROS in any version of Arduino (1.8.x or 2.x) due to errors with libraries that I do not know how to resolve

What I am using:
  • Ubuntu 22.04
  • Teensy 3.2
  • Arduino 1.8.19 & Arduino 2.1.1
  • ROS Humble


Hi, I'm a novice user, but have been using a Teensy 3.2 to control some serial devices with json messaging from a Python script. I am now trying to improve the system by incorporating Micro-ROS and controlling the device with ROS messaging. I have followed a handful of guides but have found these two to be the most comprehensive and have followed them as best I can:

When using the Micro-ROS Tutorial, I have failed to successfully compile the "micro_ros_publisher.ino" file:
I have had some success with the tutorial in both Arduino 1.8.x and Arduino 2.x. In both, I have gotten the Teensy working with Arduino for all programs not incorporating Micro-ROS. Upon incorporating Micro-ROS, however, I am stuck. When compiling the example code from the tutorial, "micro_ros_publisher.ino", I am met with the same error in both Arduino versions (I have replaced "/home/username" with "~" for anonymity):
Code:
WARNING: library micro_ros_arduino claims to run on stm32, OpenCR, Teensyduino, samd, sam, mbed, esp32, mbed_portenta architecture(s) and may be incompatible with your current board which runs on avr architecture(s).
Library micro_ros_arduino has been declared precompiled:
Using precompiled library in ~/Arduino/libraries/micro_ros_arduino-2.0.7-humble/src/mk20dx256
The platform does not support 'compiler.libraries.ldflags' for precompiled libraries.
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/86D3DC662F02BE1363BEFA39A70A0B11/sketch/micro_ros_publisher.ino.cpp.o: in function `timer_callback(rcl_timer_s*, long long)':
~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:36: undefined reference to `rcl_publish'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/86D3DC662F02BE1363BEFA39A70A0B11/sketch/micro_ros_publisher.ino.cpp.o: in function `setup':
~/Arduino/libraries/micro_ros_arduino-2.0.7-humble/src/micro_ros_arduino.h:33: undefined reference to `rmw_uros_set_custom_transport'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/86D3DC662F02BE1363BEFA39A70A0B11/sketch/micro_ros_publisher.ino.cpp.o: in function `setup':
~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:49: undefined reference to `rcutils_get_default_allocator'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:52: undefined reference to `rclc_support_init'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:55: undefined reference to `rclc_node_init_default'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:58: undefined reference to `rosidl_typesupport_c__get_message_type_support_handle__std_msgs__msg__Int32'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:58: undefined reference to `rclc_publisher_init_default'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:66: undefined reference to `rclc_timer_init_default'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:73: undefined reference to `rclc_executor_init'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:74: undefined reference to `rclc_executor_add_timer'
~/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino/sketches/86D3DC662F02BE1363BEFA39A70A0B11/sketch/micro_ros_publisher.ino.cpp.o: in function `loop':
~/Arduino/micro_ros_publisher/micro_ros_publisher.ino:81: undefined reference to `rclc_executor_spin_some'
collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

I have found the libraries online, but do not know how to take this source code and place it in the Arduino library correctly:

When attempting to follow the Micro-ROS GitHub's README instructions, I am unable to complete the How to build the precompiled library step:
This walk-through uses docker to build the precompiled libraries, but the commands listed cause issues when I run them in terminal:
Code:
$ docker run -it --rm -v $(pwd):/project --env MICROROS_LIBRARY_FOLDER=extras microros/micro_ros_static_library_builder:humble
dos2unix: /project/extras/library_generation/library_generation.sh: No such file or directory
dos2unix: Skipping /project/extras/library_generation/library_generation.sh, not a regular file.

I apologize if this is insufficient information provided, but I greatly appreciate any and all help you can provide! Thank you for your time.
 
Thank you for your reply.
ArduinoIDE_Board_Selection.png
That is what the error message seems to indicate, though, I have tried it with Teensy's auto-generated port and specifying the port and board directly but the results are the same. I am able to run examples from the Teensy library, which makes me think the board targeting is not the issue, despite the warning. In Arduino 1.8.19, the finishing note of the error message is slightly different and seems to support this thinking:
Code:
collect2: error: ld returned 1 exit status
Error compiling for board Teensy 3.2 / 3.1.
 
Last edited:
Looking at the github repository looks like there is a patch that needs to be applied: https://github.com/micro-ROS/micro_ros_arduino#patch-arduino-board-for-support-precompiled-libraries

Go inside your Arduino + Teensyduino installation and replace platform.txt:
Code:
export TEENSYDUINO_VERSION=[Your Teensyduino library version, e.g: 1.57.2]
export ARDUINO_PATH=[Your Arduino + Teensyduino path]
cd $ARDUINO_PATH/hardware/avr/$TEENSYDUINO_VERSION/
curl https://raw.githubusercontent.com/micro-ROS/micro_ros_arduino/iron/extras/patching_boards/platform_teensy.txt > platform.txt

Can't
 
I have run the patch you are referring to but have not had success with this fixing the issue. However, the location of my platform.txt file(s) is a bit different than what is described by this code block (the numbers and parentheses do not appear in the search but I added them for ease of reference):
Code:
~$ find . -name platform.txt
(1) ./.arduino15/packages/teensy/hardware/avr/1.58.1/platform.txt
(2) ./Programs/arduino-1.8.19/hardware/arduino/avr/platform.txt
(3) ./Programs/arduino-1.8.19/hardware/teensy/avr/platform.txt
Looking at the raw text, (2) seems to be unrelated to the patch. (1) and (3) are very similar to one another and the web text file referenced in the curl command, but have slight differences, which are best shown in a diff checker. I will attach the files to this post as well.

I am not an expert on curl, but after running the curl command on either of these locations, they remain different from the web text file; I also noticed that the "% Xferd" category shows 0 in each instance. I have tried manually replacing the contents of both files with each other's contents and the contents of the web text file. Any manual substitutions to (1) seem to have no effect while substitutions in (3) cause the error to change to the following:
Code:
fork/exec /arm/bin/arm-none-eabi-g++: no such file or directory
Error compiling for board Teensy 3.2 / 3.1.
This may be the source of my issue, but the patch as it is written in that tutorial is not fixing my issues. I have attached all versions of the file referenced.
 

Attachments

  • platform(2).txt
    7.5 KB · Views: 20
  • platform(1).txt
    7.8 KB · Views: 20
  • platform(web).txt
    7.3 KB · Views: 24
  • platform(3).txt
    7.8 KB · Views: 22
I have run the patch you are referring to but have not had success with this fixing the issue. However, the location of my platform.txt file(s) is a bit different than what is described by this code block (the numbers and parentheses do not appear in the search but I added them for ease of reference):
Code:
~$ find . -name platform.txt
(1) ./.arduino15/packages/teensy/hardware/avr/1.58.1/platform.txt
(2) ./Programs/arduino-1.8.19/hardware/arduino/avr/platform.txt
(3) ./Programs/arduino-1.8.19/hardware/teensy/avr/platform.txt
Looking at the raw text, (2) seems to be unrelated to the patch. (1) and (3) are very similar to one another and the web text file referenced in the curl command, but have slight differences, which are best shown in a diff checker. I will attach the files to this post as well.

I am not an expert on curl, but after running the curl command on either of these locations, they remain different from the web text file; I also noticed that the "% Xferd" category shows 0 in each instance. I have tried manually replacing the contents of both files with each other's contents and the contents of the web text file. Any manual substitutions to (1) seem to have no effect while substitutions in (3) cause the error to change to the following:
Code:
fork/exec /arm/bin/arm-none-eabi-g++: no such file or directory
Error compiling for board Teensy 3.2 / 3.1.
This may be the source of my issue, but the patch as it is written in that tutorial is not fixing my issues. I have attached all versions of the file referenced.
Were you able to find solution to this? I faced the same issue. I downgraded to Teensy 1.57.2 version and it worked without errors. I think this issue is particular to Teensy loader 1.58+ .
 
Back
Top