Gazebo | Ignition | Community
Ask Your Question

How to receive a GzString

asked 2014-09-11 19:15:37 -0500

NickDP gravatar image

updated 2014-09-11 19:16:41 -0500

Hi all

I'm trying to send a string via the Gazebo transport system. I managed to write a plugin that publishes the string I want as a GzString message. I now want to write a receiver that does something with the string. My starting point for this is this listener example.

The problem I have is that I don't know what to do with my received string in the call back function (called cb in the above example). I have changed the call back function to accommodate for the fact that the message is a GzString as follows, but the change was essentially just a guess (replacing ConstWorldStatisticsPtr with ConstWorldStatisticsPtr) and I don't know if this is actually what I need to do. I can't find any documentation regarding this.

void cb(ConstWorldStatisticsPtr &_msg)
  // Dump the message contents to stdout.
  std::cout << _msg->DebugString();

The ->DebugString(); does not necessarily seem appropriate for a string, but I don't know what else to use or where to find documentation about this.

Can somebody help me or point me to where this is described?



P.S: What I'm trying to accomplish is to communicate joint angles back and forth. I would like to be able to have one message type that is able to handle a different number of joints. Right now, I just write the joint names and angle values into the string and parse them out on the receiving side. I realize that this is not very elegant but I couldn't figure out a better way. If you can offer help in doing this differently, I would also be open to suggestions.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-09-12 22:11:08 -0500

scpeters gravatar image

If you want to use existing types to send info about a group of joints, you can use a model message, which can contain multiple joint messages. The joint messages have fields for name and also angles.

For an example of the message syntax, see Model::FillMsg and Joint::FillMsg.

edit flag offensive delete link more


Thank you for your reply. Using Model::FillMsg, I can send a Model message. But I don't know how to get the data on the receiving end. I tried using Model::ProcessMsg(), but coudln't figure out how to create a Model object (the constructor wants a BasePtr _parent, which I don't have). I tried using the member functions that msgs::Model has, but it is not at all clear to me how to figure out what member functions there are. Is there any documentation for this? Thanks

NickDP gravatar imageNickDP ( 2014-09-15 13:40:26 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-09-11 19:15:37 -0500

Seen: 518 times

Last updated: Sep 12 '14