On this [page](http://gazebosim.org/tutorials?tut=guided_i6), I found a description on how to subscribe with a gazebo plugin to a ROS topic. But some questions came up.
With the following piece of code a ros node with name gazebo_client is initialized? What is ros::init_options::NoSigintHandler for?
// Initialize ros, if it has not already bee initialized.
if (!ros::isInitialized())
{
int argc = 0;
char **argv = NULL;
ros::init(argc, argv, "gazebo_client", ros::init_options::NoSigintHandler);
}
The name of the node is already set. So, why do I need reset for?
// Create our ROS node. This acts in a similar manner to
// the Gazebo node
this->rosNode.reset(new ros::NodeHandle("gazebo_client"));
I don't understand ros::SubscribeOptions perfectly. Could someone explain how it actually works and explain what the arguments are for? Also, what does rosQueue do?
// Create a named topic, and subscribe to it.
ros::SubscribeOptions so = ros::SubscribeOptions::create(
"/" + this->model->GetName() + "/vel_cmd",
1,
boost::bind(&VelodynePlugin::OnRosMsg, this, _1),
ros::VoidPtr(), &this->rosQueue);
What is the purpose of this piece of code?
// Spin up the queue helper thread.
this->rosQueueThread = std::thread(std::bind(&VelodynePlugin::QueueThread, this));
Here is the code for QueueThread
/// \brief ROS helper function that processes messages
private: void QueueThread()
{
static const double timeout = 0.01;
while (this->rosNode->ok())
{
this->rosQueue.callAvailable(ros::WallDuration(timeout));
}
}
Does it do the same work as ros::spinOnce() or as ros::spin()? What exactly is it for? Also, why is it called with std::thread?
↧