17#ifndef _GAZEBO_SENSORMANAGER_HH_
18#define _GAZEBO_SENSORMANAGER_HH_
20#include <boost/thread.hpp>
45 class GZ_SENSORS_VISIBLE SimTimeEvent
48 public: common::Time time;
51 public: boost::condition_variable *condition;
56 class GZ_SENSORS_VISIBLE SimTimeEventHandler
59 public: SimTimeEventHandler();
62 public:
virtual ~SimTimeEventHandler();
69 public:
void AddRelativeEvent(
const common::Time &_time,
70 boost::condition_variable *_var);
74 private:
void OnUpdate(
const common::UpdateInfo &_info);
77 private: boost::mutex mutex;
80 private: std::list<SimTimeEvent*> events;
83 private: event::ConnectionPtr updateConnection;
91 class GZ_SENSORS_VISIBLE SensorManager :
public SingletonT<SensorManager>
95 private: SensorManager();
98 private:
virtual ~SensorManager();
105 public:
void Update(
bool _force =
false);
136 const std::string &_worldName,
137 const std::string &_parentName,
148 const std::string &_worldName,
149 const std::string &_parentName,
150 const uint32_t _parentId);
177 private:
void AddSensor(
SensorPtr _sensor);
212 public:
virtual void Update(
bool _force =
false);
216 public:
void AddSensor(
SensorPtr _sensor);
224 bool _useLeafName =
false)
const;
239 private:
void RunLoop();
249 private:
bool initialized;
252 private: boost::thread *runThread;
255 private:
mutable boost::recursive_mutex mutex;
259 private: boost::condition_variable runCondition;
266 private:
class ImageSensorContainer :
public SensorContainer
271 public:
virtual void Update(
bool _force =
false);
277 private:
bool initialized;
280 private:
bool removeAllSensors;
283 private:
mutable boost::recursive_mutex mutex;
286 private: Sensor_V initSensors;
289 private: std::vector<std::string> removeSensors;
292 private:
typedef std::vector<SensorContainer*> SensorContainer_V;
295 private: SensorContainer_V sensorContainers;
298 private:
friend class SingletonT<SensorManager>;
304 private: SimTimeEventHandler *simTimeEventHandler;
308 private: std::map<std::string, physics::WorldPtr> worlds;
default namespace for gazebo
sensors
Definition SensorManager.hh:35
Forward declarations and typedefs for sensors.
SingletonT()
Definition SingletonT.hh:42
void Fini()
Finalize all the sensors.
void ResetLastUpdateTimes()
Reset last update times in all sensors.
friend class SensorContainer
Allow access to sensorTimeMutex member var.
Definition SensorManager.hh:301
void Stop()
Stop the run thread.
std::string CreateSensor(sdf::ElementPtr _elem, const std::string &_worldName, const std::string &_parentName, uint32_t _parentId)
Add a sensor from an SDF element.
void Init()
Init all the sensors.
void Update(bool _force=false)
Update all the sensors.
bool SensorsInitialized()
True if SensorManager::initSensors queue is empty i.e.
void RemoveSensor(const std::string &_name)
Remove a sensor.
void RemoveSensors()
Remove all sensors.
SensorPtr GetSensor(const std::string &_name) const
Get a sensor.
bool Running() const
Get whether there's at least one sensor container running.
Sensor_V GetSensors() const
Get all the sensors.
void RunThreads()
Run sensor updates in separate threads.
void OnCreateSensor(sdf::ElementPtr _elem, const std::string &_worldName, const std::string &_parentName, const uint32_t _parentId)
Add a sensor from an SDF element.
void GetSensorTypes(std::vector< std::string > &_types) const
Get all the sensor types.
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition SingletonT.hh:58
void stop()
Stop the sensor generation loop.
boost::shared_ptr< Connection > ConnectionPtr
Definition CommonTypes.hh:134
Sensors namespace.
Definition AltimeterSensor.hh:34
std::vector< SensorPtr > Sensor_V
Definition SensorTypes.hh:152
std::shared_ptr< Sensor > SensorPtr
Definition SensorTypes.hh:64
Forward declarations for the common classes.
Definition Animation.hh:27