17#ifndef GAZEBO_SENSORS_SENSOR_HH_
18#define GAZEBO_SENSORS_SENSOR_HH_
26#include <ignition/math/Pose3.hh>
27#include <ignition/transport/Node.hh>
52 :
public std::enable_shared_from_this<Sensor>
64 public:
virtual void Load(
const std::string &_worldName,
65 sdf::ElementPtr _sdf);
69 public:
virtual void Load(
const std::string &_worldName);
72 public:
virtual void Init();
77 public:
void SetParent(
const std::string &_name,
const uint32_t _id);
86 public:
void Update(
const bool _force);
97 public:
virtual void Fini();
101 public: std::string
Name()
const;
110 public:
virtual ignition::math::Pose3d
Pose()
const;
115 public:
virtual void SetPose(
const ignition::math::Pose3d &_pose);
127 public: std::string
Type()
const;
144 public:
virtual std::string
Topic()
const;
160 std::function<
void()> _subscriber);
172 public: uint32_t
Id()
const;
190 protected:
virtual bool UpdateImpl(
const bool ) {
return false;}
198 private:
void LoadPlugin(sdf::ElementPtr _sdf);
204 protected: sdf::ElementPtr
sdf;
207 protected: ignition::math::Pose3d
pose;
222 protected: std::vector<SensorPluginPtr>
plugins;
242 protected: std::map<SensorNoiseType, NoisePtr>
noises;
249 private: std::unique_ptr<SensorPrivate> dataPtr;
default namespace for gazebo
sensors
Definition SensorManager.hh:35
Forward declarations and typedefs for sensors.
Forward declarations for transport.
A Time class, can be used to hold wall- or sim-time.
Definition Time.hh:48
Base class for sensors.
Definition Sensor.hh:53
bool active
True if sensor generation is active.
Definition Sensor.hh:201
Sensor(SensorCategory _cat)
Constructor.
ignition::math::Pose3d pose
Pose of the sensor.
Definition Sensor.hh:207
double UpdateRate() const
Get the update rate of the sensor.
common::Time lastMeasurementTime
Stores last time that a sensor measurement was generated; this value must be updated within each sens...
Definition Sensor.hh:239
std::string ScopedName() const
Get fully scoped name of the sensor.
virtual void Fini()
Finalize the sensor.
std::vector< event::ConnectionPtr > connections
All event connections.
Definition Sensor.hh:210
virtual void Init()
Initialize the sensor.
std::string WorldName() const
Returns the name of the world the sensor is in.
std::string Name() const
Get name.
virtual ignition::math::Pose3d Pose() const
Get the current pose.
virtual ~Sensor()
Destructor.
uint32_t ParentId() const
Get the sensor's parent's ID.
void Update(const bool _force)
Update the sensor.
virtual void Load(const std::string &_worldName, sdf::ElementPtr _sdf)
Load the sensor with SDF parameters.
virtual void Load(const std::string &_worldName)
Load the sensor with default parameters.
transport::NodePtr node
Node for communication.
Definition Sensor.hh:213
bool Visualize() const
Return true if user requests the sensor to be visualized via tag: <visualize>true</visualize> in SDF.
ignition::transport::Node nodeIgn
Ignition transport node.
Definition Sensor.hh:245
common::Time LastUpdateTime() const
Return last update time.
virtual bool IsActive() const
Returns true if sensor generation is active.
virtual std::string Topic() const
Returns the topic name as set in SDF.
common::Time updatePeriod
Desired time between updates, set indirectly by Sensor::SetUpdateRate.
Definition Sensor.hh:232
void FillMsg(msgs::Sensor &_msg)
fills a msgs::Sensor message.
bool NeedsUpdate()
Return true if the sensor needs to be updated.
virtual void SetPose(const ignition::math::Pose3d &_pose)
Set the current pose.
void SetParent(const std::string &_name, const uint32_t _id)
Set the sensor's parent.
std::string Type() const
Get sensor type.
std::string parentName
Name of the parent.
Definition Sensor.hh:216
std::map< SensorNoiseType, NoisePtr > noises
Noise added to sensor data.
Definition Sensor.hh:242
common::Time LastMeasurementTime() const
Return last measurement time.
virtual void SetActive(const bool _value)
Set whether the sensor is active or not.
sdf::ElementPtr sdf
Pointer the the SDF element for the sensor.
Definition Sensor.hh:204
common::Time lastUpdateTime
Time of the last update.
Definition Sensor.hh:235
uint32_t parentId
The sensor's parent ID.
Definition Sensor.hh:219
void SetUpdateRate(const double _hz)
Set the update rate of the sensor.
std::string ParentName() const
Returns the name of the sensor parent.
gazebo::physics::WorldPtr world
Pointer to the world.
Definition Sensor.hh:225
void ResetLastUpdateTime()
Reset the lastUpdateTime to zero.
gazebo::rendering::ScenePtr scene
Pointer to the Scene.
Definition Sensor.hh:228
SensorCategory Category() const
Get the category of the sensor.
event::ConnectionPtr ConnectUpdated(std::function< void()> _subscriber)
Connect a signal that is triggered when the sensor is updated.
uint32_t Id() const
Get the sensor's ID.
std::vector< SensorPluginPtr > plugins
All the plugins for the sensor.
Definition Sensor.hh:222
NoisePtr Noise(const SensorNoiseType _type) const
Get the sensor's noise model for a specified noise type.
virtual bool UpdateImpl(const bool)
This gets overwritten by derived sensor types.
Definition Sensor.hh:190
boost::shared_ptr< Connection > ConnectionPtr
Definition CommonTypes.hh:134
boost::shared_ptr< World > WorldPtr
Definition PhysicsTypes.hh:89
boost::shared_ptr< Scene > ScenePtr
Definition RenderTypes.hh:82
SensorCategory
SensorCategory is used to categorize sensors.
Definition SensorTypes.hh:309
std::shared_ptr< Noise > NoisePtr
Definition SensorTypes.hh:124
SensorNoiseType
Definition SensorTypes.hh:209
boost::shared_ptr< Node > NodePtr
Definition TransportTypes.hh:57
Forward declarations for the common classes.
Definition Animation.hh:27