Main Page
Namespaces
Classes
Files
File List
File Members
src
nodelets
nodelets/client.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-client.hh
"
10
11
namespace
visp_tracker
12
{
13
class
TrackerClientNodelet
:
public
nodelet::Nodelet
14
{
15
public
:
16
TrackerClientNodelet
()
17
:
nodelet
::
Nodelet
(),
18
exiting_
(false),
19
trackerClient_
(),
20
thread_
()
21
{}
22
23
~TrackerClientNodelet
()
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
trackerClient_
.reset ();
31
}
32
33
void
spin
()
34
{
35
trackerClient_
=
boost::shared_ptr<visp_tracker::TrackerClient>
36
(
new
visp_tracker::TrackerClient
37
(
getMTNodeHandle
(),
38
getMTPrivateNodeHandle
(),
39
exiting_
, 5u));
40
if
(
ros::ok
() && !
exiting_
)
41
trackerClient_
->spin ();
42
}
43
44
virtual
void
onInit
()
45
{
46
NODELET_DEBUG
(
"Initializing nodelet..."
);
47
exiting_
=
false
;
48
thread_
= boost::make_shared<boost::thread>
49
(boost::bind (&
TrackerClientNodelet::spin
,
this
));
50
}
51
private
:
52
volatile
bool
exiting_
;
53
boost::shared_ptr<visp_tracker::TrackerClient>
trackerClient_
;
54
boost::shared_ptr<boost::thread>
thread_
;
55
};
56
57
}
// end of namespace visp_tracker.
58
59
PLUGINLIB_DECLARE_CLASS
(
visp_tracker
,
TrackerClient
,
60
visp_tracker::TrackerClientNodelet
,
nodelet::Nodelet
);
visp_tracker::TrackerClientNodelet::thread_
boost::shared_ptr< boost::thread > thread_
Definition:
nodelets/client.cpp:54
NODELET_WARN
#define NODELET_WARN(...)
visp_tracker::TrackerClientNodelet::onInit
virtual void onInit()
Definition:
nodelets/client.cpp:44
PLUGINLIB_DECLARE_CLASS
PLUGINLIB_DECLARE_CLASS(visp_tracker, TrackerClient, visp_tracker::TrackerClientNodelet, nodelet::Nodelet)
nodelet::Nodelet::getMTNodeHandle
ros::NodeHandle & getMTNodeHandle() const
visp_tracker::TrackerClientNodelet::exiting_
volatile bool exiting_
Definition:
nodelets/client.cpp:52
visp_tracker::TrackerClientNodelet::~TrackerClientNodelet
~TrackerClientNodelet()
Definition:
nodelets/client.cpp:23
boost::shared_ptr
nodelet::Nodelet::getMTPrivateNodeHandle
ros::NodeHandle & getMTPrivateNodeHandle() const
visp_tracker::TrackerClientNodelet::TrackerClientNodelet
TrackerClientNodelet()
Definition:
nodelets/client.cpp:16
nodelet.h
nodelet::Nodelet
class_list_macros.h
visp_tracker::TrackerClientNodelet
Definition:
nodelets/client.cpp:13
visp_tracker::TrackerClientNodelet::trackerClient_
boost::shared_ptr< visp_tracker::TrackerClient > trackerClient_
Definition:
nodelets/client.cpp:53
ros::ok
ROSCPP_DECL bool ok()
nodelet::Nodelet::Nodelet
Nodelet()
nodelet
tracker-client.hh
visp_tracker::TrackerClient
Definition:
tracker-client.hh:39
visp_tracker::TrackerClientNodelet::spin
void spin()
Definition:
nodelets/client.cpp:33
NODELET_DEBUG
#define NODELET_DEBUG(...)
visp_tracker
Definition:
names.cpp:3
visp_tracker
Author(s): Thomas Moulard
autogenerated on Wed Jul 3 2019 19:48:07