最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ros2 - CMake Error: "JsonCpp::JsonCpp" Target Already Exists and ignition_add_plugin Not Found in Gazebo Fortr

programmeradmin0浏览0评论

I'm trying to make a custom plugin work in both Gazebo Classic and Gazebo Fortress. To test it, I'm loading my plugin into a simple SDF file.

I'm running the following command:

ign gazebo file.sdf

but i get this:

Library [/usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/libHuNavPlugin.so] does not export any plugins. The symbol [IgnitionPluginHook] is missing, or it is not externally visible.
libEGL warning: egl: failed to create dri2 screen
libEGL warning: egl: failed to create dri2 screen

After some research, I found that my CMakeLists.txt was missing these lines:Then, I ran:

find_package(ignition-cmake2 REQUIRED)
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
find_package(ignition-common4 REQUIRED COMPONENTS profiler)
set(GZ_COMMON_VER ${ignition-common4_VERSION_MAJOR})
find_package(ignition-gazebo6 REQUIRED)

ignition_add_plugin(HuNavPlugin
  SOURCES your_plugin_source.cpp
  INCLUDE_DIRS ${IGNITION-GAZEBO_INCLUDE_DIRS}
  LINK_LIBRARIES ${IGNITION-GAZEBO_LIBRARIES}
)

then i ran:

colcon build --symlink-install

But now I get this error:

upo@upo-Stealth-15M-A11SEK:~/hunavsim$ colcon build  --symlink-install 
Starting >>> hunav_msgs
Starting >>> people_msgs
Finished <<< people_msgs [0.46s]                                                                
Finished <<< hunav_msgs [0.51s]                  
Starting >>> hunav_agent_manager
Starting >>> hunav_evaluator
Starting >>> hunav_rviz2_panel
Starting >>> hunav_gazebo_wrapper
Finished <<< hunav_agent_manager [0.26s]                                                                                                              
Finished <<< hunav_rviz2_panel [0.35s]                                                                                             
Finished <<< hunav_evaluator [0.99s]                                                          
Starting >>> hunav_sim
Finished <<< hunav_sim [0.07s]
--- stderr: hunav_gazebo_wrapper                         
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/jsoncpp/jsoncpp-namespaced-targets.cmake:5 (add_library):
  add_library cannot create imported target "JsonCpp::JsonCpp" because
  another target with the same name already exists.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/jsoncpp/jsoncppConfig.cmake:41 (include)
  /usr/share/cmake/ignition-cmake2/cmake2/FindJSONCPP.cmake:34 (find_package)
  /usr/lib/x86_64-linux-gnu/cmake/ignition-fuel_tools7/ignition-fuel_tools7-config.cmake:94 (find_package)
  /usr/lib/x86_64-linux-gnu/cmake/ignition-gazebo6/ignition-gazebo6-config.cmake:97 (find_package)
  CMakeLists.txt:39 (find_package)


CMake Error at CMakeLists.txt:59 (ignition_add_plugin):
  Unknown CMake command "ignition_add_plugin".


gmake: *** [Makefile:308: cmake_check_build_system] Error 1
---
Failed   <<< hunav_gazebo_wrapper [1.58s, exited with code 2]
                                
Summary: 6 packages finished [2.39s]
  1 package failed: hunav_gazebo_wrapper
  1 package had stderr output: hunav_gazebo_wrapper

It seems there is a conflict with JsonCpp::JsonCpp, as it's being defined twice. Additionally, ignition_add_plugin is not recognized.

i tried adding one by one and the error is at:

find_package(ignition-gazebo6 REQUIRED).

I've tried different approaches, But nothing seems to solve the issue.

Does anyone know what’s going on or how to properly handle this conflict? Any help would be greatly appreciated!

this works properly with a launch file on gazebo classic, the problem is just when trying to use gazebo fortress.

here is my cmakelist.txt

cmake_minimum_required(VERSION 3.8)
project(hunav_gazebo_wrapper)

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()



find_package(ament_cmake REQUIRED)
find_package(tinyxml2_vendor REQUIRED)
find_package(TinyXML2 REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(rclcpp REQUIRED)
find_package(gazebo_ros REQUIRED)   
#find_package(Boost REQUIRED COMPONENTS thread)
find_package(gazebo REQUIRED)
find_package(hunav_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)

find_package(ignition-cmake2 REQUIRED)
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
find_package(ignition-common4 REQUIRED COMPONENTS profiler)
set(GZ_COMMON_VER ${ignition-common4_VERSION_MAJOR})
find_package(ignition-gazebo6 REQUIRED)


include_directories(include)
include_directories(SYSTEM
  #${Boost_INCLUDE_DIRS}
  ${GAZEBO_INCLUDE_DIRS}
  ${TINYXML2_INCLUDE_DIR}
)

link_directories(
  ${GAZEBO_LIBRARY_DIRS}
  ${TINYXML2_LIBRARY_DIRS}
  #${TINYXML2_LIBRARY_PATH}
)

ignition_add_plugin(HuNavPlugin
  SOURCES your_plugin_source.cpp
  INCLUDE_DIRS ${IGNITION-GAZEBO_INCLUDE_DIRS}
  LINK_LIBRARIES ${IGNITION-GAZEBO_LIBRARIES}
)

add_library(HuNavPlugin SHARED src/HuNavPlugin.cpp)
target_include_directories(HuNavPlugin PUBLIC include) #${ignition-common3_INCLUDE_DIRS}        
ament_target_dependencies(HuNavPlugin 
  rclcpp 
  gazebo         
  gazebo_ros    
  hunav_msgs 
  geometry_msgs
  tf2 
  tf2_geometry_msgs
) 
ament_export_libraries(HuNavPlugin)
target_link_libraries(HuNavPlugin ${GAZEBO_LIBRARIES}) #${ignition-common3_LIBRARIES}

ignition_add_plugin(HuNavPlugin
  SYSTEM
  SOURCES src/HuNavPlugin.cpp
  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(TARGETS HuNavPlugin
  DESTINATION ${CMAKE_INSTALL_LIBDIR}
)



add_executable(hunav_gazebo_world_generator src/WorldGenerator.cpp)
ament_target_dependencies(hunav_gazebo_world_generator rclcpp hunav_msgs geometry_msgs tf2_geometry_msgs tf2 tf2_ros tinyxml2_vendor)
target_link_libraries(hunav_gazebo_world_generator ${TINYXML2_LIBRARY})

install(TARGETS hunav_gazebo_world_generator
  DESTINATION lib/${PROJECT_NAME}
)

install(TARGETS HuNavPlugin 
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

install(DIRECTORY include/
        DESTINATION include
)

install(DIRECTORY launch/
   DESTINATION share/${PROJECT_NAME}/launch
)
install(DIRECTORY worlds/
   DESTINATION share/${PROJECT_NAME}/worlds
)

install(DIRECTORY media/models
   DESTINATION share/${PROJECT_NAME}/
)
#install(DIRECTORY media/models/textures
#DESTINATION share/${PROJECT_NAME}/textures
#)


ament_package()

I already tried this:

set(ignition-fuel_tools7_FOUND FALSE)
set(ignition-gazebo6_FIND_REQUIRED_JSONCPP FALSE)

and this:

if (TARGET jsoncpp_static AND NOT TARGET JsonCpp::JsonCpp)
    add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
    set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_static")
elseif (TARGET jsoncpp_lib AND NOT TARGET JsonCpp::JsonCpp)
    add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
    set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_lib")
endif ()

but it didn't solve the problem

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论