Home | Tutorials | Wiki | Issues
Ask Your Question

How to make the ign tool work with custom messages

asked 2017-08-31 18:43:51 -0500

I'm wondering what would be involved to make the ign tool and subtools like ign topic work with messages outside of ignition msgs. It seems like the ignition messages get some extra generated code, such as calls to IGN_REGISTER_STATIC_MSG, which make them discoverable by the ign tool. Can I get a brief explanation of how this works, and how I can get it to work with custom messages? I realize this may not be easy, but I'm willing to put in some work.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-09-02 05:11:04 -0500

Carlos Agüero gravatar image

updated 2017-09-03 04:50:41 -0500

I'm assuming that you're referring to ign topic --pub or ign service --req. The rest of the topic/service options should work with custom messages (info, list, echo).

I think this problem can be reduced as: Given a string representation of a Protobuf message (e.g.: example.msgs.StringMsg), can you write a function that creates one of your custom messages and returns a pointer to a google::protobuf::message?

google::protobuf::Message* CreateMsg(const std::string &_type)

This should be possible to implement if you generate your messages with descriptor information, and then, use the DynamicMessage class from Protobuf. If you can solve this problem first, I'll help you to integrate it with ign.

The way this is solved in Ignition Messages is different. We essentially maintain a map with types and a Protobuf message for each Ignition Message Type. The IGN_REGISTER_STATIC_MSG macro is injected in each message because we use our own message generator to add that code. I don't know exactly where, but the maps is populated inside the Ignition Message shared library.

edit flag offensive delete link more


I haven't put any work into this yet, but I will just note the echo command also does not work. It simply prints nothing (doesn't crash or print errors) when listening to a topic with custom message type

Peter Mitrano gravatar imagePeter Mitrano ( 2017-09-09 19:27:19 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-08-31 18:43:51 -0500

Seen: 33 times

Last updated: Sep 03