Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

I found the answer, it's actually a really simple mistake. Creating the timer this way in the Load() method means that once Load() finishes, the timer will simply go out of scope. The documentation of createTimer indicates that this will simply stop and destroy the timer. Therefore, I only need to add a ros::Timer timer attribute to my class and replace

this->rosNode->createTimer(ros::Duration(0.04),&Lidar3DPlugin::OnUpdate,this);

with

this->timer = this->rosNode->createTimer(ros::Duration(0.04),&Lidar3DPlugin::OnUpdate,this);

This way when Load() finishes, the timer stays in scope until Gazebo is closed and my plugin instance is automatically destroyed.

Best.