23 #ifndef _SENSORMANAGER_HH_
24 #define _SENSORMANAGER_HH_
26 #include <boost/thread.hpp>
50 public: common::Time time;
53 public: boost::condition_variable *condition;
61 public: SimTimeEventHandler();
64 public:
virtual ~SimTimeEventHandler();
71 public:
void AddRelativeEvent(
const common::Time &_time,
72 boost::condition_variable *_var);
76 private:
void OnUpdate(
const common::UpdateInfo &_info);
79 private: boost::mutex mutex;
82 private: std::list<SimTimeEvent*> events;
107 public:
void Update(
bool _force =
false);
114 public:
void RunThreads();
124 public:
void GetSensorTypes(std::vector<std::string> &_types)
const;
127 public: std::string CreateSensor(sdf::ElementPtr _elem,
128 const std::string &_worldName,
138 public: std::string CreateSensor(sdf::ElementPtr _elem,
139 const std::string &_worldName,
140 const std::string &_parentName,
146 public:
SensorPtr GetSensor(
const std::string &_name)
const;
150 public:
Sensor_V GetSensors()
const;
154 public:
void RemoveSensor(
const std::string &_name);
157 public:
void RemoveSensors();
161 public:
bool SensorsInitialized();
164 public:
void ResetLastUpdateTimes();
168 private:
void AddSensor(
SensorPtr _sensor);
176 private:
class SensorContainer
179 public: SensorContainer();
182 public:
virtual ~SensorContainer();
199 public:
virtual void Update(
bool _force =
false);
203 public:
void AddSensor(
SensorPtr _sensor);
210 public:
SensorPtr GetSensor(
const std::string &_name,
211 bool _useLeafName =
false)
const;
216 public:
bool RemoveSensor(
const std::string &_name);
219 public:
void RemoveSensors();
222 public:
void ResetLastUpdateTimes();
226 private:
void RunLoop();
236 private:
bool initialized;
239 private: boost::thread *runThread;
242 private:
mutable boost::recursive_mutex mutex;
246 private: boost::condition_variable runCondition;
253 private:
class ImageSensorContainer :
public SensorContainer
258 public:
virtual void Update(
bool _force =
false);
264 private:
bool initialized;
267 private:
bool removeAllSensors;
270 private:
mutable boost::recursive_mutex mutex;
276 private: std::vector<std::string> removeSensors;
279 private:
typedef std::vector<SensorContainer*> SensorContainer_V;
282 private: SensorContainer_V sensorContainers;
288 private:
friend class SensorContainer;
291 private: SimTimeEventHandler *simTimeEventHandler;