Skip to content

Commit

Permalink
Added AddSensor method to Manager
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde committed Aug 21, 2020
1 parent 50feecc commit 25be8d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions include/ignition/sensors/Manager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ namespace ignition
/// is returned on erro.
public: ignition::sensors::SensorId CreateSensor(sdf::ElementPtr _sdf);

/// \brief Add a sensor from a sensor instance.
/// \sa Sensor()
/// \param[in] _sensor pointer to the sensor
/// \return A sensor id that refers to the created sensor. NO_SENSOR
/// is returned on error.
public: ignition::sensors::SensorId AddSensor(std::unique_ptr<sensors::Sensor> _sensor);

/// \brief Create a sensor from SDF without a known sensor type.
///
/// This creates sensors by looking at the given sdf element.
Expand Down
1 change: 0 additions & 1 deletion include/ignition/sensors/SensorFactory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include <ignition/common/Console.hh>
#include <ignition/plugin/Loader.hh>
#include <ignition/plugin/RegisterMore.hh>

#include <ignition/sensors/config.hh>
#include <ignition/sensors/Export.hh>
Expand Down
10 changes: 10 additions & 0 deletions src/Manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ void Manager::RunOnce(const ignition::common::Time &_time, bool _force)
}
}

/////////////////////////////////////////////////
ignition::sensors::SensorId Manager::AddSensor(std::unique_ptr<sensors::Sensor> _sensor)
{
if (!_sensor)
return NO_SENSOR;
SensorId id = _sensor->Id();
this->dataPtr->sensors[id] = std::move(_sensor);
return id;
}

/////////////////////////////////////////////////
ignition::sensors::SensorId Manager::CreateSensor(const sdf::Sensor &_sdf)
{
Expand Down

0 comments on commit 25be8d7

Please sign in to comment.