所以我试图关注如何使用Gazebo的订阅服务添加主题的示例。唉,其中一个步骤是创建一个protobuf对象,不幸的是,当我运行CMake时,我的protobuff类将无法编译。以下是我到目前为止的情况:
import "vector3d.proto";
message ModelVelResponse
{
required AVelV angularVel = 1;
required LVelV linearVel = 2;
}
message AVelV{
repeated gazebo.msgs.Vector3d angularVel = 1;
}
message LVelV{
repeated gazebo.msgs.Vector3d linearVel = 1;
}
这是我的cmake文件
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
find_package(Protobuf REQUIRED)
set(PROTOBUF_IMPORT_DIRS)
foreach(ITR ${GAZEBO_INCLUDE_DIRS})
if(ITR MATCHES ".*gazebo-[0-9.]+$")
set(PROTOBUF_IMPORT_DIRS "${ITR}/gazebo/msgs/proto")
endif()
endforeach()
set (msgs
velocity_message.proto
${PROTOBUF_IMPORT_DIRS}/vector3d.proto
${PROTOBUF_IMPORT_DIRS}/header.proto
${PROTOBUF_IMPORT_DIRS}/time.proto
)
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${msgs})
add_library(velocity_msgs SHARED ${PROTO_SRCS})
target_link_libraries(velocity_msgs ${PROTOBUF_LIBRARY})
find_package(Boost REQUIRED COMPONENTS system)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
include (FindPkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(GAZEBO gazebo)
endif()
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
add_library(model_vel SHARED model_vel.cc)
target_link_libraries(model_vel ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES})
知道我做错了什么吗?我的protobuf文件位于“msgs”子目录中,但是当我将代码生成protobuf库移动到子目录中时,它仍然无法编译。它也没有任何错误。
更新:我的代码基于this教程。
答案 0 :(得分:0)
我通过将make文件更改为:
来解决了这个问题select
我只需将其添加为共享库。