From 2f4fc8fde3883eca67c7d377bc0df737c3bea354 Mon Sep 17 00:00:00 2001 From: KiselevIlia Date: Fri, 29 Mar 2024 22:45:34 +0400 Subject: [PATCH] Auto download messages lib --- CMakeLists.txt | 20 ++++++++++++++------ include/groundtruth_plugin.h | 2 +- include/harmonic_collision.h | 2 +- src/groundtruth_plugin.cpp | 2 +- src/harmonic_collision.cpp | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2563c9..f9c403c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,10 +27,17 @@ if(NOT ${gz-transport13_VERSION} EQUAL 13.1.0) message(FATAL_ERROR "gz-transport13 must be version 13.1.0. You have ${gz-transport13_VERSION}") endif () -find_library(GZ_CUSTOM_MSGS NAMES gz_custom_messages PATHS /usr/local/bin) -if (NOT GZ_CUSTOM_MSGS) - message(FATAL_ERROR "Please install messages library from https://github.com/tiiuae/TASFMessages") -endif () +include(FetchContent) +message(STATUS "Download TASFMessages library") + +FetchContent_Declare( + TASFMessages + GIT_REPOSITORY "git@github.com:tiiuae/TASFMessages.git" + GIT_TAG main + SOURCE_DIR ${CMAKE_SOURCE_DIR}/dependency/TASFMessages +) +FetchContent_Populate(TASFMessages) +add_subdirectory(${tasfmessages_SOURCE_DIR}) if(gz-msgs10_FOUND) set(GZ_MSG_VER 10) @@ -50,6 +57,7 @@ include_directories(${CMAKE_BINARY_DIR}) include_directories( include ${Boost_INCLUDE_DIR} + ${tasfmessages_BINARY_DIR} # ${MAVLINK_INCLUDE_DIRS} ) @@ -75,11 +83,11 @@ add_library(collision_plugin SHARED src/harmonic_collision.cpp) set_property(TARGET collision_plugin PROPERTY CXX_STANDARD 17) target_link_libraries(collision_plugin PRIVATE gz-sim${GAZEBO_VERSION}::gz-sim${GAZEBO_VERSION} - PRIVATE ${GZ_CUSTOM_MSGS} + PRIVATE gz_custom_messages ) add_library(groundtruth_plugin SHARED src/groundtruth_plugin.cpp) target_link_libraries(groundtruth_plugin PRIVATE gz-sim${GAZEBO_VERSION}::gz-sim${GAZEBO_VERSION} - PRIVATE ${GZ_CUSTOM_MSGS} + PRIVATE gz_custom_messages ) \ No newline at end of file diff --git a/include/groundtruth_plugin.h b/include/groundtruth_plugin.h index 758cb07..b8f0dfe 100644 --- a/include/groundtruth_plugin.h +++ b/include/groundtruth_plugin.h @@ -7,7 +7,7 @@ #include #include #include "common.h" -#include "gz_custom_messages/Groundtruth.pb.h" +#include "Groundtruth.pb.h" namespace gz { namespace sim { diff --git a/include/harmonic_collision.h b/include/harmonic_collision.h index 62efc4d..7c2df37 100644 --- a/include/harmonic_collision.h +++ b/include/harmonic_collision.h @@ -5,7 +5,7 @@ #include #include -#include "gz_custom_messages/CollisionObject.pb.h" +#include "CollisionObject.pb.h" namespace gz { using namespace sim; diff --git a/src/groundtruth_plugin.cpp b/src/groundtruth_plugin.cpp index 7395f4a..1f2cea6 100644 --- a/src/groundtruth_plugin.cpp +++ b/src/groundtruth_plugin.cpp @@ -190,7 +190,7 @@ GZ_ADD_PLUGIN(GroundtruthPlugin, GroundtruthPlugin::ISystemPostUpdate) GZ_ADD_PLUGIN_ALIAS(GroundtruthPlugin, - "gz::sim::systems::GroundtruthPlugin") + "gz::GroundtruthPlugin") bool GroundtruthPlugin::responseCallback(const gz::msgs::StringMsg &, gz::msgs::Groundtruth &rep) { diff --git a/src/harmonic_collision.cpp b/src/harmonic_collision.cpp index 1de8d4b..6dbbd67 100644 --- a/src/harmonic_collision.cpp +++ b/src/harmonic_collision.cpp @@ -31,7 +31,7 @@ void CollisionPlugin::Load(const EntityComponentManager &_ecm, } } - if (_sdf->HasElement("updateRate")) { ; + if (_sdf->HasElement("updateRate")) { publish_rate_ = _sdf->GetElement("updateRate")->Get(); gzmsg << "Publish rate set to " << publish_rate_ << std::endl; }