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/math/Pose3.hh>
36 #include <gz/sensors/config.hh>
37 #include <gz/sensors/Export.hh>
45 inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
59 class IGNITION_SENSORS_VISIBLE
Sensor
70 public:
virtual bool Load(
const sdf::Sensor &_sdf);
75 public:
virtual bool Load(sdf::ElementPtr _sdf);
81 public:
virtual bool Init();
96 public:
virtual bool Update(
97 const std::chrono::steady_clock::duration &_now) = 0;
100 public: std::chrono::steady_clock::duration NextDataUpdateTime()
const;
116 const std::chrono::steady_clock::duration &_now,
const bool _force);
123 public:
double UpdateRate()
const;
129 public:
void SetUpdateRate(
const double _hz);
133 public: gz::math::Pose3d Pose()
const;
136 public:
void SetPose(
const gz::math::Pose3d &_pose);
139 public:
virtual void SetParent(
const std::string &_parent);
151 public:
void SetFrameId(
const std::string &_frameId);
164 public:
bool EnableMetrics()
const;
168 public:
void SetEnableMetrics(
bool _enableMetrics);
181 public: sdf::ElementPtr SDF()
const;
201 public:
void AddSequence(gz::msgs::Header *_msg,
207 public:
void PublishMetrics(
213 public:
bool IsActive()
const;
221 public:
void SetActive(
bool _active);
223 IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
227 IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
bool IsActive() const
Get whether the sensor is enabled or not.
gz::math::Pose3d Pose() const
Get the current pose.
Definition: gz/sensors/AirPressureSensor.hh:31
void SetActive(bool _active)
Enable or disable the sensor. Disabled sensors will not generate or publish data unless Update is cal...
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().
std::chrono::steady_clock::duration NextDataUpdateTime() const
Return the next time the sensor will generate data.
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.
void SetPose(const gz::math::Pose3d &_pose)
Update the pose of the sensor.
virtual bool Update(const std::chrono::steady_clock::duration &_now)=0
Force the sensor to generate data.
void SetFrameId(const std::string &_frameId)
Set Frame ID of the sensor.
const SensorId NO_SENSOR
Definition: gz/sensors/Sensor.hh:49
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 This will set the next update time to zero. This is particularly usef...
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:59
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