Gremsy / PayloadSdk

GNU General Public License v3.0
3 stars 5 forks source link

Problem with include paths #27

Open soaring-filip opened 1 month ago

soaring-filip commented 1 month ago

Hi, I've been having trouble including the payloadSdInterface into a ROS project. Here's the error output during build.

In file included from /root/ros2_ws/src/gremsy-interface/include/PayloadSdk/libs/payloadSdkInterface.h:5,
                 from /root/ros2_ws/src/gremsy-interface/src/gremsy_camera_sdk_wrapper.cpp:10:
/root/ros2_ws/src/gremsy-interface/include/PayloadSdk/libs/payloadsdk.h:5:10: fatal error: common/mavlink.h: No such file or directory
    5 | #include <common/mavlink.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/gremsy_node.dir/build.make:76: CMakeFiles/gremsy_node.dir/src/gremsy_camera_sdk_wrapper.cpp.o] Error 1

I added this to my CMakeLists.txt add_subdirectory(include/PayloadSdk) The error is surprinsing because all files are there and cmake . && make in the sdk repo work just fine.

My mavsdk is installed through

wget -q https://github.com/mavlink/MAVSDK/releases/download/v2.12.10/libmavsdk-dev_2.12.10_ubuntu20.04_amd64.deb \
    && dpkg -i libmavsdk-dev_2.12.10_ubuntu20.04_amd64.deb \
    && rm libmavsdk-dev_2.12.10_ubuntu20.04_amd64.deb

I'd welcome ideas on how to approach this, thanks. Filip

soaring-filip commented 1 month ago

I got lucky and guessed this workaround

set(GREMSY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/PayloadSdk)

add_subdirectory(${GREMSY_DIR})
target_include_directories(gremsy_node PUBLIC
  # $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  # $<INSTALL_INTERFACE:include>

  ${GREMSY_DIR}/libs/mavlinkInterface/libs/inc/mavlink/v2.0
  ${GREMSY_DIR}/libs/third-party/mavlink/include
)
target_link_libraries(gremsy_node 
  ${GREMSY_DIR}/libs/libPayloadSDK.a
)

Can you please post a better solution if you have one? I want the major build (my cmake file) to build the libPayloadSdk.a as well, without having to do cmake . && make from the package itself and that's still missing.

penguin-dang commented 4 weeks ago

PayloadSDK repository has CMakeLists to build it into libPayloadSDK.a. You can easily integrate PayloadSDK into your ROS workspace by add 2 below lines to /root/ros2_ws/src/gremsy-interface/CMakeLists.txt set(PAYLOADSDKLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/PayloadSdk/libs) include_directories(${PAYLOADSDKLIB_DIR})

soaring-filip commented 3 weeks ago

The simply directory include throws issues with mavlinks on my end

gremsy-interface/include/GremsyPayloadSdk/libs/payloadsdk.h:5:10: fatal error: common/mavlink.h: No such file or directory
    5 | #include <common/mavlink.h>

Also, I already had this added: include_directories(include) and the payloadsdk is in the include folder, is there another config I'm missing?