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 SensorPrivate;
42  struct PoseRelativeToGraph;
43 
46  // Developer note: Make sure to update sensorTypeStrs in the source file
47  // when changing this enum.
48  enum class SensorType
49  {
51  NONE = 0,
52 
54  ALTIMETER = 1,
55 
57  CAMERA = 2,
58 
60  CONTACT = 3,
61 
63  DEPTH_CAMERA = 4,
64 
66  FORCE_TORQUE = 5,
67 
69  GPS = 6,
70 
72  GPU_LIDAR = 7,
73 
75  IMU = 8,
76 
78  LOGICAL_CAMERA = 9,
79 
81  MAGNETOMETER = 10,
82 
84  MULTICAMERA = 11,
85 
87  LIDAR = 12,
88 
90  RFID = 13,
91 
93  RFIDTAG = 14,
94 
96  SONAR = 15,
97 
99  WIRELESS_RECEIVER = 16,
100 
103 
105  AIR_PRESSURE = 18,
106 
109  RGBD_CAMERA = 19,
110 
112  THERMAL_CAMERA = 20
113  };
114 
117  {
119  public: Sensor();
120 
123  public: Sensor(const Sensor &_sensor);
124 
127  public: Sensor(Sensor &&_sensor) noexcept;
128 
130  public: ~Sensor();
131 
138  public: Errors Load(ElementPtr _sdf);
139 
143  public: std::string Name() const;
144 
148  public: void SetName(const std::string &_name);
149 
152  public: std::string Topic() const;
153 
156  public: void SetTopic(const std::string &_topic);
157 
163  public: const ignition::math::Pose3d &RawPose() const;
164 
168  public: void SetRawPose(const ignition::math::Pose3d &_pose);
169 
174  public: const std::string &PoseRelativeTo() const;
175 
180  public: void SetPoseRelativeTo(const std::string &_frame);
181 
185  public: sdf::SemanticPose SemanticPose() const;
186 
191  public: sdf::ElementPtr Element() const;
192 
195  public: SensorType Type() const;
196 
199  public: void SetType(const SensorType _type);
200 
207  public: bool SetType(const std::string &_typeStr);
208 
211  public: std::string TypeStr() const;
212 
217  public: double UpdateRate() const;
218 
223  public: void SetUpdateRate(double _hz);
224 
228  public: Sensor &operator=(const Sensor &_sensor);
229 
233  public: Sensor &operator=(Sensor &&_sensor);
234 
238  public: bool operator==(const Sensor &_sensor) const;
239 
244  public: bool operator!=(const Sensor &_sensor) const;
245 
251  public: const Magnetometer *MagnetometerSensor() const;
252 
255  public: void SetMagnetometerSensor(const Magnetometer &_mag);
256 
262  public: const Altimeter *AltimeterSensor() const;
263 
266  public: void SetAltimeterSensor(const Altimeter &_alt);
267 
273  public: const AirPressure *AirPressureSensor() const;
274 
277  public: void SetAirPressureSensor(const AirPressure &_air);
278 
281  public: void SetCameraSensor(const Camera &_cam);
282 
288  public: const Camera *CameraSensor() const;
289 
292  public: void SetImuSensor(const Imu &_imu);
293 
299  public: const Imu *ImuSensor() const;
300 
306  public: const Lidar *LidarSensor() const;
307 
310  public: void SetLidarSensor(const Lidar &_lidar);
311 
316  private: void SetXmlParentName(const std::string &_xmlParentName);
317 
322  private: void SetPoseRelativeToGraph(
323  std::weak_ptr<const PoseRelativeToGraph> _graph);
324 
328  friend class Link;
329 
331  private: SensorPrivate *dataPtr = nullptr;
332  };
333  }
334 }
335 #endif
sdf::v10::Lidar
Lidar contains information about a Lidar sensor.
Definition: Lidar.hh:104
sdf::SDF_VERSION_NAMESPACE::SensorType::GPU_LIDAR
@ GPU_LIDAR
A GPU based lidar sensor.
sdf::v10::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::THERMAL_CAMERA
@ THERMAL_CAMERA
A thermal camera sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::MAGNETOMETER
@ MAGNETOMETER
A magnetometer sensor.
sdf::v10::Imu
Imu contains information about an imu sensor.
Definition: Imu.hh:35
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
sdf::v10::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
sdf::v10::Altimeter
Altimeter contains information about an altimeter sensor.
Definition: Altimeter.hh:34
sdf::SDF_VERSION_NAMESPACE::SensorType::MULTICAMERA
@ MULTICAMERA
A multicamera sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::AIR_PRESSURE
@ AIR_PRESSURE
An air pressure sensor.
Types.hh
sdf::SDF_VERSION_NAMESPACE::SensorType::CAMERA
@ CAMERA
A monocular camera sensor.
SemanticPose.hh
sdf::v10::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::SDF_VERSION_NAMESPACE::SensorType::DEPTH_CAMERA
@ DEPTH_CAMERA
A depth camera sensor.
sdf::v10::AirPressure
AirPressure contains information about a general purpose fluid pressure sensor.
Definition: AirPressure.hh:35
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::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:48
sdf::SDF_VERSION_NAMESPACE::SensorType::IMU
@ IMU
An IMU sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::SONAR
@ SONAR
A sonar tag sensor.
sdf::SDF_VERSION_NAMESPACE::SensorType::LIDAR
@ LIDAR
A CPU based lidar sensor.
sdf::v10::Magnetometer
Magnetometer contains information about a magnetometer sensor.
Definition: Magnetometer.hh:34
sdf::SDF_VERSION_NAMESPACE::SensorType::LOGICAL_CAMERA
@ LOGICAL_CAMERA
A logical camera sensor.
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
sdf::v10::Camera
Information about a monocular camera sensor.
Definition: Camera.hh:63
sdf::SDF_VERSION_NAMESPACE::SensorType::CONTACT
@ CONTACT
A contact sensor.
sdf::SDF_VERSION_NAMESPACE::Sensor
Information about an SDF sensor.
Definition: Sensor.hh:116
sdf::v10::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
Element.hh
sdf::SDF_VERSION_NAMESPACE::SensorType::WIRELESS_TRANSMITTER
@ WIRELESS_TRANSMITTER
A wireless transmitter.