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 Nate Koenig
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 <list>
28 #include <string>
29 #include <vector>
30 
31 #include "common/SingletonT.hh"
32 #include "sensors/SensorTypes.hh"
33 #include "sdf/sdf.hh"
34 
35 namespace gazebo
36 {
39  namespace sensors
40  {
45  class SensorManager : public SingletonT<SensorManager>
46  {
49  private: SensorManager();
50 
52  private: virtual ~SensorManager();
53 
59  public: void Update(bool _force = false);
60 
62  public: void Init();
63 
65  public: void Run();
66 
68  public: void Stop();
69 
71  public: void Fini();
72 
75  public: void GetSensorTypes(std::vector<std::string> &_types) const;
76 
84  public: std::string CreateSensor(sdf::ElementPtr _elem,
85  const std::string &_worldName,
86  const std::string &_parentName);
87 
91  public: SensorPtr GetSensor(const std::string &_name);
92 
95  public: void RemoveSensor(const std::string &_name);
96 
98  public: void RemoveSensors();
99 
102  public: bool SensorsInitialized();
103 
105  private: void RunLoop();
106 
108  private: bool stop;
109 
112  private: bool initialized;
113 
115  private: boost::thread *runThread;
116 
118  private: boost::recursive_mutex mutex;
119 
121  private: std::list<SensorPtr> sensors;
122 
124  private: std::list<SensorPtr> initSensors;
125 
127  private: friend class SingletonT<SensorManager>;
128  };
130  }
131 }
132 #endif
133 
134