Gazebo Sensors

API Reference

9.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 GZ_SENSORS_SENSOR_HH_
18#define GZ_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 <gz/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 <gz/utils/SuppressWarning.hh>
35#include <gz/math/Pose3.hh>
36#include <gz/sensors/config.hh>
37#include <gz/sensors/Export.hh>
38#include <sdf/sdf.hh>
39
40namespace gz
41{
42 namespace sensors
43 {
44 // Inline bracket to help doxygen filtering.
45 inline namespace GZ_SENSORS_VERSION_NAMESPACE {
46 //
50
52 class SensorPrivate;
53
59 class GZ_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
107 const std::chrono::steady_clock::duration &_time);
108
122 public: bool Update(
123 const std::chrono::steady_clock::duration &_now, const bool _force);
124
130 public: double UpdateRate() const;
131
136 public: void SetUpdateRate(const double _hz);
137
140 public: gz::math::Pose3d Pose() const;
141
143 public: void SetPose(const gz::math::Pose3d &_pose);
144
146 public: virtual void SetParent(const std::string &_parent);
147
150 public: std::string Name() const;
151
154 public: std::string FrameId() const;
155
158 public: void SetFrameId(const std::string &_frameId);
159
162 public: std::string Topic() const;
163
167 public: bool SetTopic(const std::string &_topic);
168
171 public: bool EnableMetrics() const;
172
175 public: void SetEnableMetrics(bool _enableMetrics);
176
179 public: std::string Parent() const;
180
183 public: SensorId Id() const;
184
188 public: sdf::ElementPtr SDF() const;
189
208 public: void AddSequence(gz::msgs::Header *_msg,
209 const std::string &_seqKey = "default");
210
214 public: void PublishMetrics(
216
220 public: bool IsActive() const;
221
228 public: void SetActive(bool _active);
229
232 public: virtual bool HasConnections() const;
233
248 public: bool SetTriggered(bool _triggered,
249 const std::string &_triggerTopic = "");
250
254 public: bool HasPendingTrigger() const;
255
258 public: bool IsTriggered() const;
259
260 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
263 private: std::unique_ptr<SensorPrivate> dataPtr;
264 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
265 };
266 }
267 }
268}
269#endif