Ignition Sensors

API Reference

5.0.0
Sensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_SENSORS_SENSOR_HH_
18 #define IGNITION_SENSORS_SENSOR_HH_
19 
20 #ifdef _WIN32
21 #pragma warning(push)
22 #pragma warning(disable: 4005)
23 #pragma warning(disable: 4251)
24 #endif
25 #include <ignition/msgs/header.pb.h>
26 #ifdef _WIN32
27 #pragma warning(pop)
28 #endif
29 
30 #include <chrono>
31 #include <memory>
32 #include <string>
33 
34 #include <ignition/common/SuppressWarning.hh>
35 #include <ignition/common/Time.hh>
36 #include <ignition/math/Pose3.hh>
37 #include <ignition/sensors/config.hh>
38 #include <ignition/sensors/Export.hh>
39 #include <sdf/sdf.hh>
40 
41 namespace ignition
42 {
43  namespace sensors
44  {
45  // Inline bracket to help doxygen filtering.
46  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
47  //
50  const SensorId NO_SENSOR = 0;
51 
53  class SensorPrivate;
54 
60  class IGNITION_SENSORS_VISIBLE Sensor
61  {
63  protected: Sensor();
64 
66  public: virtual ~Sensor();
67 
71  public: virtual bool Load(const sdf::Sensor &_sdf);
72 
76  public: virtual bool Load(sdf::ElementPtr _sdf);
77 
82  public: virtual bool Init();
83 
97  public:
98  virtual bool IGN_DEPRECATED(4) Update(const common::Time &_now) = 0;
99 
113  public: virtual bool Update(
114  const std::chrono::steady_clock::duration &_now) = 0;
115 
117  public: ignition::common::Time IGN_DEPRECATED(4) NextUpdateTime() const;
118 
120  public: std::chrono::steady_clock::duration NextDataUpdateTime() const;
121 
136  public: bool IGN_DEPRECATED(4)
137  Update(const ignition::common::Time &_now, const bool _force);
138 
153  public: bool Update(
154  const std::chrono::steady_clock::duration &_now, const bool _force);
155 
161  public: double UpdateRate() const;
162 
167  public: void SetUpdateRate(const double _hz);
168 
171  public: ignition::math::Pose3d Pose() const;
172 
174  public: void SetPose(const ignition::math::Pose3d &_pose);
175 
177  public: virtual void SetParent(const std::string &_parent);
178 
181  public: std::string Name() const;
182 
185  public: std::string Topic() const;
186 
190  public: bool SetTopic(const std::string &_topic);
191 
194  public: bool EnableMetrics() const;
195 
198  public: void SetEnableMetrics(bool _enableMetrics);
199 
202  public: std::string Parent() const;
203 
206  public: SensorId Id() const;
207 
211  public: sdf::ElementPtr SDF() const;
212 
231  public: void AddSequence(ignition::msgs::Header *_msg,
232  const std::string &_seqKey = "default");
233 
237  public: void PublishMetrics(
238  const std::chrono::duration<double> &_now);
239 
240  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
243  private: std::unique_ptr<SensorPrivate> dataPtr;
244  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
245  };
246  }
247  }
248 }
249 
250 #endif
a base sensor class
Definition: Sensor.hh:60
STL class.
const SensorId NO_SENSOR
Definition: Sensor.hh:50
Definition: AirPressureSensor.hh:32