# What is the topic ~/world_stats?

I am following this tutorial . It teaches me to write a program to listen on the topic ~/worldstats. I did and it worked. However, when I run $gz topic -l, I cannot find a topic named ~/worldstats. So what is ~/world_stats? and what does the tilde '~' mean here? And what is 'ConstWorldStatisticsPtr'? The following is the listener.cpp files for your reference: #include <gazebo/transport/transport.hh> #include <gazebo/msgs/msgs.hh> #include <gazebo/gazebo.hh> #include <iostream> ///////////////////////////////////////////////// // Function is called everytime a message is received. void cb(ConstWorldStatisticsPtr &_msg) { // Dump the message contents to stdout. std::cout << _msg->DebugString(); } ///////////////////////////////////////////////// int main(int _argc, char **_argv) { // Load gazebo gazebo::setupClient(_argc, _argv); // Create our node for communication gazebo::transport::NodePtr node(new gazebo::transport::Node()); node->Init(); // Listen to Gazebo world_stats topic gazebo::transport::SubscriberPtr sub = node->Subscribe("~/world_stats", cb); // Busy wait loop...replace with your own code as needed. while (true) gazebo::common::Time::MSleep(10); // Make sure to shut everything down. gazebo::shutdown(); }  edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted ~/world_stats gives you statistics about the world, such as the time elapsed and the paused state. • The type of the messages being published is gazebo::msgs::WorldStatistics. Here you can see all the message fields. ConstWorldStatisticsPtr is the same as boost::shared_ptr<const gazebo::msgs::WorldStatistics>. • The tilde ~ is shorthand for the default world. If you're running the default world, when you do $ gz topic -l, you'll see a list of topics all starting with /gazebo/default and one of them is /gazebo/default/world_stats, which corresponds to the ~/world_stats you're subscribing to.

• You can run \$ gz topic -e /gazebo/default/world_stats, to see all fields of the message printed out as the simulation is running.

more