uROS Teensy Service issue
Hi all,
I'm working on porting more examples into the
micro-ROS/micro_ros_platformio
repository. I'm trying to use Teensy 4.1 with microROS, (uROS) under PlatformIO on Ubuntu 22.04.1 and ROS2 Humble
Currently the examples for microrosplatformio are limited to the
micro-ros_publisher
And I plan on expanding the repository with the work I'm preparing here. So be clear to understand this is not only for personal experience, but also to give back to the community.
However, I'm facing some challenges. I'm trying to change the arduino example step by step for teensy in platformIO
micro-ros_addtwoints_service
From
micro_ros_arduino/examples/
After this is successfull and I understand how to get it working I will merge it back and work also on the following.
micro-ros_subscriber
micro-ros_subscriber_twist
micro-ros_tf_publisher
So far I have spent 2 entire weekends researching and trying things on my own, but I can't figure it out. And before I burn more time on this I would kindly ask you for assistance. Please help me with the issue below to get me started and across my initial hurdle.
FIRST PROBLEM
in the below code it fails and shows red underline squiggles for the following line of code:
#include <example_interfaces/srv/add_two_ints.h>
FIRST PROBLEM FIX
was adding the proper include path for intelliSense. -> edit includepath setting-> added /opt/ros/humble/include/** to the bottom of the list
SECOND PROBLEM
void setup() { setmicrorostransports(); delay(1000);
Inside the setup() it dowsn't know "setmicrorostransports(); and also delay() is not known and it complains about it.
SECOND PROBLEM SOLUTION
As per the microrosplatformio documentation, I ensured the proper transports protocol is selected in platformio.ini
and under setup() I have added the following:
Serial.begin(115200);
set_microros_serial_transports(Serial);
The of course the compiler complained about Serial. being unknown. So I knew I forgot to
#include <Arduino.h>
PROBLEM THREE
When compiling / building the entire project following the documentation with the PlatformIO workflow:
pio lib install # Install dependencies
pio run # Build the firmware
pio run --target upload # Flash the firmware
I'm getting build errors and the compilation fails: Here the output:
administrator@dev01:~/Documents/gitclones/AutoBot_uros$ pio lib install
WARNING: This command is deprecated and will be removed in the next releases.
Please use `pio pkg install` instead.
Resolving teensy41 dependencies...
Library Manager: Installing git+https://github.com/micro-ROS/micro_ros_platformio
git version 2.34.1
Cloning into '/home/administrator/.platformio/.cache/tmp/pkg-installing-7zkg7pja'...
remote: Enumerating objects: 67, done.
remote: Counting objects: 100% (67/67), done.
remote: Compressing objects: 100% (52/52), done.
remote: Total 67 (delta 10), reused 44 (delta 4), pack-reused 0
Receiving objects: 100% (67/67), 125.47 KiB | 1.04 MiB/s, done.
Resolving deltas: 100% (10/10), done.
Library Manager: micro_ros_platformio@0.0.1+sha.22cf9b6 has been installed!
administrator@dev01:~/Documents/gitclones/AutoBot_uros$ pio run
Processing teensy41 (platform: teensy; board: teensy41; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy41.html
PLATFORM: Teensy (4.17.0) > Teensy 4.1
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
- framework-arduinoteensy @ 1.157.220801 (1.57)
- tool-teensy @ 1.157.0 (1.57)
- toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Installing pyyaml with pip at PlatformIO environment
/usr/bin/python3 -m pip install pyyaml
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (5.4.1)
Installing markupsafe==2.0.1 with pip at PlatformIO environment
/usr/bin/python3 -m pip install markupsafe==2.0.1
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: markupsafe==2.0.1 in /usr/lib/python3/dist-packages (2.0.1)
Configuring teensy41 with transport serial
Downloading micro-ROS dev dependencies
- Downloaded ament_cmake
- Downloaded ament_lint
- Downloaded ament_package
- Downloaded googletest
- Downloaded ament_cmake_ros
- Downloaded ament_index
Building micro-ROS dev dependencies
Downloading micro-ROS library
- Downloaded microcdr
- Downloaded microxrcedds_client
- Downloaded rcl_action
- Downloaded rcl
- Downloaded rcl_lifecycle
- Downloaded rcl_yaml_param_parser (ignored)
- Downloaded rclc
- Downloaded rclc_parameter
- Downloaded rclc_examples (ignored)
- Downloaded rclc_lifecycle
- Downloaded micro_ros_utilities
- Downloaded rcutils
- Downloaded micro_ros_msgs
- Downloaded rmw_microxrcedds
- Downloaded rosidl_typesupport_cpp (ignored)
- Downloaded rosidl_typesupport_c
- Downloaded rosidl_typesupport_microxrcedds_cpp (ignored)
- Downloaded rosidl_typesupport_microxrcedds_test_msg
- Downloaded rosidl_typesupport_microxrcedds_c_tests
- Downloaded rosidl_typesupport_microxrcedds_cpp_tests
- Downloaded rosidl_typesupport_microxrcedds_c
- Downloaded rosidl_runtime_c
- Downloaded rosidl_generator_cpp (ignored)
- Downloaded rosidl_typesupport_introspection_c
- Downloaded rosidl_typesupport_introspection_tests
- Downloaded rosidl_typesupport_introspection_cpp (ignored)
- Downloaded rosidl_parser
- Downloaded rosidl_cmake
- Downloaded rosidl_runtime_cpp (ignored)
- Downloaded rosidl_generator_c
- Downloaded rosidl_adapter
- Downloaded rosidl_typesupport_interface
- Downloaded rosidl_cli
- Downloaded rmw
- Downloaded rmw_implementation_cmake
- Downloaded builtin_interfaces
- Downloaded rcl_interfaces
- Downloaded test_msgs
- Downloaded statistics_msgs
- Downloaded composition_interfaces
- Downloaded lifecycle_msgs
- Downloaded rosgraph_msgs
- Downloaded action_msgs
- Downloaded rosidl_default_generators
- Downloaded rosidl_default_runtime
- Downloaded unique_identifier_msgs
- Downloaded visualization_msgs
- Downloaded stereo_msgs
- Downloaded actionlib_msgs
- Downloaded nav_msgs
- Downloaded diagnostic_msgs
- Downloaded sensor_msgs_py
- Downloaded trajectory_msgs
- Downloaded geometry_msgs
- Downloaded std_srvs
- Downloaded std_msgs
- Downloaded sensor_msgs
- Downloaded common_interfaces
- Downloaded shape_msgs
- Downloaded test_interface_files
- Downloaded rmw_implementation
- Downloaded test_rmw_implementation
- Downloaded rcl_logging_interface
- Downloaded rcl_logging_noop
- Downloaded rcl_logging_spdlog (ignored)
- Downloaded tracetools
- Downloaded tracetools_test
- Downloaded test_tracetools_launch
- Downloaded test_tracetools
- Downloaded tracetools_launch
- Downloaded ros2trace
- Downloaded tracetools_read
- Downloaded tracetools_trace
- Extra packages folder not found, skipping...
Building micro-ROS library
Found 93 compatible libraries
Scanning dependencies...
Dependency Graph
|-- micro_ros_platformio @ 0.0.1+sha.22cf9b6
Building in release mode
Compiling .pio/build/teensy41/src/main.cpp.o
Compiling .pio/build/teensy41/lib419/micro_ros_platformio/platform_code/arduino/clock_gettime.cpp.o
Compiling .pio/build/teensy41/lib419/micro_ros_platformio/platform_code/arduino/serial/micro_ros_transport.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/AudioStream.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/CrashReport.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/DMAChannel.cpp.o
src/main.cpp:4:49: fatal error: example_interfaces/srv/add_two_ints.h: No such file or directory
compilation terminated.
Compiling .pio/build/teensy41/FrameworkArduino/EventResponder.cpp.o
Compiling .pio/build/teensy41/FrameworkArduino/HardwareSerial.cpp.o
*** [.pio/build/teensy41/src/main.cpp.o] Error 1
===================================================================================================================================================== [FAILED] Took 132.80 seconds =====================================================================================================================================================
administrator@dev01:~/Documents/gitclones/AutoBot_uros$
Any suggestions on how to overcome the THIRD PROBLEM will be greatly appreciated!
Here is the entire source code:
//#include <micro_ros_arduino.h>
#include <micro_ros_platformio.h>
#include <example_interfaces/srv/add_two_ints.h>
#include <stdio.h>
#include <rcl/error_handling.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#include <std_msgs/msg/int64.h>
rcl_node_t node;
rclc_support_t support;
rcl_allocator_t allocator;
rclc_executor_t executor;
rcl_service_t service;
rcl_wait_set_t wait_set;
example_interfaces__srv__AddTwoInts_Response res;
example_interfaces__srv__AddTwoInts_Request req;
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){while(1){};}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}}
void service_callback(const void * req, void * res){
example_interfaces__srv__AddTwoInts_Request * req_in = (example_interfaces__srv__AddTwoInts_Request *) req;
example_interfaces__srv__AddTwoInts_Response * res_in = (example_interfaces__srv__AddTwoInts_Response *) res;
//printf("Service request value: %d + %d.\n", (int) req_in->a, (int) req_in->b);
res_in->sum = req_in->a + req_in->b;
}
void setup() {
set_microros_transports();
delay(1000);
allocator = rcl_get_default_allocator();
// create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
RCCHECK(rclc_node_init_default(&node, "add_twoints_client_rclc", "", &support));
// create service
RCCHECK(rclc_service_init_default(&service, &node, ROSIDL_GET_SRV_TYPE_SUPPORT(example_interfaces, srv, AddTwoInts), "/addtwoints"));
// create executor
RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator));
RCCHECK(rclc_executor_add_service(&executor, &service, &req, &res, service_callback));
}
void loop() {
delay(100);
RCSOFTCHECK(rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)));
}
And also my platformio.ini
platform = teensy
board = teensy41
framework = arduino
board_microros_transport = serial
lib_deps =
https://github.com/micro-ROS/micro_ros_platformio
Here is a screenshot from the include error. I believe it is a path not set-up right:
The package is installed:
administrator@dev01:~/ros2_ws/src$ ros2 pkg list | grep interf
action_tutorials_interfaces
ament_cmake_export_interfaces
builtin_interfaces
common_interfaces
composition_interfaces
example_interfaces
rcl_interfaces
rcl_logging_interface
ros2interface
rosbag2_interfaces
rosidl_typesupport_interface
test_interface_files
Any help will be greatly appreciated and I promise to merge any success back into the original repository, so others can also benefit from this.
Asked by PointCloud on 2022-10-07 15:07:45 UTC
Answers
Answers here: https://github.com/micro-ROS/micro_ros_platformio/issues/68 I guess...
Please do not duplicate this in Github + Answers + ROS discourse. GitHub is enough for technical issues. If you need to ping us, the micro-ROS maintainer's mails are public and we have a Slack community that you can find here: https://micro.ros.org/
Asked by Pablogs on 2022-10-10 00:52:33 UTC
Comments
This question may be related to #q407573 and #q407572
Asked by ravijoshi on 2022-10-07 22:35:44 UTC