How do I import Ignition Msg protobufs into my own custom protobuf?

asked 2018-05-16 20:35:14 -0600

MartinDeegan gravatar image

I am trying to make a custom message that uses ignition::msgs::Vector3d and ignition::msgs::Quaternion. Here is my state.proto

syntax = "proto2";

package cdrone.messages;

import "quaternion.proto";
import "vector3d.proto";

message State
{
  required int64 time = 1;

  required Vector3d position = 2;
  required Vector3d velocity = 3;
  required Quaternion attitude = 4;
  required Vector3d angular_velocity = 5;
}

Here is the CMakeLists.txt I am using to compile the protobufs:

include_directories(${PROTOBUF_INCLUDE_DIRS})

set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} "/usr/include/ignition/msgs1/ignition/msgs")

set(ProtoFiles 
    gamepad.proto
    motor_power.proto
    /usr/include/ignition/msgs1/ignition/msgs/time.proto
    /usr/include/ignition/msgs1/ignition/msgs/header.proto
    /usr/include/ignition/msgs1/ignition/msgs/vector3d.proto
    /usr/include/ignition/msgs1/ignition/msgs/quaternion.proto
    state.proto)

PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
add_library(messages SHARED ${ProtoSources})
target_link_libraries(messages ${PROTOBUF_LIBRARY})

It looks like it finds the proto files but when it tries to compile an imported proto inside the imported proto, it fails to find the file.

 $ make
[  4%] Built target cpptoml-parser
[  9%] Built target cpptoml-build
[ 14%] Built target cpptoml-conversions
[ 19%] Built target parse
[ 21%] Running C++ protocol buffer compiler on state.proto
ignition/msgs/header.proto: File not found.
quaternion.proto: Import "ignition/msgs/header.proto" was not found or had errors.
quaternion.proto:32:12: "Header" is not defined.
vector3d.proto: Import "ignition/msgs/header.proto" was not found or had errors.
vector3d.proto:32:12: "Header" is not defined.
state.proto: Import "quaternion.proto" was not found or had errors.
state.proto: Import "vector3d.proto" was not found or had errors.
state.proto:12:12: "Vector3d" is not defined.
state.proto:13:12: "Vector3d" is not defined.
state.proto:14:12: "Quaternion" is not defined.
state.proto:15:12: "Vector3d" is not defined.
src/common/messages/CMakeFiles/messages.dir/build.make:110: recipe for target 'src/common/messages/state.pb.cc' failed
make[2]: *** [src/common/messages/state.pb.cc] Error 1
CMakeFiles/Makefile2:413: recipe for target 'src/common/messages/CMakeFiles/messages.dir/all' failed
make[1]: *** [src/common/messages/CMakeFiles/messages.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
edit retag flag offensive close merge delete

Comments

Hi, could you fix this issue? I have the same issue

elector102 gravatar imageelector102 ( 2019-06-04 10:29:13 -0600 )edit

Same problem

wfcola gravatar imagewfcola ( 2020-06-09 04:44:26 -0600 )edit