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 <ignition/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 Altimeter;
40  class Camera;
41  class ForceTorque;
42  class Imu;
43  class Lidar;
44  class Magnetometer;
45  class NavSat;
46  struct PoseRelativeToGraph;
47  template <typename T> class ScopedGraph;
48 
51  // Developer note: Make sure to update sensorTypeStrs in the source file
52  // when changing this enum.
53  enum class SensorType
54  {
56  NONE = 0,
57 
59  ALTIMETER = 1,
60 
62  CAMERA = 2,
63 
65  CONTACT = 3,
66 
68  DEPTH_CAMERA = 4,
69 
71  FORCE_TORQUE = 5,
72 
74  GPS = 6,
75 
77  GPU_LIDAR = 7,
78 
80  IMU = 8,
81 
83  LOGICAL_CAMERA = 9,
84 
86  MAGNETOMETER = 10,
87 
89  MULTICAMERA = 11,
90 
92  LIDAR = 12,
93 
95  RFID = 13,
96 
98  RFIDTAG = 14,
99 
101  SONAR = 15,
102 
104  WIRELESS_RECEIVER = 16,
105 
108 
110  AIR_PRESSURE = 18,
111 
114  RGBD_CAMERA = 19,
115 
117  THERMAL_CAMERA = 20,
118 
120  NAVSAT = 21,
121 
123  SEGMENTATION_CAMERA = 22,
124 
126  BOUNDINGBOX_CAMERA = 23,
127 
129  CUSTOM = 24,
130 
132  WIDE_ANGLE_CAMERA = 25
133  };
134 
137  {
139  public: Sensor();
140 
147  public: Errors Load(ElementPtr _sdf);
148 
152  public: std::string Name() const;
153 
157  public: void SetName(const std::string &_name);
158 
161  public: std::string Topic() const;
162 
165  public: void SetTopic(const std::string &_topic);
166 
169  public: bool EnableMetrics() const;
170 
173  public: void SetEnableMetrics(bool _enableMetrics);
174 
180  public: const ignition::math::Pose3d &RawPose() const;
181 
185  public: void SetRawPose(const ignition::math::Pose3d &_pose);
186 
191  public: const std::string &PoseRelativeTo() const;
192 
197  public: void SetPoseRelativeTo(const std::string &_frame);
198 
202  public: sdf::SemanticPose SemanticPose() const;
203 
208  public: sdf::ElementPtr Element() const;
209 
215  public: sdf::ElementPtr ToElement() const;
216 
219  public: SensorType Type() const;
220 
223  public: void SetType(const SensorType _type);
224 
231  public: bool SetType(const std::string &_typeStr);
232 
235  public: std::string TypeStr() const;
236 
241  public: double UpdateRate() const;
242 
247  public: void SetUpdateRate(double _hz);
248 
252  public: bool operator==(const Sensor &_sensor) const;
253 
258  public: bool operator!=(const Sensor &_sensor) const;
259 
265  public: const Magnetometer *MagnetometerSensor() const;
266 
272  public: Magnetometer *MagnetometerSensor();
273 
276  public: void SetMagnetometerSensor(const Magnetometer &_mag);
277 
283  public: const Altimeter *AltimeterSensor() const;
284 
290  public: Altimeter *AltimeterSensor();
291 
294  public: void SetAltimeterSensor(const Altimeter &_alt);
295 
301  public: const AirPressure *AirPressureSensor() const;
302 
308  public: AirPressure *AirPressureSensor();
309 
312  public: void SetAirPressureSensor(const AirPressure &_air);
313 
316  public: void SetCameraSensor(const Camera &_cam);
317 
323  public: const Camera *CameraSensor() const;
324 
330  public: Camera *CameraSensor();
331 
334  public: void SetNavSatSensor(const NavSat &_navsat);
335 
341  public: const NavSat *NavSatSensor() const;
342 
348  public: NavSat *NavSatSensor();
349 
352  public: void SetForceTorqueSensor(const ForceTorque &_ft);
353 
359  public: const ForceTorque *ForceTorqueSensor() const;
360 
366  public: ForceTorque *ForceTorqueSensor();
367 
370  public: void SetImuSensor(const Imu &_imu);
371 
377  public: const Imu *ImuSensor() const;
378 
384  public: Imu *ImuSensor();
385 
391  public: const Lidar *LidarSensor() const;
392 
398  public: Lidar *LidarSensor();
399 
402  public: void SetLidarSensor(const Lidar &_lidar);
403 
407  public: const sdf::Plugins &Plugins() const;
408 
412  public: sdf::Plugins &Plugins();
413 
415  public: void ClearPlugins();
416 
419  public: void AddPlugin(const Plugin &_plugin);
420 
425  private: void SetXmlParentName(const std::string &_xmlParentName);
426 
431  private: void SetPoseRelativeToGraph(
433 
437  friend class Link;
438 
440  IGN_UTILS_IMPL_PTR(dataPtr)
441  };
442  }
443 }
444 #endif
sdf::v12::AirPressure
AirPressure contains information about a general purpose fluid pressure sensor.
Definition: AirPressure.hh:34
sdf::v12::SensorType::CONTACT
@ CONTACT
A contact sensor.
sdf::v12::ScopedGraph
Definition: Collision.hh:39
sdf::v12::SensorType::THERMAL_CAMERA
@ THERMAL_CAMERA
A thermal camera sensor.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::v12::Plugins
std::vector< Plugin > Plugins
A vector of Plugin.
Definition: Plugin.hh:196
sdf::v12::SensorType::GPU_LIDAR
@ GPU_LIDAR
A GPU based lidar sensor.
sdf::v12::SensorType::BOUNDINGBOX_CAMERA
@ BOUNDINGBOX_CAMERA
A boundingbox camera sensor.
sdf::v12::SensorType::RGBD_CAMERA
@ RGBD_CAMERA
An RGBD sensor, which produces both a color image and a depth image.
sdf::v12::SensorType::RFID
@ RFID
An RFID sensor.
sdf::v12::SensorType::GPS
@ GPS
A GPS sensor.
sdf::v12::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
Types.hh
sdf::v12::SensorType::NAVSAT
@ NAVSAT
A NavSat sensor, such as GPS.
SemanticPose.hh
sdf::v12::SensorType::FORCE_TORQUE
@ FORCE_TORQUE
A force-torque sensor.
sdf::v12::SensorType::WIRELESS_RECEIVER
@ WIRELESS_RECEIVER
A wireless receiver.
sdf::v12::SensorType::MULTICAMERA
@ MULTICAMERA
A multicamera sensor.
sdf_config.h
sdf::v12::Imu
Imu contains information about an imu sensor.
Definition: Imu.hh:33
sdf::v12::ForceTorque
ForceTorque contains information about a force torque sensor.
Definition: ForceTorque.hh:64
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::v12::SensorType::WIRELESS_TRANSMITTER
@ WIRELESS_TRANSMITTER
A wireless transmitter.
sdf::v12::SensorType::LIDAR
@ LIDAR
A CPU based lidar sensor.
sdf::v12::SensorType::DEPTH_CAMERA
@ DEPTH_CAMERA
A depth camera sensor.
sdf::v12::SensorType::SEGMENTATION_CAMERA
@ SEGMENTATION_CAMERA
A segmentation camera sensor.
sdf::v12::SensorType::MAGNETOMETER
@ MAGNETOMETER
A magnetometer sensor.
sdf::v12::SensorType::CAMERA
@ CAMERA
A monocular camera sensor.
sdf::v12::Element
class IGNITION_SDFORMAT_VISIBLE Element
Definition: Element.hh:50
sdf::v12::Magnetometer
Magnetometer contains information about a magnetometer sensor.
Definition: Magnetometer.hh:34
sdf::v12::Camera
Information about a monocular camera sensor.
Definition: Camera.hh:60
sdf::v12::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::v12::SensorType::RFIDTAG
@ RFIDTAG
An RFID tag.
sdf::v12::Altimeter
Altimeter contains information about an altimeter sensor.
Definition: Altimeter.hh:33
sdf::v12::Plugin
Definition: Plugin.hh:45
sdf::v12::Lidar
Lidar contains information about a Lidar sensor.
Definition: Lidar.hh:105
sdf::v12::SensorType::SONAR
@ SONAR
A sonar tag sensor.
sdf::v12::SensorType::CUSTOM
@ CUSTOM
A custom sensor.
sdf::v12::SensorType::AIR_PRESSURE
@ AIR_PRESSURE
An air pressure sensor.
sdf::v12::ErrorCode::NONE
@ NONE
sdf::v12::SensorType::IMU
@ IMU
An IMU sensor.
sdf::v12::SensorType
SensorType
Definition: Sensor.hh:53
sdf::v12::NavSat
NavSat contains information about a NavSat sensor.
Definition: NavSat.hh:75
system_util.hh
Plugin.hh
sdf::v12::SensorType::LOGICAL_CAMERA
@ LOGICAL_CAMERA
A logical camera sensor.
sdf::v12::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
sdf::v12::SensorType::ALTIMETER
@ ALTIMETER
An altimeter sensor.
sdf::v12::Sensor
Information about an SDF sensor.
Definition: Sensor.hh:136
Element.hh
sdf::v12::SensorType::WIDE_ANGLE_CAMERA
@ WIDE_ANGLE_CAMERA
A wide angle camera sensor.