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 
28 namespace 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 Imu;
39  class Lidar;
40  class Magnetometer;
41  class NavSat;
42  class SensorPrivate;
43  struct PoseRelativeToGraph;
44 
47  // Developer note: Make sure to update sensorTypeStrs in the source file
48  // when changing this enum.
49  enum class SensorType
50  {
52  NONE = 0,
53 
55  ALTIMETER = 1,
56 
58  CAMERA = 2,
59 
61  CONTACT = 3,
62 
64  DEPTH_CAMERA = 4,
65 
67  FORCE_TORQUE = 5,
68 
70  GPS = 6,
71 
73  GPU_LIDAR = 7,
74 
76  IMU = 8,
77 
79  LOGICAL_CAMERA = 9,
80 
82  MAGNETOMETER = 10,
83 
85  MULTICAMERA = 11,
86 
88  LIDAR = 12,
89 
91  RFID = 13,
92 
94  RFIDTAG = 14,
95 
97  SONAR = 15,
98 
100  WIRELESS_RECEIVER = 16,
101 
104 
106  AIR_PRESSURE = 18,
107 
110  RGBD_CAMERA = 19,
111 
113  THERMAL_CAMERA = 20,
114 
116  NAVSAT = 21
117  };
118 
121  {
123  public: Sensor();
124 
127  public: Sensor(const Sensor &_sensor);
128 
131  public: Sensor(Sensor &&_sensor) noexcept;
132 
134  public: ~Sensor();
135 
142  public: Errors Load(ElementPtr _sdf);
143 
147  public: std::string Name() const;
148 
152  public: void SetName(const std::string &_name);
153 
156  public: std::string Topic() const;
157 
160  public: void SetTopic(const std::string &_topic);
161 
164  public: bool EnableMetrics() const;
165 
168  public: void SetEnableMetrics(bool _enableMetrics);
169 
176  public: const ignition::math::Pose3d &Pose() const
177  SDF_DEPRECATED(9.0);
178 
183  public: void SetPose(const ignition::math::Pose3d &_pose)
184  SDF_DEPRECATED(9.0);
185 
191  public: const ignition::math::Pose3d &RawPose() const;
192 
196  public: void SetRawPose(const ignition::math::Pose3d &_pose);
197 
202  public: const std::string &PoseRelativeTo() const;
203 
208  public: void SetPoseRelativeTo(const std::string &_frame);
209 
215  public: const std::string &PoseFrame() const
216  SDF_DEPRECATED(9.0);
217 
223  public: void SetPoseFrame(const std::string &_frame)
224  SDF_DEPRECATED(9.0);
225 
229  public: sdf::SemanticPose SemanticPose() const;
230 
235  public: sdf::ElementPtr Element() const;
236 
239  public: SensorType Type() const;
240 
243  public: void SetType(const SensorType _type);
244 
251  public: bool SetType(const std::string &_typeStr);
252 
255  public: std::string TypeStr() const;
256 
261  public: double UpdateRate() const;
262 
267  public: void SetUpdateRate(double _hz);
268 
272  public: Sensor &operator=(const Sensor &_sensor);
273 
277  public: Sensor &operator=(Sensor &&_sensor);
278 
282  public: bool operator==(const Sensor &_sensor) const;
283 
288  public: bool operator!=(const Sensor &_sensor) const;
289 
295  public: const Magnetometer *MagnetometerSensor() const;
296 
299  public: void SetMagnetometerSensor(const Magnetometer &_mag);
300 
306  public: const Altimeter *AltimeterSensor() const;
307 
310  public: void SetAltimeterSensor(const Altimeter &_alt);
311 
317  public: const AirPressure *AirPressureSensor() const;
318 
321  public: void SetAirPressureSensor(const AirPressure &_air);
322 
325  public: void SetCameraSensor(const Camera &_cam);
326 
332  public: const Camera *CameraSensor() const;
333 
336  public: void SetNavSatSensor(const NavSat &_navsat);
337 
343  public: const NavSat *NavSatSensor() const;
344 
347  public: void SetImuSensor(const Imu &_imu);
348 
354  public: const Imu *ImuSensor() const;
355 
361  public: const Lidar *LidarSensor() const;
362 
365  public: void SetLidarSensor(const Lidar &_lidar);
366 
371  private: void SetXmlParentName(const std::string &_xmlParentName);
372 
377  private: void SetPoseRelativeToGraph(
378  std::weak_ptr<const PoseRelativeToGraph> _graph);
379 
383  friend class Link;
384 
386  private: SensorPrivate *dataPtr = nullptr;
387  };
388  }
389 }
390 #endif
sdf::SDF_VERSION_NAMESPACE::SensorType::GPU_LIDAR
@ GPU_LIDAR
A GPU based lidar sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::THERMAL_CAMERA
@ THERMAL_CAMERA
A thermal camera sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::MAGNETOMETER
@ MAGNETOMETER
A magnetometer sensor.
sdf::v9::AirPressure
AirPressure contains information about a general purpose fluid pressure sensor.
Definition: AirPressure.hh:35
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
sdf::SDF_VERSION_NAMESPACE::SensorType::MULTICAMERA
@ MULTICAMERA
A multicamera sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::AIR_PRESSURE
@ AIR_PRESSURE
An air pressure sensor.
sdf::v9::Imu
Imu contains information about an imu sensor.
Definition: Imu.hh:35
sdf::SDF_VERSION_NAMESPACE::SensorType::NAVSAT
@ NAVSAT
A NavSat sensor, such as GPS.
Types.hh
sdf::SDF_VERSION_NAMESPACE::SensorType::CAMERA
@ CAMERA
A monocular camera sensor.
SemanticPose.hh
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
sdf::SDF_VERSION_NAMESPACE::SensorType::DEPTH_CAMERA
@ DEPTH_CAMERA
A depth camera sensor.
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::SDF_VERSION_NAMESPACE::SensorType::GPS
@ GPS
A GPS sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::WIRELESS_RECEIVER
@ WIRELESS_RECEIVER
A wireless receiver.
sdf::SDF_VERSION_NAMESPACE::SensorType::RFIDTAG
@ RFIDTAG
An RFID tag.
sdf::v9::SDF_DEPRECATED
class SDFORMAT_VISIBLE SDF_DEPRECATED(9.2) URDF2SDF
URDF to SDF converter.
Definition: parser_urdf.hh:40
sdf::SDF_VERSION_NAMESPACE::SensorType::FORCE_TORQUE
@ FORCE_TORQUE
A force-torque sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::RFID
@ RFID
An RFID sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType
SensorType
Definition: Sensor.hh:49
sdf::SDF_VERSION_NAMESPACE::SensorType::IMU
@ IMU
An IMU sensor.
sdf::v9::Camera
Information about a monocular camera sensor.
Definition: Camera.hh:63
sdf::SDF_VERSION_NAMESPACE::SensorType::SONAR
@ SONAR
A sonar tag sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::LIDAR
@ LIDAR
A CPU based lidar sensor.
sdf::v9::NavSat
NavSat contains information about a NavSat sensor.
Definition: NavSat.hh:76
sdf::v9::SemanticPose
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:53
sdf::SDF_VERSION_NAMESPACE::SensorType::LOGICAL_CAMERA
@ LOGICAL_CAMERA
A logical camera sensor.
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::SDF_VERSION_NAMESPACE::SensorType::ALTIMETER
@ ALTIMETER
An altimeter sensor.
sdf::v9::Lidar
Lidar contains information about a Lidar sensor.
Definition: Lidar.hh:104
sdf::SDF_VERSION_NAMESPACE::SensorType::RGBD_CAMERA
@ RGBD_CAMERA
An RGBD sensor, which produces both a color image and a depth image.
sdf::SDF_VERSION_NAMESPACE::SensorType::NONE
@ NONE
An unspecified sensor type.
system_util.hh
sdf::v9::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
sdf::v9::Altimeter
Altimeter contains information about an altimeter sensor.
Definition: Altimeter.hh:34
sdf::v9::Magnetometer
Magnetometer contains information about a magnetometer sensor.
Definition: Magnetometer.hh:34
sdf::SDF_VERSION_NAMESPACE::SensorType::CONTACT
@ CONTACT
A contact sensor.
sdf::SDF_VERSION_NAMESPACE::Sensor
Information about an SDF sensor.
Definition: Sensor.hh:120
Element.hh
sdf::SDF_VERSION_NAMESPACE::SensorType::WIRELESS_TRANSMITTER
@ WIRELESS_TRANSMITTER
A wireless transmitter.