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/sdf_config.h"
27 #include "sdf/system_util.hh"
28 
29 namespace sdf
30 {
31  // Inline bracket to help doxygen filtering.
32  inline namespace SDF_VERSION_NAMESPACE {
33  //
34 
35  // Forward declarations.
36  class AirPressure;
37  class Altimeter;
38  class Camera;
39  class ForceTorque;
40  class Imu;
41  class Lidar;
42  class Magnetometer;
43  class NavSat;
44  class SensorPrivate;
45  struct PoseRelativeToGraph;
46 
49  // Developer note: Make sure to update sensorTypeStrs in the source file
50  // when changing this enum.
51  enum class SensorType
52  {
54  NONE = 0,
55 
57  ALTIMETER = 1,
58 
60  CAMERA = 2,
61 
63  CONTACT = 3,
64 
66  DEPTH_CAMERA = 4,
67 
69  FORCE_TORQUE = 5,
70 
72  GPS = 6,
73 
75  GPU_LIDAR = 7,
76 
78  IMU = 8,
79 
81  LOGICAL_CAMERA = 9,
82 
84  MAGNETOMETER = 10,
85 
87  MULTICAMERA = 11,
88 
90  LIDAR = 12,
91 
93  RFID = 13,
94 
96  RFIDTAG = 14,
97 
99  SONAR = 15,
100 
102  WIRELESS_RECEIVER = 16,
103 
106 
108  AIR_PRESSURE = 18,
109 
112  RGBD_CAMERA = 19,
113 
115  THERMAL_CAMERA = 20,
116 
118  NAVSAT = 21
119  };
120 
123  {
125  public: Sensor();
126 
129  public: Sensor(const Sensor &_sensor);
130 
133  public: Sensor(Sensor &&_sensor) noexcept;
134 
136  public: ~Sensor();
137 
144  public: Errors Load(ElementPtr _sdf);
145 
149  public: std::string Name() const;
150 
154  public: void SetName(const std::string &_name);
155 
158  public: std::string Topic() const;
159 
162  public: void SetTopic(const std::string &_topic);
163 
166  public: bool EnableMetrics() const;
167 
170  public: void SetEnableMetrics(bool _enableMetrics);
171 
178  public: const ignition::math::Pose3d &Pose() const
179  SDF_DEPRECATED(9.0);
180 
185  public: void SetPose(const ignition::math::Pose3d &_pose)
186  SDF_DEPRECATED(9.0);
187 
193  public: const ignition::math::Pose3d &RawPose() const;
194 
198  public: void SetRawPose(const ignition::math::Pose3d &_pose);
199 
204  public: const std::string &PoseRelativeTo() const;
205 
210  public: void SetPoseRelativeTo(const std::string &_frame);
211 
217  public: const std::string &PoseFrame() const
218  SDF_DEPRECATED(9.0);
219 
225  public: void SetPoseFrame(const std::string &_frame)
226  SDF_DEPRECATED(9.0);
227 
231  public: sdf::SemanticPose SemanticPose() const;
232 
237  public: sdf::ElementPtr Element() const;
238 
241  public: SensorType Type() const;
242 
245  public: void SetType(const SensorType _type);
246 
253  public: bool SetType(const std::string &_typeStr);
254 
257  public: std::string TypeStr() const;
258 
263  public: double UpdateRate() const;
264 
269  public: void SetUpdateRate(double _hz);
270 
274  public: Sensor &operator=(const Sensor &_sensor);
275 
279  public: Sensor &operator=(Sensor &&_sensor);
280 
284  public: bool operator==(const Sensor &_sensor) const;
285 
290  public: bool operator!=(const Sensor &_sensor) const;
291 
297  public: const Magnetometer *MagnetometerSensor() const;
298 
301  public: void SetMagnetometerSensor(const Magnetometer &_mag);
302 
308  public: const Altimeter *AltimeterSensor() const;
309 
312  public: void SetAltimeterSensor(const Altimeter &_alt);
313 
319  public: const AirPressure *AirPressureSensor() const;
320 
323  public: void SetAirPressureSensor(const AirPressure &_air);
324 
327  public: void SetCameraSensor(const Camera &_cam);
328 
334  public: const Camera *CameraSensor() const;
335 
338  public: void SetForceTorqueSensor(const ForceTorque &_ft);
339 
345  public: const ForceTorque *ForceTorqueSensor() const;
346 
349  public: void SetNavSatSensor(const NavSat &_navsat);
350 
356  public: const NavSat *NavSatSensor() const;
357 
360  public: void SetImuSensor(const Imu &_imu);
361 
367  public: const Imu *ImuSensor() const;
368 
374  public: const Lidar *LidarSensor() const;
375 
378  public: void SetLidarSensor(const Lidar &_lidar);
379 
384  private: void SetXmlParentName(const std::string &_xmlParentName);
385 
390  private: void SetPoseRelativeToGraph(
391  std::weak_ptr<const PoseRelativeToGraph> _graph);
392 
396  friend class Link;
397 
399  private: SensorPrivate *dataPtr = nullptr;
400  };
401  }
402 }
403 #endif
sdf::v9::SensorType::WIRELESS_TRANSMITTER
@ WIRELESS_TRANSMITTER
A wireless transmitter.
sdf::v9::SensorType::ALTIMETER
@ ALTIMETER
An altimeter sensor.
sdf::v9::SensorType::IMU
@ IMU
An IMU sensor.
sdf::v9::SensorType::GPS
@ GPS
A GPS sensor.
sdf::v9::AirPressure
AirPressure contains information about a general purpose fluid pressure sensor.
Definition: AirPressure.hh:35
sdf::v9::SensorType::RFID
@ RFID
An RFID sensor.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
sdf::v9::SensorType::SONAR
@ SONAR
A sonar tag sensor.
sdf::v9::SensorType::GPU_LIDAR
@ GPU_LIDAR
A GPU based lidar sensor.
sdf::v9::ForceTorque
ForceTorque contains information about a force torque sensor.
Definition: ForceTorque.hh:66
sdf::v9::SensorType::CAMERA
@ CAMERA
A monocular camera sensor.
sdf::v9::SensorType::CONTACT
@ CONTACT
A contact sensor.
sdf::v9::SensorType::RFIDTAG
@ RFIDTAG
An RFID tag.
sdf::v9::Imu
Imu contains information about an imu sensor.
Definition: Imu.hh:35
Types.hh
SemanticPose.hh
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
sdf::v9::SensorType
SensorType
Definition: Sensor.hh:51
sdf::v9::SensorType::AIR_PRESSURE
@ AIR_PRESSURE
An air pressure sensor.
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::v9::SensorType::MAGNETOMETER
@ MAGNETOMETER
A magnetometer sensor.
sdf::v9::SDF_DEPRECATED
class SDFORMAT_VISIBLE SDF_DEPRECATED(9.2) URDF2SDF
URDF to SDF converter.
Definition: parser_urdf.hh:40
sdf::v9::SensorType::LOGICAL_CAMERA
@ LOGICAL_CAMERA
A logical camera sensor.
sdf::v9::SensorType::NAVSAT
@ NAVSAT
A NavSat sensor, such as GPS.
sdf::v9::Camera
Information about a monocular camera sensor.
Definition: Camera.hh:63
sdf::v9::SensorType::DEPTH_CAMERA
@ DEPTH_CAMERA
A depth camera sensor.
sdf::v9::NavSat
NavSat contains information about a NavSat sensor.
Definition: NavSat.hh:76
sdf::v9::SensorType::THERMAL_CAMERA
@ THERMAL_CAMERA
A thermal camera sensor.
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::v9::SensorType::RGBD_CAMERA
@ RGBD_CAMERA
An RGBD sensor, which produces both a color image and a depth image.
sdf::v9::Sensor
Information about an SDF sensor.
Definition: Sensor.hh:122
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::SensorType::WIRELESS_RECEIVER
@ WIRELESS_RECEIVER
A wireless receiver.
sdf::v9::Lidar
Lidar contains information about a Lidar sensor.
Definition: Lidar.hh:104
system_util.hh
sdf::v9::SensorType::MULTICAMERA
@ MULTICAMERA
A multicamera sensor.
sdf::v9::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
sdf::v9::SensorType::LIDAR
@ LIDAR
A CPU based lidar sensor.
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::v9::SensorType::FORCE_TORQUE
@ FORCE_TORQUE
A force-torque sensor.
Element.hh
sdf::v9::ErrorCode::NONE
@ NONE