ros::Timer in ModelPlugin
Hi everyone!
I want to set a timer's callback for ModelPlugin. What is the better way to do it?
I tried such way but got error:
"error: invalid use of incomplete type ‘class ros::NodeHandle’ timer = nh->createTimer(ros::Duration(0.1), timerCallback);"
Code:
namespace gazebo
{
class VelodynePlugin : public ModelPlugin
{
...
private: ros::NodeHandlePtr nh;
ros::Timer timer;
public: void timerCallback()
{
cout << "Hi Vlad!" << endl;
}
public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
{
...
nh = boost::make_shared<ros::NodeHandle>();
timer = nh->createTimer(ros::Duration(0.1), timerCallback);
}
...
}
Where is a mistake?