Loading...
Searching...
No Matches
Sensor.hh
Go to the documentation of this file.
1/*
2 * Copyright 2018 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 SDF_SENSOR_HH_
18#define SDF_SENSOR_HH_
19
20#include <memory>
21#include <string>
22#include <ignition/math/Pose3.hh>
23#include "sdf/Element.hh"
24#include "sdf/SemanticPose.hh"
25#include "sdf/Types.hh"
26#include "sdf/system_util.hh"
27
28namespace sdf
29{
30 // Inline bracket to help doxygen filtering.
31 inline namespace SDF_VERSION_NAMESPACE {
32 //
33
34 // Forward declarations.
35 class AirPressure;
36 class Altimeter;
37 class Camera;
38 class ForceTorque;
39 class Imu;
40 class Lidar;
41 class Magnetometer;
42 class NavSat;
43 class SensorPrivate;
44 struct PoseRelativeToGraph;
45
48 // Developer note: Make sure to update sensorTypeStrs in the source file
49 // when changing this enum.
50 enum class SensorType
51 {
53 NONE = 0,
54
56 ALTIMETER = 1,
57
59 CAMERA = 2,
60
62 CONTACT = 3,
63
65 DEPTH_CAMERA = 4,
66
68 FORCE_TORQUE = 5,
69
71 GPS = 6,
72
74 GPU_LIDAR = 7,
75
77 IMU = 8,
78
81
83 MAGNETOMETER = 10,
84
86 MULTICAMERA = 11,
87
89 LIDAR = 12,
90
92 RFID = 13,
93
95 RFIDTAG = 14,
96
98 SONAR = 15,
99
102
105
107 AIR_PRESSURE = 18,
108
111 RGBD_CAMERA = 19,
112
114 THERMAL_CAMERA = 20,
115
117 NAVSAT = 21
118 };
119
122 {
124 public: Sensor();
125
128 public: Sensor(const Sensor &_sensor);
129
132 public: Sensor(Sensor &&_sensor) noexcept;
133
135 public: ~Sensor();
136
143 public: Errors Load(ElementPtr _sdf);
144
148 public: std::string Name() const;
149
153 public: void SetName(const std::string &_name);
154
157 public: std::string Topic() const;
158
161 public: void SetTopic(const std::string &_topic);
162
165 public: bool EnableMetrics() const;
166
169 public: void SetEnableMetrics(bool _enableMetrics);
170
177 public: const ignition::math::Pose3d &Pose() const
178 SDF_DEPRECATED(9.0);
179
184 public: void SetPose(const ignition::math::Pose3d &_pose)
185 SDF_DEPRECATED(9.0);
186
192 public: const ignition::math::Pose3d &RawPose() const;
193
197 public: void SetRawPose(const ignition::math::Pose3d &_pose);
198
203 public: const std::string &PoseRelativeTo() const;
204
209 public: void SetPoseRelativeTo(const std::string &_frame);
210
216 public: const std::string &PoseFrame() const
217 SDF_DEPRECATED(9.0);
218
224 public: void SetPoseFrame(const std::string &_frame)
225 SDF_DEPRECATED(9.0);
226
230 public: sdf::SemanticPose SemanticPose() const;
231
236 public: sdf::ElementPtr Element() const;
237
240 public: SensorType Type() const;
241
244 public: void SetType(const SensorType _type);
245
252 public: bool SetType(const std::string &_typeStr);
253
256 public: std::string TypeStr() const;
257
262 public: double UpdateRate() const;
263
268 public: void SetUpdateRate(double _hz);
269
273 public: Sensor &operator=(const Sensor &_sensor);
274
278 public: Sensor &operator=(Sensor &&_sensor);
279
283 public: bool operator==(const Sensor &_sensor) const;
284
289 public: bool operator!=(const Sensor &_sensor) const;
290
296 public: const Magnetometer *MagnetometerSensor() const;
297
300 public: void SetMagnetometerSensor(const Magnetometer &_mag);
301
307 public: const Altimeter *AltimeterSensor() const;
308
311 public: void SetAltimeterSensor(const Altimeter &_alt);
312
318 public: const AirPressure *AirPressureSensor() const;
319
322 public: void SetAirPressureSensor(const AirPressure &_air);
323
326 public: void SetCameraSensor(const Camera &_cam);
327
333 public: const Camera *CameraSensor() const;
334
337 public: void SetForceTorqueSensor(const ForceTorque &_ft);
338
344 public: const ForceTorque *ForceTorqueSensor() const;
345
348 public: void SetNavSatSensor(const NavSat &_navsat);
349
355 public: const NavSat *NavSatSensor() const;
356
359 public: void SetImuSensor(const Imu &_imu);
360
366 public: const Imu *ImuSensor() const;
367
373 public: const Lidar *LidarSensor() const;
374
377 public: void SetLidarSensor(const Lidar &_lidar);
378
383 private: void SetXmlParentName(const std::string &_xmlParentName);
384
389 private: void SetPoseRelativeToGraph(
390 std::weak_ptr<const PoseRelativeToGraph> _graph);
391
395 friend class Link;
396
398 private: SensorPrivate *dataPtr = nullptr;
399 };
400 }
401}
402#endif
#define SDF_DEPRECATED(version)
Definition Types.hh:38
Information about an SDF sensor.
Definition Sensor.hh:122
Sensor(Sensor &&_sensor) noexcept
Move constructor.
void SetName(const std::string &_name)
Set the name of the sensor.
void SetEnableMetrics(bool _enableMetrics)
Set flag to enable publishing performance metrics.
bool EnableMetrics() const
Get flag state for enabling performance metrics publication.
const ignition::math::Pose3d & Pose() const SDF_DEPRECATED(9.0)
Get the pose of the sensor.
std::string Name() const
Get the name of the sensor.
Sensor(const Sensor &_sensor)
Copy constructor.
void SetTopic(const std::string &_topic)
Set the topic on which sensor data should be published.
std::string Topic() const
Get the topic on which sensor data should be published.
Errors Load(ElementPtr _sdf)
Load the sensor based on a element pointer.
Sensor()
Default constructor.
AirPressure contains information about a general purpose fluid pressure sensor.
Definition AirPressure.hh:36
Altimeter contains information about an altimeter sensor.
Definition Altimeter.hh:35
Information about a monocular camera sensor.
Definition Camera.hh:64
SDF Element class.
Definition Element.hh:74
ForceTorque contains information about a force torque sensor.
Definition ForceTorque.hh:67
Imu contains information about an imu sensor.
Definition Imu.hh:36
Lidar contains information about a Lidar sensor.
Definition Lidar.hh:105
Magnetometer contains information about a magnetometer sensor.
Definition Magnetometer.hh:35
NavSat contains information about a NavSat sensor.
Definition NavSat.hh:77
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition SemanticPose.hh:54
SensorType
The set of sensor types.
Definition Sensor.hh:51
@ WIRELESS_TRANSMITTER
A wireless transmitter.
@ GPU_LIDAR
A GPU based lidar sensor.
@ NAVSAT
A NavSat sensor, such as GPS.
@ LOGICAL_CAMERA
A logical camera sensor.
@ WIRELESS_RECEIVER
A wireless receiver.
@ AIR_PRESSURE
An air pressure sensor.
@ THERMAL_CAMERA
A thermal camera sensor.
@ RGBD_CAMERA
An RGBD sensor, which produces both a color image and a depth image.
@ FORCE_TORQUE
A force-torque sensor.
@ NONE
An unspecified sensor type.
@ MULTICAMERA
A multicamera sensor.
@ MAGNETOMETER
A magnetometer sensor.
@ LIDAR
A CPU based lidar sensor.
@ CAMERA
A monocular camera sensor.
@ DEPTH_CAMERA
A depth camera sensor.
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:89
std::shared_ptr< Element > ElementPtr
Definition Element.hh:53
namespace for Simulation Description Format parser
Definition Actor.hh:33
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:48