Fawkes API  Fawkes Development Version
ros.cpp
1 
2 /***************************************************************************
3  * ros.cpp - ROS aspect for Fawkes
4  *
5  * Created: Thu May 05 15:53:31 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <plugins/ros/aspect/ros.h>
25 #include <ros/node_handle.h>
26 
27 namespace fawkes {
28 #if 0 /* just to make Emacs auto-indent happy */
29 }
30 #endif
31 
32 /** @class ROSAspect <plugins/ros/aspect/ros.h>
33  * Thread aspect to get access to a ROS node handle.
34  * Give this aspect to your thread to interact with the central ROS
35  * node handle.
36  *
37  * @ingroup Aspects
38  * @author Tim Niemueller
39  */
40 
41 /** @var fawkes:LockPtr<ros::NodeHandle> ROSAspect::rosnode
42  * Central ROS node handle. Make sure you use proper locking in your
43  * application when using the class, or chaos and havoc will come upon you.
44  */
45 
46 /** Constructor. */
48 {
49  add_aspect("ROSAspect");
50 }
51 
52 
53 /** Virtual empty destructor. */
55 {
56 }
57 
58 
59 /** Init ROS aspect.
60  * This set the ROS node handle.
61  * It is guaranteed that this is called for an ROS Thread before start
62  * is called (when running regularly inside Fawkes).
63  * @param rosnode ROS node handle
64  */
65 void
66 ROSAspect::init_ROSAspect(LockPtr<ros::NodeHandle> rosnode)
67 {
68  this->rosnode = rosnode;
69 }
70 
71 /** Finalize ROS aspect.
72  * This clears the ROS node handle.
73  */
74 void
75 ROSAspect::finalize_ROSAspect()
76 {
77  rosnode.clear();
78 }
79 
80 } // end namespace fawkes
virtual ~ROSAspect()
Virtual empty destructor.
Definition: ros.cpp:54
Fawkes library namespace.
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:52
ROSAspect()
Constructor.
Definition: ros.cpp:47
void clear()
Set underlying instance to 0, decrementing reference count of existing instance appropriately.
Definition: lockptr.h:492
LockPtr< ros::NodeHandle > rosnode
Central ROS node handle.
Definition: ros.h:48