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 <gz/math/Pose3.hh>
23 #include <gz/utils/ImplPtr.hh>
24 #include "sdf/Element.hh"
25 #include "sdf/Plugin.hh"
26 #include "sdf/SemanticPose.hh"
27 #include "sdf/Types.hh"
28 #include "sdf/sdf_config.h"
29 #include "sdf/system_util.hh"
30 
31 namespace sdf
32 {
33  // Inline bracket to help doxygen filtering.
34  inline namespace SDF_VERSION_NAMESPACE {
35  //
36 
37  // Forward declarations.
38  class AirPressure;
39  class AirSpeed;
40  class Altimeter;
41  class Camera;
42  class ForceTorque;
43  class Imu;
44  class Lidar;
45  class Magnetometer;
46  class NavSat;
47  struct PoseRelativeToGraph;
48  template <typename T> class ScopedGraph;
49 
52  // Developer note: Make sure to update sensorTypeStrs in the source file
53  // when changing this enum.
54  enum class SensorType
55  {
57  NONE = 0,
58 
60  ALTIMETER = 1,
61 
63  CAMERA = 2,
64 
66  CONTACT = 3,
67 
69  DEPTH_CAMERA = 4,
70 
72  FORCE_TORQUE = 5,
73 
75  GPS = 6,
76 
78  GPU_LIDAR = 7,
79 
81  IMU = 8,
82 
84  LOGICAL_CAMERA = 9,
85 
87  MAGNETOMETER = 10,
88 
90  MULTICAMERA = 11,
91 
93  LIDAR = 12,
94 
96  RFID = 13,
97 
99  RFIDTAG = 14,
100 
102  SONAR = 15,
103 
105  WIRELESS_RECEIVER = 16,
106 
109 
111  AIR_PRESSURE = 18,
112 
115  RGBD_CAMERA = 19,
116 
118  THERMAL_CAMERA = 20,
119 
121  NAVSAT = 21,
122 
124  SEGMENTATION_CAMERA = 22,
125 
127  BOUNDINGBOX_CAMERA = 23,
128 
130  CUSTOM = 24,
131 
133  WIDE_ANGLE_CAMERA = 25,
134 
136  AIR_SPEED = 26,
137  };
138 
141  {
143  public: Sensor();
144 
151  public: Errors Load(ElementPtr _sdf);
152 
156  public: std::string Name() const;
157 
161  public: void SetName(const std::string &_name);
162 
165  public: std::string Topic() const;
166 
169  public: void SetTopic(const std::string &_topic);
170 
173  public: bool EnableMetrics() const;
174 
177  public: void SetEnableMetrics(bool _enableMetrics);
178 
184  public: const gz::math::Pose3d &RawPose() const;
185 
189  public: void SetRawPose(const gz::math::Pose3d &_pose);
190 
195  public: const std::string &PoseRelativeTo() const;
196 
201  public: void SetPoseRelativeTo(const std::string &_frame);
202 
206  public: sdf::SemanticPose SemanticPose() const;
207 
212  public: sdf::ElementPtr Element() const;
213 
219  public: sdf::ElementPtr ToElement() const;
220 
227  public: sdf::ElementPtr ToElement(sdf::Errors &_errors) const;
228 
231  public: SensorType Type() const;
232 
235  public: void SetType(const SensorType _type);
236 
243  public: bool SetType(const std::string &_typeStr);
244 
247  public: std::string TypeStr() const;
248 
253  public: double UpdateRate() const;
254 
259  public: void SetUpdateRate(double _hz);
260 
264  public: bool operator==(const Sensor &_sensor) const;
265 
270  public: bool operator!=(const Sensor &_sensor) const;
271 
277  public: const Magnetometer *MagnetometerSensor() const;
278 
284  public: Magnetometer *MagnetometerSensor();
285 
288  public: void SetMagnetometerSensor(const Magnetometer &_mag);
289 
295  public: const Altimeter *AltimeterSensor() const;
296 
302  public: Altimeter *AltimeterSensor();
303 
306  public: void SetAltimeterSensor(const Altimeter &_alt);
307 
313  public: const AirPressure *AirPressureSensor() const;
314 
320  public: AirPressure *AirPressureSensor();
321 
324  public: void SetAirPressureSensor(const AirPressure &_air);
325 
331  public: const AirSpeed *AirSpeedSensor() const;
332 
338  public: AirSpeed *AirSpeedSensor();
339 
342  public: void SetAirSpeedSensor(const AirSpeed &_air);
343 
346  public: void SetCameraSensor(const Camera &_cam);
347 
353  public: const Camera *CameraSensor() const;
354 
360  public: Camera *CameraSensor();
361 
364  public: void SetNavSatSensor(const NavSat &_navsat);
365 
371  public: const NavSat *NavSatSensor() const;
372 
378  public: NavSat *NavSatSensor();
379 
382  public: void SetForceTorqueSensor(const ForceTorque &_ft);
383 
389  public: const ForceTorque *ForceTorqueSensor() const;
390 
396  public: ForceTorque *ForceTorqueSensor();
397 
400  public: void SetImuSensor(const Imu &_imu);
401 
407  public: const Imu *ImuSensor() const;
408 
414  public: Imu *ImuSensor();
415 
421  public: const Lidar *LidarSensor() const;
422 
428  public: Lidar *LidarSensor();
429 
432  public: void SetLidarSensor(const Lidar &_lidar);
433 
437  public: const sdf::Plugins &Plugins() const;
438 
442  public: sdf::Plugins &Plugins();
443 
445  public: void ClearPlugins();
446 
449  public: void AddPlugin(const Plugin &_plugin);
450 
455  private: void SetXmlParentName(const std::string &_xmlParentName);
456 
461  private: void SetPoseRelativeToGraph(
463 
467  friend class Link;
471  friend class Joint;
472 
474  GZ_UTILS_IMPL_PTR(dataPtr)
475  };
476  }
477 }
478 #endif
sdf::SDF_VERSION_NAMESPACE::Camera
Information about a monocular camera sensor.
Definition: Camera.hh:60
sdf::SDF_VERSION_NAMESPACE::SensorType::SEGMENTATION_CAMERA
@ SEGMENTATION_CAMERA
A segmentation camera sensor.
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::SDF_VERSION_NAMESPACE::Imu
Imu contains information about an imu sensor.
Definition: Imu.hh:33
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::SensorType::BOUNDINGBOX_CAMERA
@ BOUNDINGBOX_CAMERA
A boundingbox camera sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::MULTICAMERA
@ MULTICAMERA
A multicamera sensor.
sdf::SDF_VERSION_NAMESPACE::NavSat
NavSat contains information about a NavSat sensor.
Definition: NavSat.hh:75
sdf::SDF_VERSION_NAMESPACE::SensorType::AIR_PRESSURE
@ AIR_PRESSURE
An air pressure sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::NAVSAT
@ NAVSAT
A NavSat sensor, such as GPS.
sdf::SDF_VERSION_NAMESPACE::AirSpeed
AirSpeed contains information about a general purpose air speed sensor.
Definition: AirSpeed.hh:34
Types.hh
sdf::SDF_VERSION_NAMESPACE::SensorType::CAMERA
@ CAMERA
A monocular camera sensor.
SemanticPose.hh
sdf_config.h
sdf::SDF_VERSION_NAMESPACE::SensorType::DEPTH_CAMERA
@ DEPTH_CAMERA
A depth camera sensor.
sdf::SDF_VERSION_NAMESPACE::Altimeter
Altimeter contains information about an altimeter sensor.
Definition: Altimeter.hh:33
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::AirPressure
AirPressure contains information about a general purpose fluid pressure sensor.
Definition: AirPressure.hh:34
sdf::SDF_VERSION_NAMESPACE::Plugin
Definition: Plugin.hh:45
sdf::SDF_VERSION_NAMESPACE::Magnetometer
Magnetometer contains information about a magnetometer sensor.
Definition: Magnetometer.hh:34
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::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::WIDE_ANGLE_CAMERA
@ WIDE_ANGLE_CAMERA
A wide angle camera sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType
SensorType
Definition: Sensor.hh:54
sdf::SDF_VERSION_NAMESPACE::Lidar
Lidar contains information about a Lidar sensor.
Definition: Lidar.hh:105
sdf::SDF_VERSION_NAMESPACE::SensorType::IMU
@ IMU
An IMU sensor.
sdf::SDF_VERSION_NAMESPACE::Joint
Definition: Joint.hh:85
sdf::SDF_VERSION_NAMESPACE::SensorType::SONAR
@ SONAR
A sonar tag sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::LIDAR
@ LIDAR
A CPU based lidar sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::AIR_SPEED
@ AIR_SPEED
An air speed sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::CUSTOM
@ CUSTOM
A custom sensor.
sdf::SDF_VERSION_NAMESPACE::Element
class GZ_SDFORMAT_VISIBLE Element
Definition: Element.hh:51
sdf::SDF_VERSION_NAMESPACE::SemanticPose
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:54
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
sdf::SDF_VERSION_NAMESPACE::SensorType::LOGICAL_CAMERA
@ LOGICAL_CAMERA
A logical camera sensor.
sdf::SDF_VERSION_NAMESPACE::ScopedGraph
Definition: Collision.hh:40
sdf::SDF_VERSION_NAMESPACE::ForceTorque
ForceTorque contains information about a force torque sensor.
Definition: ForceTorque.hh:64
sdf::SDF_VERSION_NAMESPACE::SensorType::ALTIMETER
@ ALTIMETER
An altimeter sensor.
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
Plugin.hh
sdf::SDF_VERSION_NAMESPACE::Plugins
std::vector< Plugin > Plugins
A vector of Plugin.
Definition: Plugin.hh:245
sdf::SDF_VERSION_NAMESPACE::SensorType::CONTACT
@ CONTACT
A contact sensor.
sdf::SDF_VERSION_NAMESPACE::Sensor
Information about an SDF sensor.
Definition: Sensor.hh:140
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
Element.hh
sdf::SDF_VERSION_NAMESPACE::SensorType::WIRELESS_TRANSMITTER
@ WIRELESS_TRANSMITTER
A wireless transmitter.