Skip to content

Commit

Permalink
[jsk_topic_tools] fix timer start flag of ConstantRateThrottleNodelet
Browse files Browse the repository at this point in the history
  • Loading branch information
sktometometo committed Sep 18, 2022
1 parent 4573dae commit f6314a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -31,6 +31,7 @@ namespace jsk_topic_tools
ros::TransportHints th_;
ros::NodeHandle pnh_;
ros::Timer timer_publish_;
bool timer_started_;

boost::mutex mutex_;

Expand Down
5 changes: 4 additions & 1 deletion jsk_topic_tools/src/constant_rate_throttle_nodelet.cpp
Expand Up @@ -7,6 +7,7 @@ namespace jsk_topic_tools
pnh_ = this->getPrivateNodeHandle();
subscribing_ = false;
advertised_ = false;
timer_started_ = false;
msg_cached_ = boost::shared_ptr<topic_tools::ShapeShifter>(new topic_tools::ShapeShifter());

srv_ = boost::make_shared<dynamic_reconfigure::Server<Config> >(pnh_);
Expand Down Expand Up @@ -90,7 +91,7 @@ namespace jsk_topic_tools

bool ConstantRateThrottle::isLoopAlive()
{
return timer_publish_.isValid() and timer_publish_.hasStarted();
return timer_publish_.isValid() and timer_started_;
}

void ConstantRateThrottle::startPublishLoop(double loop_rate)
Expand All @@ -104,12 +105,14 @@ namespace jsk_topic_tools
} else {
timer_publish_.setPeriod(ros::Duration(1.0/update_rate_));
timer_publish_.start();
timer_started_ = false;
}
}

void ConstantRateThrottle::stopPublishLoop()
{
timer_publish_.stop();
timer_started_ = false;
}

}
Expand Down

0 comments on commit f6314a0

Please sign in to comment.