eProsima / Micro-XRCE-DDS-Client

Micro XRCE-DDS Client repository. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
130 stars 82 forks source link

Field has incomplete type with UDP transport #268

Closed coalman321 closed 2 years ago

coalman321 commented 2 years ago

Hi, I am trying to compile this library as part of micro-ros, but have run into an issue during the build process. The target board is armhf with some custom compiler configurations that I am not entirely aware of. I do also know it is older than the mainline version of GCC by at least 2 years.

Currently the build fails with the error

In file included from /home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/transport.h:30:0,
                 from /home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/util/ping.h:28,
                 from /home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/util/ping.c:1:
/home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/profile/transport/ip/udp/udp_transport.h:37:27: error: field 'platform' has incomplete type
     struct uxrUDPPlatform platform;
                           ^~~~~~~~
make[2]: *** [CMakeFiles/microxrcedds_client.dir/build.make:261: CMakeFiles/microxrcedds_client.dir/src/c/util/ping.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport_internal.h:23:0,
                 from /home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport.c:2:
/home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/profile/transport/ip/udp/udp_transport.h:37:27: error: field 'platform' has incomplete type
     struct uxrUDPPlatform platform;
                           ^~~~~~~~
/home/coalman321/code/micro_ros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/ip/udp/udp_transport.c: In function 'uxr_close_udp_transport':

Any help in fixing this would be greatly appreciated.

pablogs9 commented 2 years ago

You are not configuring the library well, could you share your colcon.meta or the CMake args that you are using? Also, detail the transport that you want to use to communicate client with the agent.

coalman321 commented 2 years ago

colcon.meta : https://gist.github.com/coalman321/302fa34fa7ca37d07bfce5f21e27490a toolchain.cmake : https://gist.github.com/coalman321/c568b9d817791a531f2eb09c110a415f The desired transport is UDP and or TCP to the agent. The system is running a soft realtime linux kernel from National Instruments

pablogs9 commented 2 years ago

Disable UDP profile in the Micro XRCE-DDS Client configuration if you don't want POSIX UDP support: https://gist.github.com/coalman321/302fa34fa7ca37d07bfce5f21e27490a#file-colcon-meta-L33

coalman321 commented 2 years ago

If I set that to off, it does compile, but then that would leave the udp network stack configuration up to me correct? I would like to stick with the posix version if possible. Am I missing some kind of tool chain flag to enable this? Or is an armv7 Linux kernel running the real-time scheduler not posix compliant?

coalman321 commented 2 years ago

As a side note, I tested the same colcon.meta file with the custom transport and stream framing off. Changing either option cause no change in build error.

pablogs9 commented 2 years ago

On which platform are you using micro-ROS?

coalman321 commented 2 years ago

The platform is not an officially supported one from the list. I am attempting to build a static library for a Xilinx armv7 board with an integrated FPGA. The device is called the Roborio and it is produced by National Instruments (NI). It is running a 4.x Linux kernel with the real-time scheduler patch enabled. (I’ll add the output of uname -a when I can access the board later today) It is unable to run a fully fledged version of ros2 due to only having 256 Mb of ram, but it does make a very powerful platform for micro ros to run on.

coalman321 commented 2 years ago

uname -a output: Linux roboRIO-4145-FRC 4.14.87-rt49-cg-7.0.0f0-xilinx-zynq-189 #1 SMP PREEMPT RT Fri Mar 15 19:11:24 UTC 2019 armv7l GNU/Linux g++ -v output:

Using built-in specs.
COLLECT_GCC=./arm-frc2021-linux-gnueabi-g++
COLLECT_LTO_WRAPPER=/home/coalman321/code/micro_ros_ws/roborio_toolchain/bin/../libexec/gcc/arm-frc2021-linux-gnueabi/7.3.0/lto-wrapper
Target: arm-frc2021-linux-gnueabi
Configured with: ../gcc-7.3.0/configure --enable-threads=posix --target=arm-frc2021-linux-gnueabi --with-cpu=cortex-a9 --with-float=softfp --with-fpu=vfpv3 --with-specs='%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' --enable-languages=c,c++,fortran --enable-shared --enable-lto --disable-nls --with-pkgversion='GCC for FRC 2021' --with-cloog --disable-multilib --disable-multiarch --prefix=/usr/local --with-sysroot=/usr/local/arm-frc2021-linux-gnueabi --enable-poison-system-directories --disable-libmudflap --with-build-sysroot=/usr/local/arm-frc2021-linux-gnueabi --libdir=/usr/local/arm-frc2021-linux-gnueabi/usr/lib --with-gxx-include-dir=/usr/local/arm-frc2021-linux-gnueabi/usr/include/c++/7.3.0 --with-system-zlib
Thread model: posix
gcc version 7.3.0 (GCC for FRC 2021) 

gcc -v output:

Using built-in specs.
COLLECT_GCC=./arm-frc2021-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/home/coalman321/code/micro_ros_ws/roborio_toolchain/bin/../libexec/gcc/arm-frc2021-linux-gnueabi/7.3.0/lto-wrapper
Target: arm-frc2021-linux-gnueabi
Configured with: ../gcc-7.3.0/configure --enable-threads=posix --target=arm-frc2021-linux-gnueabi --with-cpu=cortex-a9 --with-float=softfp --with-fpu=vfpv3 --with-specs='%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' --enable-languages=c,c++,fortran --enable-shared --enable-lto --disable-nls --with-pkgversion='GCC for FRC 2021' --with-cloog --disable-multilib --disable-multiarch --prefix=/usr/local --with-sysroot=/usr/local/arm-frc2021-linux-gnueabi --enable-poison-system-directories --disable-libmudflap --with-build-sysroot=/usr/local/arm-frc2021-linux-gnueabi --libdir=/usr/local/arm-frc2021-linux-gnueabi/usr/lib --with-gxx-include-dir=/usr/local/arm-frc2021-linux-gnueabi/usr/include/c++/7.3.0 --with-system-zlib
Thread model: posix
gcc version 7.3.0 (GCC for FRC 2021) 
pablogs9 commented 2 years ago

In this case, reenable the UDP flag (UCLIENT_PROFILE_UDP) and make sure that the CMake in the XRCE-DDS Client is setting this flag and this is being included.

coalman321 commented 2 years ago

How should I check those second two? I am not overly familliar with cmake and the uRos build system and hot to get set variables and flags out. Though, I think I can manually force them with the toolchain file, but I am not sure if that would be desirable in this instance.

pablogs9 commented 2 years ago

Yes, setting them in the toolchain should be ok.

coalman321 commented 2 years ago

Thank you very much. Those two settings did the trick. The client now compiles successfully! They should definitely be documented somewhere though, as it was unclear what needed to be set / changed from the documentation I read.