Ignition Sensors

API Reference

3.2.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 
79  public: virtual bool Init();
80 
94  public: virtual bool Update(const common::Time &_now) = 0;
95 
97  public: common::Time NextUpdateTime() const;
98 
112  public: bool Update(const common::Time &_now, const bool _force);
113 
119  public: double UpdateRate() const;
120 
125  public: void SetUpdateRate(const double _hz);
126 
129  public: ignition::math::Pose3d Pose() const;
130 
132  public: void SetPose(const ignition::math::Pose3d &_pose);
133 
135  public: virtual void SetParent(const std::string &_parent);
136 
139  public: std::string Name() const;
140 
143  public: std::string Topic() const;
144 
148  public: bool SetTopic(const std::string &_topic);
149 
152  public: bool EnableMetrics() const;
153 
156  public: void SetEnableMetrics(bool _enableMetrics);
157 
160  public: std::string Parent() const;
161 
164  public: SensorId Id() const;
165 
169  public: sdf::ElementPtr SDF() const;
170 
189  public: void AddSequence(ignition::msgs::Header *_msg,
190  const std::string &_seqKey = "default");
191 
195  public: void PublishMetrics(
196  const std::chrono::duration<double> &_now);
197 
198  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
201  private: std::unique_ptr<SensorPrivate> dataPtr;
202  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
203  };
204  }
205  }
206 }
207 
208 #endif
a base sensor class
Definition: Sensor.hh:60
STL class.
const SensorId NO_SENSOR
Definition: Sensor.hh:50
Definition: AirPressureSensor.hh:32