Go to the documentation of this file.
17 #ifndef GZ_SENSORS_SENSOR_HH_
18 #define GZ_SENSORS_SENSOR_HH_
22 #pragma warning(disable: 4005)
23 #pragma warning(disable: 4251)
25 #include <gz/msgs/header.pb.h>
34 #include <gz/common/SuppressWarning.hh>
35 #include <gz/common/Time.hh>
36 #include <gz/math/Pose3.hh>
37 #include <gz/sensors/config.hh>
38 #include <gz/sensors/Export.hh>
46 inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
60 class IGNITION_SENSORS_VISIBLE
Sensor
71 public:
virtual bool Load(
const sdf::Sensor &_sdf);
76 public:
virtual bool Load(sdf::ElementPtr _sdf);
79 public:
virtual bool Init();
94 public:
virtual bool Update(
const common::Time &_now) = 0;
97 public: common::Time NextUpdateTime()
const;
112 public:
bool Update(
const common::Time &_now,
const bool _force);
119 public:
double UpdateRate()
const;
125 public:
void SetUpdateRate(
const double _hz);
129 public: gz::math::Pose3d Pose()
const;
132 public:
void SetPose(
const gz::math::Pose3d &_pose);
135 public:
virtual void SetParent(
const std::string &_parent);
147 public:
void SetFrameId(
const std::string &_frameId);
160 public:
bool EnableMetrics()
const;
164 public:
void SetEnableMetrics(
bool _enableMetrics);
177 public: sdf::ElementPtr SDF()
const;
197 public:
void AddSequence(gz::msgs::Header *_msg,
203 public:
void PublishMetrics(
206 IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
210 IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
gz::math::Pose3d Pose() const
Get the current pose.
Definition: gz/sensors/AirPressureSensor.hh:32
double UpdateRate() const
Get the update rate of the sensor.
void SetEnableMetrics(bool _enableMetrics)
Set flag to enable publishing performance metrics.
std::string FrameId() const
FrameId.
void PublishMetrics(const std::chrono::duration< double > &_now)
Publishes information about the performance of the sensor. This method is called by Update().
sdf::ElementPtr SDF() const
Get the SDF used to load this sensor.
virtual void SetParent(const std::string &_parent)
Set the parent of the sensor.
virtual bool Update(const common::Time &_now)=0
Force the sensor to generate data.
void SetPose(const gz::math::Pose3d &_pose)
Update the pose of the sensor.
void SetFrameId(const std::string &_frameId)
Set Frame ID of the sensor.
const SensorId NO_SENSOR
Definition: gz/sensors/Sensor.hh:50
common::Time NextUpdateTime() const
Return the next time the sensor will generate data.
std::string Parent() const
Get parent link of the sensor.
virtual bool Load(const sdf::Sensor &_sdf)
Load the sensor based on data from an sdf::Sensor object.
bool SetTopic(const std::string &_topic)
Set topic where sensor data is published.
virtual bool Init()
Initialize values in the sensor.
std::string Topic() const
Get topic where sensor data is published.
std::string Name() const
Get name.
bool EnableMetrics() const
Get flag state for enabling performance metrics publication.
void SetUpdateRate(const double _hz)
Set the update rate of the sensor. An update rate of zero means that the sensor is updated every cycl...
a base sensor class
Definition: gz/sensors/Sensor.hh:60
SensorId Id() const
Get the sensor's ID.
void AddSequence(gz::msgs::Header *_msg, const std::string &_seqKey="default")
Add a sequence number to an gz::msgs::Header. This function can be called by a sensor that wants to a...
virtual ~Sensor()
destructor