Ignition Sensors

API Reference

3.1.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 #include <ignition/msgs/header.pb.h>
21 
22 #include <memory>
23 #include <string>
24 
25 #include <ignition/common/Time.hh>
26 #include <ignition/math/Pose3.hh>
27 #include <ignition/sensors/config.hh>
28 #include <ignition/sensors/Export.hh>
29 #include <sdf/sdf.hh>
30 
31 namespace ignition
32 {
33  namespace sensors
34  {
35  // Inline bracket to help doxygen filtering.
36  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
37  //
40  const SensorId NO_SENSOR = 0;
41 
43  class SensorPrivate;
44 
50  class IGNITION_SENSORS_VISIBLE Sensor
51  {
53  protected: Sensor();
54 
56  public: virtual ~Sensor();
57 
61  public: virtual bool Load(const sdf::Sensor &_sdf);
62 
66  public: virtual bool Load(sdf::ElementPtr _sdf);
67 
69  public: virtual bool Init();
70 
84  public: virtual bool Update(const common::Time &_now) = 0;
85 
87  public: common::Time NextUpdateTime() const;
88 
102  public: bool Update(const common::Time &_now, const bool _force);
103 
109  public: double UpdateRate() const;
110 
115  public: void SetUpdateRate(const double _hz);
116 
119  public: ignition::math::Pose3d Pose() const;
120 
122  public: void SetPose(const ignition::math::Pose3d &_pose);
123 
125  public: virtual void SetParent(const std::string &_parent);
126 
129  public: std::string Name() const;
130 
133  public: std::string Topic() const;
134 
138  public: bool SetTopic(const std::string &_topic);
139 
142  public: std::string Parent() const;
143 
146  public: SensorId Id() const;
147 
151  public: sdf::ElementPtr SDF() const;
152 
171  public: void AddSequence(ignition::msgs::Header *_msg,
172  const std::string &_seqKey = "default");
173 
176  private: std::unique_ptr<SensorPrivate> dataPtr;
177  };
178  }
179  }
180 }
181 
182 #endif
a base sensor class
Definition: Sensor.hh:50
STL class.
const SensorId NO_SENSOR
Definition: Sensor.hh:40
Definition: AirPressureSensor.hh:31