micro-ROS / micro_ros_setup

Support macros for building micro-ROS-based firmware.
Apache License 2.0
365 stars 133 forks source link

Compilation errors in Dashing version #25

Closed KevinHwangAi closed 4 years ago

KevinHwangAi commented 4 years ago

I have installed the dashing version of micro-ros-build. After configuring the MCU (tools/configure.sh configs/olimex-stm32-e407/drive_base) and enter the build_firmware command (ros2 run micro_ros_setup build_firmware.sh) , I got the following error :

kevin@kevin:~/uros_ws$` ros2 run micro_ros_setup build_firmware.sh Starting >>> ament_package Starting >>> ament_lint Starting >>> ament_cppcheck Starting >>> gtest_vendor Starting >>> ament_pep8 Finished <<< ament_package [1.13s]
Finished <<< ament_lint [1.13s] Starting >>> ament_cmake_core
Starting >>> ament_flake8 Finished <<< ament_cppcheck [1.45s] Finished <<< ament_pep8 [1.80s]
Starting >>> ament_pyflakes Finished <<< ament_flake8 [0.80s]
Finished <<< gtest_vendor [2.24s] Starting >>> ament_pep257 Starting >>> gmock_vendor Finished <<< ament_pyflakes [0.77s]
Finished <<< ament_cmake_core [1.18s] Starting >>> ament_cmake_test Starting >>> ament_cmake_libraries Starting >>> ament_cmake_export_libraries Starting >>> ament_cmake_include_directories Starting >>> ament_cmake_export_definitions Starting >>> ament_cmake_export_include_directories Starting >>> ament_cmake_export_link_flags Starting >>> ament_cmake_python Finished <<< gmock_vendor [0.64s]
Finished <<< ament_cmake_test [0.39s]
Starting >>> ament_cmake_gtest Starting >>> ament_lint_auto Starting >>> ament_cmake_nose Starting >>> ament_cmake_pytest
Finished <<< ament_cmake_libraries [0.55s] Finished <<< ament_cmake_export_definitions [0.56s]
Finished <<< ament_cmake_include_directories [0.57s] Finished <<< ament_cmake_export_libraries [0.58s] Finished <<< ament_cmake_export_include_directories [0.56s] Starting >>> ament_cmake_export_dependencies Starting >>> ament_cmake_export_interfaces Starting >>> ament_cmake_target_dependencies Finished <<< ament_cmake_export_link_flags [0.56s] Finished <<< ament_cmake_python [0.55s] Finished <<< ament_pep257 [0.98s] Starting >>> ament_copyright Starting >>> ament_index_python Finished <<< ament_copyright [0.96s]
Starting >>> ament_lint_cmake Starting >>> ament_cpplint Starting >>> ament_xmllint
Starting >>> ament_clang_format Starting >>> ament_clang_tidy
Starting >>> ament_pclint Finished <<< ament_cmake_gtest [1.32s] Finished <<< ament_lint_auto [1.32s] Finished <<< ament_cmake_nose [1.24s] Finished <<< ament_cmake_pytest [1.22s] Finished <<< ament_cmake_export_dependencies [1.11s] Finished <<< ament_cmake_target_dependencies [1.11s] Finished <<< ament_cmake_export_interfaces [1.11s] Starting >>> ament_cmake Starting >>> ament_cmake_gmock Finished <<< ament_index_python [3.28s]
Finished <<< ament_lint_cmake [2.32s] Finished <<< ament_xmllint [2.28s] Finished <<< ament_cpplint [2.34s]
Finished <<< ament_clang_format [2.23s] Starting >>> ament_cmake_lint_cmake Finished <<< ament_clang_tidy [2.22s] Finished <<< ament_cmake [2.37s]
Starting >>> uncrustify_vendor Starting >>> ament_cmake_auto Finished <<< ament_cmake_gmock [2.43s]
Finished <<< ament_cmake_lint_cmake [0.27s] Starting >>> ament_cmake_copyright Finished <<< ament_pclint [2.49s] Finished <<< uncrustify_vendor [0.33s]
Starting >>> ament_uncrustify Finished <<< ament_cmake_copyright [0.24s] Finished <<< ament_cmake_auto [0.34s] Starting >>> ament_cmake_cppcheck Starting >>> ament_cmake_cpplint Starting >>> ament_cmake_flake8 Starting >>> ament_cmake_pep257 Starting >>> ament_cmake_xmllint Starting >>> ament_cmake_clang_format Starting >>> ament_cmake_clang_tidy Starting >>> ament_cmake_pclint Starting >>> ament_cmake_pep8 Starting >>> ament_cmake_pyflakes
Finished <<< ament_cmake_cppcheck [0.78s]
Finished <<< ament_cmake_cpplint [0.83s]
Finished <<< ament_cmake_pep257 [0.86s] Finished <<< ament_cmake_flake8 [0.88s]
Finished <<< ament_cmake_xmllint [0.87s] Finished <<< ament_cmake_clang_format [0.86s] Finished <<< ament_cmake_clang_tidy [0.85s] Finished <<< ament_cmake_pclint [0.84s] Finished <<< ament_cmake_pep8 [0.83s] Finished <<< ament_cmake_pyflakes [0.82s] Finished <<< ament_uncrustify [1.00s] Starting >>> ament_cmake_uncrustify Finished <<< ament_cmake_uncrustify [0.26s]
Starting >>> ament_lint_common Finished <<< ament_lint_common [0.31s]
Starting >>> ament_cmake_ros Starting >>> ament_index_cpp Finished <<< ament_cmake_ros [0.32s]
Finished <<< ament_index_cpp [0.63s]

Summary: 54 packages finished [9.69s] make[1]: Entering directory '/home/kevin/uros_ws/firmware/NuttX/tools' make[1]: Leaving directory '/home/kevin/uros_ws/firmware/NuttX/tools' make[1]: Entering directory '/home/kevin/uros_ws/firmware/NuttX/tools' make[1]: Leaving directory '/home/kevin/uros_ws/firmware/NuttX/tools' LN: include/arch to arch/arm/include LN: include/arch/board to /home/kevin/uros_ws/firmware/NuttX/configs/olimex-stm32-e407/include LN: include/arch/chip to arch/arm/include/stm32 LN: arch/arm/src/board to /home/kevin/uros_ws/firmware/NuttX/configs/olimex-stm32-e407/src LN: arch/arm/src/chip to arch/arm/src/stm32 make[1]: Entering directory '/home/kevin/uros_ws/firmware/NuttX/configs' make[1]: Leaving directory '/home/kevin/uros_ws/firmware/NuttX/configs' make[1]: Entering directory '/home/kevin/uros_ws/firmware/apps' make[2]: Entering directory '/home/kevin/uros_ws/firmware/apps/platform' LN: platform/board to /home/kevin/uros_ws/firmware/apps/platform/dummy make[2]: Leaving directory '/home/kevin/uros_ws/firmware/apps/platform' make[1]: Leaving directory '/home/kevin/uros_ws/firmware/apps' make[1]: Entering directory '/home/kevin/uros_ws/firmware/NuttX/configs' make[2]: Entering directory '/home/kevin/uros_ws/firmware/NuttX/configs/olimex-stm32-e407/src' make[2]: Nothing to be done for 'context'. make[2]: Leaving directory '/home/kevin/uros_ws/firmware/NuttX/configs/olimex-stm32-e407/src' make[1]: Leaving directory '/home/kevin/uros_ws/firmware/NuttX/configs' make[1]: Entering directory '/home/kevin/uros_ws/firmware/apps' make[2]: Entering directory '/home/kevin/uros_ws/firmware/apps/builtin' make[3]: Entering directory '/home/kevin/uros_ws/firmware/apps/builtin/registry' make[3]: Leaving directory '/home/kevin/uros_ws/firmware/apps/builtin/registry' make[2]: Leaving directory '/home/kevin/uros_ws/firmware/apps/builtin' make[2]: Entering directory '/home/kevin/uros_ws/firmware/apps' make[3]: Entering directory '/home/kevin/uros_ws/firmware/apps/uros' cat arm_toolchain.cmake.in | \ sed "s/@CROSSDEV@/arm-none-eabi-/g" | \ sed "s/@NUTTX_TOPDIR@/\/home\/kevin\/uros_ws\/firmware\/NuttX/g" |\ sed "s/@ARCH_CPU_FLAGS@/\"-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard\"/g" |\ sed "s/@ARCH_OPT_FLAGS@/\"-g -Os -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer\"/g" \

arm_toolchain.cmake Starting >>> rosidl_adapter Starting >>> rosidl_typesupport_interface Starting >>> microcdr Starting >>> rcutils Starting >>> microxrcedds_cmake_module Starting >>> rmw_implementation_cmake Starting >>> libyaml_vendor Finished <<< rosidl_typesupport_interface [0.91s]
Finished <<< rmw_implementation_cmake [0.89s] Finished <<< rosidl_adapter [1.04s]
Starting >>> rosidl_parser Finished <<< rosidl_parser [0.97s]
Starting >>> rosidl_cmake Finished <<< microcdr [2.32s]
Starting >>> microxrcedds_client Finished <<< microxrcedds_cmake_module [2.35s] --- stderr: rcutils

_**CMake Warning: Manually-specified variables were not used by the project:

ENABLE_TESTING

In file included from /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/include/rcutils/error_handling.h:28:0, from /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/error_handling.c:22: /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/error_handling.c: In function '__format_overwriting_error_state_message': /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/error_handling.c:95:20: warning: comparison is always true due to limited range of data type [-Wtype-limits] assert(INT64_MAX > buffer_size);

/home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/process.c: In function 'rcutils_get_executable_name': /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/process.c:53:26: error: 'program_invocation_name' undeclared (first use in this function) const char * appname = program_invocation_name; ^~~~~~~ /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/process.c:53:26: note: each undeclared identifier is reported only once for each function it appears in make[6]: [CMakeFiles/rcutils.dir/src/process.c.obj] Error 1 make[6]: Waiting for unfinished jobs.... /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/time_unix.c: In function 'rcutils_system_time_now': /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/time_unix.c:46:59: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

define __WOULD_BE_NEGATIVE(seconds, subseconds) (seconds < 0 || (subseconds < 0 && seconds == 0))

/home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/time_unix.c:66:7: note: in expansion of macro 'WOULD_BE_NEGATIVE' if (WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) { ^~~~~~~ /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/time_unix.c: In function 'rcutils_steady_time_now': /home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/time_unix.c:46:59: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

define __WOULD_BE_NEGATIVE(seconds, subseconds) (seconds < 0 || (subseconds < 0 && seconds == 0))

/home/kevin/uros_ws/firmware/mcu_ws/ros2/rcutils/src/time_unix.c:97:7: note: in expansion of macro 'WOULD_BE_NEGATIVE' if (WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) { ^~~~~~~ make[5]: [CMakeFiles/rcutils.dir/all] Error 2 make[4]: [all] Error 2

Failed <<< rcutils [ Exited with code 2 ] Aborted <<< rosidl_cmake
Aborted <<< microxrcedds_client
--- stderr: libyaml_vendor
CMake Warning (dev) at CMakeLists.txt:55 (add_library): ADD_LIBRARY called with SHARED option but the target platform does not support dynamic linking. Building a STATIC library instead. This may lead to problems. This warning is for project developers. Use -Wno-dev to suppress it.

Aborted <<< libyaml_vendor Summary: 6 packages finished [12.3s] 1 package failed: rcutils 3 packages aborted: libyaml_vendor microxrcedds_client rosidl_cmake 2 packages had stderr output: libyaml_vendor rcutils 37 packages not processed Makefile:31: recipe for target 'colcon_compile' failed make[3]: [colcon_compile] Error 2 make[3]: Leaving directory '/home/kevin/uros_ws/firmware/apps/uros' Makefile:106: recipe for target 'uros_context' failed make[2]: [uros_context] Error 2 make[2]: Leaving directory '/home/kevin/uros_ws/firmware/apps' Makefile:179: recipe for target 'context_serialize' failed make[1]: [context_serialize] Error 2 make[1]: Leaving directory '/home/kevin/uros_ws/firmware/apps' tools/Makefile.unix:345: recipe for target 'context' failed make: [context] Error 2**

BorjaOuterelo commented 4 years ago

Hi, @KevinHwangAi I will have a look at it and come back to you. Thanks for reporting.

KevinHwangAi commented 4 years ago

I found that in this file: micro-ros-build/micro_ros_setup/config/uros_packages.repos , the version of apps is still crystal :

repositories: NuttX: type: git url: https://github.com/micro-ROS/NuttX.git version: drive_base apps: type: git url: https://github.com/micro-ROS/apps.git version: crystal uclibc: type: git url: https://github.com/micro-ROS/uclibc.git version: master

Does this cause compilation errors?

BorjaOuterelo commented 4 years ago

Those need to be updated to support Dashing...

KevinHwangAi commented 4 years ago

@BorjaOuterelo Is that mean it still need to wait for the apps to be updated to Dashing ?

iluetkeb commented 4 years ago

We haven't released the dashing version, yet, but we're working on it. That's why there are "dashing" branches in the repos.

See https://micro-ros.github.io//docs/tutorials/basic/getting_started/ for the current status. Dashing is still "TODO"...

KevinHwangAi commented 4 years ago

@iluetkeb Thank you for your efforts. Because of the Dashing version of Ros2 used in our robotics project, we very much hope to use Mirco_Ros in MCU communications.

Could you tell me when the Dashing version will be updated?

iluetkeb commented 4 years ago

I can't really say, there are several people, and I don't know their time-frame. On my side, I'm a bit busy with ROSCon preparations and some other things.

That said, you can compile the firmware using ROS 2 Crystal, and it can communicate with an agent running on ROS 2 Dashing. I think the agent is a bit further ahead than the rest, so this might be a faster solution.

KevinHwangAi commented 4 years ago

@iluetkeb That sounds like a very good proposal !!!

KevinHwangAi commented 4 years ago

Hi @iluetkeb ,I try run the agent in the ROS2 Dashing and compile the firmware with Crystal as what you said. And now, In the NSH input 'publisher', I got this error:

publisher modified publisher Serial mode => dev: /dev/ttyS0

[rcutils|error_handling.c:106] rcutils_set_error_state() This error state is being overwritten:

'failed to create node session on Micro ROS Agent., at /home/gemini/uros_ws/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/src/rmw_nod'

with this new error message:

'rcl node's rmw handle is invalid, at /home/gemini/uros_ws/firmware/mcu_ws/ros2/rcl/rcl/src/rcl/node.c:535'

rcutils_reset_error() should be called after error handling to avoid this. <<< [ERROR] [rcl]: Failed to fini publisher for node: 1 [rclc_create_node] error in rcl_node_init: rcl node's rmw handle is invalid, at /home/gemini/uros_ws/firmware/mcu_ws/ros2/rcl/rcl/src/rcl/node.c:55 Issues creating node

############################################################# And the micro_ros_agent information is like this:

kevin@kevin:~$ ~/uros_ws/install/micro_ros_agent/lib/micro_ros_agent/micro_ros_agent serial /dev/ttyUSB0 --dev is required Run with --help for more information.

Enter command: serial --dev /dev/ttyUSB0 Enter 'q' for exit [1570718795.285436] info | SerialServerLinux.cpp | init | running... | fd: 3 [1570718820.645029] info | Root.cpp | create_client | invalid cookie | client_key: 0x0100010F [1570718820.648884] info | Root.cpp | create_client | invalid cookie | client_key: 0x0100010F [1570718820.653858] info | Root.cpp | create_client | invalid cookie | client_key: 0x0100010F [1570718820.655847] info | Root.cpp | create_client | invalid cookie | client_key: 0x0100010F [1570718820.659915] info | Root.cpp | create_client | invalid cookie | client_key: 0x0100010F [1570718820.662844] info | Root.cpp | create_client | invalid cookie | client_key: 0x0100010F [1570718820.666802] info | Root.cpp | create_client | invalid cookie | client_key: 0x0100010F

Could you tell me where the problem is?

iluetkeb commented 4 years ago

@BorjaOuterelo you have any idea?

KevinHwangAi commented 4 years ago

Hi @iluetkeb @BorjaOuterelo, I thing I have solved the problem.
The MCU(Crtstal) can run the publisher now, and the agent(Dashing) got this :

kevin@kevin:~$ ~/uros_ws/install/micro_ros_agent/lib/micro_ros_agent/micro_ros_agent serial --dev /dev/ttyUSB0 Enter 'q' for exit [1570771546.421357] info | SerialServerLinux.cpp | init | running... | fd: 3 [1570771560.434907] info | Root.cpp | create_client | create | client_key: 0x75E1799B, session_id: 0x81 [1570771560.434983] info | SerialServerBase.cpp | on_create_client | session established | client_key: 0x75E1799B, address: 1

iluetkeb commented 4 years ago

@KevinHwangAi what did you do to fix the issue? I have not encountered the "invalid cookie" problem before -- it would be good to know what to do to fix it.

KevinHwangAi commented 4 years ago

@iluetkeb The problem seems to come from the different definitions of "xrce_cookie" in xrce_protocol_internal.h between Crystal and Dashing. The file path: mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/core/serialization/xrce_protocol_internal.h

Crystal: typedef struct XrceCookie { uint8_t data[4];

} XrceCookie;

define XRCE_COOKIE (XrceCookie){{0x58, 0x52, 0x43, 0x45}}

typedef struct XrceVersion { uint8_t data[2];

} XrceVersion;

define XRCE_VERSION_MAJOR 0x01

define XRCE_VERSION_MINOR 0x00

define XRCE_VERSION (XrceVersion){{XRCE_VERSION_MAJOR, XRCE_VERSION_MINOR}}

Dashing: typedef struct XrceCookie { uint8_t data[4];

} XrceCookie;

define XRCE_COOKIE COMPOUND_LITERAL(XrceCookie){{0x58, 0x52, 0x43, 0x45}}

typedef struct XrceVersion { uint8_t data[2];

} XrceVersion;

define XRCE_VERSION_MAJOR 0x01

define XRCE_VERSION_MINOR 0x00

define XRCE_VERSION COMPOUND_LITERAL(XrceVersion){{XRCE_VERSION_MAJOR, XRCE_VERSION_MINOR}}

In the Dashing, it use the COMPOUND_LITERAL for XrceCookie's Macro definition.

iluetkeb commented 4 years ago

@KevinHwangAi If this issue has been resolved successfully for you, please close it.