All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SensorManager.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /*
18  * Desc: Class to manager all sensors
19  * Author: Nate Koenig
20  * Date: 18 Dec 2009
21  */
22 
23 #ifndef _SENSORMANAGER_HH_
24 #define _SENSORMANAGER_HH_
25 
26 #include <boost/thread.hpp>
27 #include <string>
28 #include <vector>
29 
30 #include "common/SingletonT.hh"
31 #include "sensors/SensorTypes.hh"
32 #include "sdf/sdf.hh"
33 
34 namespace gazebo
35 {
38  namespace sensors
39  {
44  class SensorManager : public SingletonT<SensorManager>
45  {
48  private: SensorManager();
49 
51  private: virtual ~SensorManager();
52 
58  public: void Update(bool _force = false);
59 
61  public: void Init();
62 
64  public: void Run();
65 
67  public: void Stop();
68 
70  public: void Fini();
71 
74  public: void GetSensorTypes(std::vector<std::string> &_types) const;
75 
83  public: std::string CreateSensor(sdf::ElementPtr _elem,
84  const std::string &_worldName,
85  const std::string &_parentName);
86 
90  public: SensorPtr GetSensor(const std::string &_name);
91 
94  public: Sensor_V GetSensors() const;
95 
98  public: void RemoveSensor(const std::string &_name);
99 
101  public: void RemoveSensors();
102 
105  public: bool SensorsInitialized();
106 
108  private: void RunLoop();
109 
111  private: bool stop;
112 
115  private: bool initialized;
116 
118  private: boost::thread *runThread;
119 
121  private: boost::recursive_mutex mutex;
122 
124  private: Sensor_V sensors;
125 
127  private: Sensor_V initSensors;
128 
130  private: friend class SingletonT<SensorManager>;
131  };
133  }
134 }
135 #endif
136 
137