Gazebo | Ignition | Community
Ask Your Question
0

What is the ConstWorldStatisticsPtr datatype?

asked 2013-08-12 13:29:16 -0500

F-word gravatar image

I was going through the tutorial on Topics and the souce code gazebo / examples / standalone / listener / listener.cc (https://bitbucket.org/osrf/gazebo/src/8b0c2de0886a61a862036f7e7fe1d4b7b8b4651c/examples/standalone/listener/listener.cc?at=gazebo_1.9).

I got a question on the callback function.

///////////////////////////////////////////////// // Function is called everytime a message is received. void cb(ConstWorldStatisticsPtr &_msg) {
// Dump the message contents to stdout. std::cout << _msg->DebugString(); }

I can see that ConstWorldStatisticsPtr deals with worldstatistics messages. But where can I find documents about this datatype? And if I want to process SonarStamped, what Const Ptr should be used?

edit retag flag offensive close merge delete

Comments

I think I've figured this out. Thank everybody for viewing. I will close this question.

F-word gravatar imageF-word ( 2013-08-14 18:37:43 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-09-15 16:13:30 -0500

nkoenig gravatar image
edit flag offensive delete link more

Comments

I cannot understand how to use this, say print out only sim_time?

Paul gravatar imagePaul ( 2013-10-21 07:55:08 -0500 )edit

Create receiving node (in main e.g.): transport::NodePtr inNode = transport::NodePtr(new gazebo::transport::Node()); inNode->Init(); transport::SubscriberPtr worldSub = inNode->Subscribe("/gazebo/default/world_stats", receiveWorld); Set up the receiving function: void receiveWorld(ConstWorldStatisticsPtr &msg) { auto timeMsg = msg->sim_time(); // get time common::Time time = timeMsg.nsec(); // get nanoseconds double tm = time.Double() / 100000000.0; // convert to seconds in double }

tommy gravatar imagetommy ( 2018-09-26 06:32:27 -0500 )edit

Turns out it remembers only the nanoseconds and doesn't count on. I'd therefore recommend a world plugin with your own topic publishing the time. This seems useless.

tommy gravatar imagetommy ( 2018-09-26 06:37:53 -0500 )edit
0

answered 2013-09-16 19:57:56 -0500

scpeters gravatar image

The ConstWorldStatisticsPtr type is a boost shared pointer pointer to the world_stats.proto protobuf message and is defined in the autogenerated message code files world_stats.pb.h, world_stats.pb.cc in your build directory. Here's a snippet from one of my copies of world_stats.pb.h:


typedef boost::shared_ptr<gazebo::msgs::worldstatistics> WorldStatisticsPtr;
...
typedef const boost::shared_ptr<gazebo::msgs::worldstatistics const=""> ConstWorldStatisticsPtr;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-08-12 13:29:16 -0500

Seen: 1,757 times

Last updated: Sep 16 '13