nodelet.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Austin Robot Technology, Jack O'Quin
3  *
4  * License: Modified BSD Software License Agreement
5  *
6 
7  Copyright (C) 2010-2013 Austin Robot Technology, and others
8  All rights reserved.
9 
10 
11 Modified BSD License:
12 --------------------
13 
14  Redistribution and use in source and binary forms, with or without
15  modification, are permitted provided that the following conditions
16  are met:
17 
18  * Redistributions of source code must retain the above copyright
19  notice, this list of conditions and the following disclaimer.
20 
21  * Redistributions in binary form must reproduce the above
22  copyright notice, this list of conditions and the following
23  disclaimer in the documentation and/or other materials provided
24  with the distribution.
25 
26  * Neither the names of the University of Texas at Austin, nor
27  Austin Robot Technology, nor the names of other contributors may
28  be used to endorse or promote products derived from this
29  software without specific prior written permission.
30 
31  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
36  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
37  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
39  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
41  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 POSSIBILITY OF SUCH DAMAGE.
43  */
44 
50 #include <string>
51 #include <boost/thread.hpp>
52 
53 #include <ros/ros.h>
55 #include <nodelet/nodelet.h>
56 
57 #include "rsdriver.h"
58 
59 volatile sig_atomic_t flag = 1;
60 
61 namespace rslidar_driver
62 {
64 {
65 public:
67  {
68  }
69 
71  {
72  if (running_)
73  {
74  NODELET_INFO("shutting down driver thread");
75  running_ = false;
76  deviceThread_->join();
77  NODELET_INFO("driver thread stopped");
78  }
79  }
80 
81 private:
82  virtual void onInit(void);
83  virtual void devicePoll(void);
84 
85  volatile bool running_;
87 
89 };
90 
92 {
93  // start the driver
95 
96  // spawn device poll thread
97  running_ = true;
98  deviceThread_ = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&DriverNodelet::devicePoll, this)));
99  // NODELET_INFO("DriverNodelet onInit");
100 }
101 
104 {
105  while (ros::ok() && dvr_->poll())
106  {
107  ros::spinOnce();
108  }
109 }
110 }
111 
112 // Register this plugin with pluginlib. Names must match nodelet_velodyne.xml.
113 //
114 // parameters are: class type, base class type
volatile bool running_
device thread is running
Definition: nodelet.cc:85
virtual void devicePoll(void)
Device poll thread main loop.
Definition: nodelet.cc:103
PLUGINLIB_EXPORT_CLASS(BAGReader, nodelet::Nodelet)
virtual void onInit(void)
Definition: nodelet.cc:91
ros::NodeHandle & getPrivateNodeHandle() const
ROSCPP_DECL bool ok()
ros::NodeHandle & getNodeHandle() const
volatile sig_atomic_t flag
Definition: nodelet.cc:59
#define NODELET_INFO(...)
boost::shared_ptr< boost::thread > deviceThread_
Definition: nodelet.cc:86
ROSCPP_DECL void spinOnce()
boost::shared_ptr< rslidarDriver > dvr_
driver implementation class
Definition: nodelet.cc:88


rslidar_driver
Author(s): Tony Zhang , Tony Zhang
autogenerated on Mon Jun 10 2019 14:41:07