Read-only mirror of https://github.com/ethz-asl/protobuf_catkin — ETHZ ASL. Issues & pull requests at the source.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Alex Millane 721a6cc17e
Merge pull request #38 from Jaeyoung-Lim/pr-fix-noetic
Use correct python commands depending on the python version
2021-11-15 19:16:48 +01:00
cmake Add optional GRPC stuff. 2020-02-10 15:00:50 +01:00
.gitignore Fix and ignore bloom output 2018-07-03 14:16:40 +02:00
CMakeLists.txt Use correct python commands depending on the python version 2021-11-12 17:31:29 +01:00
package.xml Fix grpc option. 2020-02-10 15:15:35 +01:00
README.md Update README.md 2017-10-26 08:37:29 +02:00
unused_parameter_warnings.patch
unused_parameter_warnings_wire_format.patch Added patch to get rid of some more warnings 2017-04-05 13:45:03 +02:00

protobuf_catkin

A catkin wrapper for Google protocol buffers

Usage

In your CMakeLists.txt, call the protobuf compiler:

set(PROTO_DEFNS proto/path-to-my-protos/my-proto.proto)
set(BASE_PATH "proto")
PROTOBUF_CATKIN_GENERATE_CPP2(${BASE_PATH} PROTO_SRCS PROTO_HDRS ${PROTO_DEFNS}) 

...

cs_add_library(${PROJECT_NAME} src/my-source-files.cc
                               ${PROTO_SRCS}
                               ${PROTO_HDRS})

where BASE_PATH is the base path to the folder containing all protobuf definitions (in this example, the base path is proto).

This will generate C++ codes for the protos given by PROTO_DEFNS. The C++ files will be generated under catkin_wsbuild/${PROJECT_NAME}/compiled_proto. The structure within this folder mirrors the structure of the source definitions (within BASE_PATH).

From the compiled C++ files, the generated headers (*.pb.h) are installed into catkin_ws/devel/include, again keeping the folder structure from within BASE_PATH. The *.proto definition files are installed into catkin_ws/devel/share/proto so that they can be used by other packages.

The example code above would generate the following files:

  • catkin_ws/build/${PROJECT_NAME}/compiled_proto/path-to-my-protos/my-proto.pb.cc
  • catkin_ws/build/${PROJECT_NAME}/compiled_proto/path-to-my-protos/my-proto.pb.h
  • catkin_ws/devel/include/path-to-my-protos/my-proto.pb.h
  • catkin_ws/devel/share/proto/path-to-my-protos/my-proto.pb.h

The protobuf definitions can then be used with #include <path-to-my-protos/my-proto.pb.h in C++ or with import "path-to-my-protos/my-proto.proto"; in other protobuf definition files.