Gazebo Sensors

API Reference

9.0.0
Manager Class Reference

Loads and runs sensors. More...

#include <Manager.hh>

Public Member Functions

 Manager ()
 constructor
 
virtual ~Manager ()
 destructor
 
SensorId AddSensor (std::unique_ptr< Sensor > _sensor)
 Add a sensor for this manager to manage.
 
template<typename SensorType , typename SdfType >
SensorType * CreateSensor (SdfType _sdf)
 Create a sensor from an SDF ovject with a known sensor type.
 
bool Init ()
 Initialize the sensor library without rendering or physics.
 
bool Remove (const SensorId _id)
 Remove a sensor by ID.
 
void RunOnce (const std::chrono::steady_clock::duration &_time, bool _force=false)
 Run the sensor generation one step.
 
SensorSensor (SensorId _id)
 Get an instance of a loaded sensor by sensor id.
 

Detailed Description

Loads and runs sensors.

This class is responsible for loading and running sensors, and providing sensors with common environments to generat data from.

The primary interface through which to load a sensor is LoadSensor(). This takes an sdf element pointer that should be configured with everything the sensor will need. Custom sensors configuration must be in the <plugin> tag of the sdf::Element. The manager will dynamically load the sensor library and update it.

Remarks
This class is not thread safe.

Constructor & Destructor Documentation

◆ Manager()

Manager ( )

constructor

◆ ~Manager()

virtual ~Manager ( )
virtual

destructor

Member Function Documentation

◆ AddSensor()

SensorId AddSensor ( std::unique_ptr< Sensor _sensor)

Add a sensor for this manager to manage.

See also
Sensor()
Parameters
[in]_sensorPointer to the sensor
Returns
A sensor id that refers to the created sensor. NO_SENSOR is returned on error.

Referenced by Manager::CreateSensor().

◆ CreateSensor()

template<typename SensorType , typename SdfType >
SensorType * CreateSensor ( SdfType  _sdf)
inline

Create a sensor from an SDF ovject with a known sensor type.

See also
Sensor()
Parameters
[in]_sdfAn SDF element or DOM object.
Template Parameters
SensorTypeSensor type
SdfTypeIt may be an sdf::ElementPtr containing a sensor or an sdf::Sensor.
Returns
A pointer to the created sensor. Null returned on error. The Manager keeps ownership of the pointer's lifetime.

References Manager::AddSensor(), SensorFactory::CreateSensor(), std::endl(), std::move(), and gz::sensors::NO_SENSOR.

◆ Init()

bool Init ( )

Initialize the sensor library without rendering or physics.

Returns
True if successfully initialized, false if not

◆ Remove()

bool Remove ( const SensorId  _id)

Remove a sensor by ID.

Parameters
[in]_idID of the sensor to remove
Returns
True if the sensor exists and removed.

◆ RunOnce()

void RunOnce ( const std::chrono::steady_clock::duration &  _time,
bool  _force = false 
)

Run the sensor generation one step.

Parameters
_timeThe current simulated time
_forceIf true, all sensors are forced to update. Otherwise a sensor will update based on it's Hz rate.

◆ Sensor()

Sensor * Sensor ( SensorId  _id)

Get an instance of a loaded sensor by sensor id.

Parameters
[in]_idIdenitifier of the sensor.
Returns
Pointer to the sensor, nullptr on error.

The documentation for this class was generated from the following file: