nodelet.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Yujin Robot.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Yujin Robot nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
35 /*****************************************************************************
36  ** Includes
37  *****************************************************************************/
38 
39 #include <nodelet/nodelet.h>
41 #include <ecl/threads/thread.hpp>
43 
44 namespace kobuki
45 {
46 
48 {
49 public:
52  {
53  NODELET_DEBUG("Waiting for update thread to finish.");
54  update_thread_.join();
55  }
56  virtual void onInit()
57  {
58  NODELET_DEBUG("Initialising nodelet...");
59  std::string nodelet_name = this->getName();
60  auto_dock_.reset(new AutoDockingROS(nodelet_name));
61  auto_dock_->init(this->getPrivateNodeHandle());
62  NODELET_DEBUG("Nodelet initialised.");
63  }
64 private:
65  void update()
66  {
67  ros::Rate spin_rate(10);
68  while (ros::ok())
69  {
70  auto_dock_->spin();
71  spin_rate.sleep();
72  }
73  }
74 
76  ecl::Thread update_thread_;
77 };
78 
79 } //namespace kobuki
virtual void onInit()
Definition: nodelet.cpp:56
const std::string & getName() const
boost::shared_ptr< AutoDockingROS > auto_dock_
Definition: nodelet.cpp:75
ros::NodeHandle & getPrivateNodeHandle() const
PLUGINLIB_EXPORT_CLASS(kobuki::AutoDockingNodelet, nodelet::Nodelet)
ecl::Thread update_thread_
Definition: nodelet.cpp:76
ROSCPP_DECL bool ok()
bool sleep()
#define NODELET_DEBUG(...)


kobuki_auto_docking
Author(s): Younghun Ju
autogenerated on Mon Jun 10 2019 13:44:57