So I am trying to follow an example about how to add a topic using Gazebo's subscription service. Alas, one of the steps is to create a protobuf object and unfortunately, my protobuff class just will not compile when I run CMake. Here is what I have so far:
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;
}
and here is my cmake file
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})
Any idea what I am doing wrong? My protobuf file in a "msgs" subdirectory but when I move the code that is suppose to generate the protobuf libs into the subdirectory it still fails to compile. It does not through out any errors either.
Update: I am basing my code off this tutorial.
I solved this issue by changing the make file to so:
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})
I just had to add it as a shared library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.