nodelets/tracker.cpp
Go to the documentation of this file.
1 #include <boost/bind.hpp>
2 #include <boost/make_shared.hpp>
3 #include <boost/shared_ptr.hpp>
4 #include <boost/thread.hpp>
5 
6 #include <nodelet/nodelet.h>
8 
9 #include "tracker.hh"
10 
11 namespace visp_tracker
12 {
14  {
15  public:
17  : nodelet::Nodelet (),
18  exiting_ (false),
19  tracker_ (),
20  thread_ ()
21  {}
22 
24  {
25  exiting_ = true;
26  if (thread_)
27  if (!thread_->timed_join (boost::posix_time::seconds (2)))
28  NODELET_WARN ("failed to join thread but continuing anyway");
29  thread_.reset ();
30  tracker_.reset ();
31  }
32 
33  void spin ()
34  {
35  if (exiting_)
36  return;
40  exiting_, 5u));
41  while (ros::ok () && !exiting_)
42  tracker_->spin ();
43  }
44 
45  virtual void onInit ()
46  {
47  NODELET_DEBUG ("Initializing nodelet...");
48  exiting_ = false;
49  thread_ = boost::make_shared<boost::thread>
50  (boost::bind (&TrackerNodelet::spin, this));
51  }
52 
53  private:
54  volatile bool exiting_;
57  };
58 
59 } // end of namespace visp_tracker.
60 
#define NODELET_WARN(...)
boost::shared_ptr< boost::thread > thread_
ros::NodeHandle & getMTNodeHandle() const
PLUGINLIB_DECLARE_CLASS(visp_tracker, Tracker, visp_tracker::TrackerNodelet, nodelet::Nodelet)
ros::NodeHandle & getMTPrivateNodeHandle() const
ROSCPP_DECL bool ok()
boost::shared_ptr< visp_tracker::Tracker > tracker_
#define NODELET_DEBUG(...)


visp_tracker
Author(s): Thomas Moulard
autogenerated on Wed Jul 3 2019 19:48:07