Ignition Sensors

API Reference

6.0.1
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/math/Pose3.hh>
36 #include <ignition/sensors/config.hh>
37 #include <ignition/sensors/Export.hh>
38 #include <sdf/sdf.hh>
39 
40 namespace ignition
41 {
42  namespace sensors
43  {
44  // Inline bracket to help doxygen filtering.
45  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
46  //
49  const SensorId NO_SENSOR = 0;
50 
52  class SensorPrivate;
53 
59  class IGNITION_SENSORS_VISIBLE Sensor
60  {
62  protected: Sensor();
63 
65  public: virtual ~Sensor();
66 
70  public: virtual bool Load(const sdf::Sensor &_sdf);
71 
75  public: virtual bool Load(sdf::ElementPtr _sdf);
76 
81  public: virtual bool Init();
82 
96  public: virtual bool Update(
97  const std::chrono::steady_clock::duration &_now) = 0;
98 
100  public: std::chrono::steady_clock::duration NextDataUpdateTime() const;
101 
115  public: bool Update(
116  const std::chrono::steady_clock::duration &_now, const bool _force);
117 
123  public: double UpdateRate() const;
124 
129  public: void SetUpdateRate(const double _hz);
130 
133  public: ignition::math::Pose3d Pose() const;
134 
136  public: void SetPose(const ignition::math::Pose3d &_pose);
137 
139  public: virtual void SetParent(const std::string &_parent);
140 
143  public: std::string Name() const;
144 
147  public: std::string Topic() const;
148 
152  public: bool SetTopic(const std::string &_topic);
153 
156  public: bool EnableMetrics() const;
157 
160  public: void SetEnableMetrics(bool _enableMetrics);
161 
164  public: std::string Parent() const;
165 
168  public: SensorId Id() const;
169 
173  public: sdf::ElementPtr SDF() const;
174 
193  public: void AddSequence(ignition::msgs::Header *_msg,
194  const std::string &_seqKey = "default");
195 
199  public: void PublishMetrics(
200  const std::chrono::duration<double> &_now);
201 
202  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
205  private: std::unique_ptr<SensorPrivate> dataPtr;
206  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
207  };
208  }
209  }
210 }
211 
212 #endif
a base sensor class
Definition: Sensor.hh:59
STL class.
const SensorId NO_SENSOR
Definition: Sensor.hh:49
Definition: AirPressureSensor.hh:31