Main Page
Namespaces
Classes
Files
File List
File Members
src
nodelets
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
>
7
#include <
pluginlib/class_list_macros.h
>
8
9
#include "
tracker.hh
"
10
11
namespace
visp_tracker
12
{
13
class
TrackerNodelet
:
public
nodelet::Nodelet
14
{
15
public
:
16
TrackerNodelet
()
17
:
nodelet
::
Nodelet
(),
18
exiting_
(false),
19
tracker_
(),
20
thread_
()
21
{}
22
23
~TrackerNodelet
()
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
;
37
tracker_
=
boost::shared_ptr<visp_tracker::Tracker>
38
(
new
visp_tracker::Tracker
(
getMTNodeHandle
(),
39
getMTPrivateNodeHandle
(),
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_
;
55
boost::shared_ptr<visp_tracker::Tracker>
tracker_
;
56
boost::shared_ptr<boost::thread>
thread_
;
57
};
58
59
}
// end of namespace visp_tracker.
60
61
PLUGINLIB_DECLARE_CLASS
(
visp_tracker
,
Tracker
,
62
visp_tracker::TrackerNodelet
,
nodelet::Nodelet
);
visp_tracker::TrackerNodelet::TrackerNodelet
TrackerNodelet()
Definition:
nodelets/tracker.cpp:16
NODELET_WARN
#define NODELET_WARN(...)
visp_tracker::TrackerNodelet::thread_
boost::shared_ptr< boost::thread > thread_
Definition:
nodelets/tracker.cpp:56
nodelet::Nodelet::getMTNodeHandle
ros::NodeHandle & getMTNodeHandle() const
PLUGINLIB_DECLARE_CLASS
PLUGINLIB_DECLARE_CLASS(visp_tracker, Tracker, visp_tracker::TrackerNodelet, nodelet::Nodelet)
visp_tracker::TrackerNodelet::spin
void spin()
Definition:
nodelets/tracker.cpp:33
boost::shared_ptr
nodelet::Nodelet::getMTPrivateNodeHandle
ros::NodeHandle & getMTPrivateNodeHandle() const
visp_tracker::TrackerNodelet::~TrackerNodelet
~TrackerNodelet()
Definition:
nodelets/tracker.cpp:23
nodelet.h
nodelet::Nodelet
class_list_macros.h
ros::ok
ROSCPP_DECL bool ok()
nodelet::Nodelet::Nodelet
Nodelet()
visp_tracker::TrackerNodelet::tracker_
boost::shared_ptr< visp_tracker::Tracker > tracker_
Definition:
nodelets/tracker.cpp:55
nodelet
visp_tracker::Tracker
Definition:
tracker.hh:39
visp_tracker::TrackerNodelet::onInit
virtual void onInit()
Definition:
nodelets/tracker.cpp:45
visp_tracker::TrackerNodelet
Definition:
nodelets/tracker.cpp:13
visp_tracker::TrackerNodelet::exiting_
volatile bool exiting_
Definition:
nodelets/tracker.cpp:54
NODELET_DEBUG
#define NODELET_DEBUG(...)
tracker.hh
visp_tracker
Definition:
names.cpp:3
visp_tracker
Author(s): Thomas Moulard
autogenerated on Wed Jul 3 2019 19:48:07