17 #ifndef _GAZEBO_SENSORMANAGER_HH_
18 #define _GAZEBO_SENSORMANAGER_HH_
20 #include <boost/thread.hpp>
25 #include <condition_variable>
47 class GZ_SENSORS_VISIBLE SimTimeEvent
50 public: common::Time time;
53 public: boost::condition_variable *condition;
58 class GZ_SENSORS_VISIBLE SimTimeEventHandler
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);
143 const std::string &_worldName,
144 const std::string &_parentName,
155 const std::string &_worldName,
156 const std::string &_parentName,
157 const uint32_t _parentId);
185 private:
void WaitForSensors(
double _clk,
double _dt);
190 private:
bool WaitForPrerendered(
double _timeoutsec);
194 private:
void AddSensor(
SensorPtr _sensor);
202 private:
class SensorContainer
205 public: SensorContainer();
208 public:
virtual ~SensorContainer();
224 public:
bool Running()
const;
229 public:
virtual void Update(
bool _force =
false);
233 public:
void AddSensor(
SensorPtr _sensor);
240 public:
SensorPtr GetSensor(
const std::string &_name,
241 bool _useLeafName =
false)
const;
246 public:
bool RemoveSensor(
const std::string &_name);
249 public:
void RemoveSensors();
252 public:
void ResetLastUpdateTimes();
256 private:
void RunLoop();
266 private:
bool initialized;
269 private: boost::thread *runThread;
272 private:
mutable boost::recursive_mutex mutex;
276 private: boost::condition_variable runCondition;
283 private:
class ImageSensorContainer :
public SensorContainer
288 public:
bool WaitForPrerendered(
double _timeoutsec);
293 public:
virtual void Update(
bool _force =
false);
296 private: std::condition_variable conditionPrerendered;
302 private:
bool initialized;
305 private:
bool removeAllSensors;
308 private:
mutable boost::recursive_mutex mutex;
314 private: std::vector<std::string> removeSensors;
317 private:
typedef std::vector<SensorContainer*> SensorContainer_V;
320 private: SensorContainer_V sensorContainers;
326 private:
friend class SensorContainer;
329 private: SimTimeEventHandler *simTimeEventHandler;
333 private: std::map<std::string, physics::WorldPtr> worlds;
default namespace for gazebo
sensors
Definition: SensorManager.hh:37
Forward declarations and typedefs for sensors.
Singleton template class.
Definition: SingletonT.hh:34
Class to manage and update all sensors.
Definition: SensorManager.hh:94
void Fini()
Finalize all the sensors.
void ResetLastUpdateTimes()
Reset last update times in all sensors.
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.
double NextRequiredTimestamp()
Amongst all IMAGE sensors, returns the forthcoming timestamp used by one (or several) sensor.
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
void stop()
Stop the sensor generation loop.
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
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