Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

Protobuf intro

Gazebo messages are generated using Protocol buffers (protobuf). The messages are described in .proto files, and Protobuf uses that file to generate a C++ class.

For example, this is the description for the contacts message:

import "contact.proto";
import "time.proto";

message Contacts
{
  repeated Contact contact   = 1;
  required Time time         = 2;
}

You can see that the contact field is a repeated field of the Contact (singular) message. For every repeated field, Protobuf generates a <field_name>_size() function, such as the contact_size() one.

This is all described in the Protocol Buffers C++ Generated Code documentation.

Header files

This is not ideal, but personally, what I do when I want to check a message's API, is to check its header files (who has time to read the protobuf documentation? :P).

Protobuf creates a <message_name>.pb.h header for each message and installs it in your system. You can look for the contacts.pb.h header like this:

find /usr | grep contacts.pb.h

Then you'll find something similar to this:

/usr/local/include/gazebo-7/gazebo/msgs/contacts.pb.h

So you can open that file and take a look at the API:

gedit /usr/local/include/gazebo-7/gazebo/msgs/contacts.pb.h

Digging through header files is definitely not ideal... We do have some form of message API documentation, but that's broken, as described on this issue.