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();
}