Loading...
Searching...
No Matches
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/SemanticPose.hh"
26#include "sdf/Types.hh"
27#include "sdf/sdf_config.h"
28#include "sdf/system_util.hh"
29
30namespace sdf
31{
32 // Inline bracket to help doxygen filtering.
33 inline namespace SDF_VERSION_NAMESPACE {
34 //
35
36 // Forward declarations.
37 class AirPressure;
38 class Altimeter;
39 class Camera;
40 class ForceTorque;
41 class Imu;
42 class Lidar;
43 class Magnetometer;
44 class NavSat;
45 struct PoseRelativeToGraph;
46 template <typename T> class ScopedGraph;
47
50 // Developer note: Make sure to update sensorTypeStrs in the source file
51 // when changing this enum.
52 enum class SensorType
53 {
55 NONE = 0,
56
58 ALTIMETER = 1,
59
61 CAMERA = 2,
62
64 CONTACT = 3,
65
67 DEPTH_CAMERA = 4,
68
70 FORCE_TORQUE = 5,
71
73 GPS = 6,
74
76 GPU_LIDAR = 7,
77
79 IMU = 8,
80
82 LOGICAL_CAMERA = 9,
83
85 MAGNETOMETER = 10,
86
88 MULTICAMERA = 11,
89
91 LIDAR = 12,
92
94 RFID = 13,
95
97 RFIDTAG = 14,
98
100 SONAR = 15,
101
103 WIRELESS_RECEIVER = 16,
104
106 WIRELESS_TRANSMITTER = 17,
107
109 AIR_PRESSURE = 18,
110
113 RGBD_CAMERA = 19,
114
116 THERMAL_CAMERA = 20,
117
119 NAVSAT = 21,
120
122 SEGMENTATION_CAMERA = 22,
123
125 BOUNDINGBOX_CAMERA = 23,
126
128 CUSTOM = 24,
129
131 WIDE_ANGLE_CAMERA = 25
132 };
133
136 {
138 public: Sensor();
139
146 public: Errors Load(ElementPtr _sdf);
147
151 public: std::string Name() const;
152
156 public: void SetName(const std::string &_name);
157
160 public: std::string Topic() const;
161
164 public: void SetTopic(const std::string &_topic);
165
168 public: bool EnableMetrics() const;
169
172 public: void SetEnableMetrics(bool _enableMetrics);
173
179 public: const ignition::math::Pose3d &RawPose() const;
180
184 public: void SetRawPose(const ignition::math::Pose3d &_pose);
185
190 public: const std::string &PoseRelativeTo() const;
191
196 public: void SetPoseRelativeTo(const std::string &_frame);
197
202
207 public: sdf::ElementPtr Element() const;
208
212 public: sdf::ElementPtr ToElement() const;
213
216 public: SensorType Type() const;
217
220 public: void SetType(const SensorType _type);
221
228 public: bool SetType(const std::string &_typeStr);
229
232 public: std::string TypeStr() const;
233
238 public: double UpdateRate() const;
239
244 public: void SetUpdateRate(double _hz);
245
249 public: bool operator==(const Sensor &_sensor) const;
250
255 public: bool operator!=(const Sensor &_sensor) const;
256
262 public: const Magnetometer *MagnetometerSensor() const;
263
270
273 public: void SetMagnetometerSensor(const Magnetometer &_mag);
274
280 public: const Altimeter *AltimeterSensor() const;
281
288
291 public: void SetAltimeterSensor(const Altimeter &_alt);
292
298 public: const AirPressure *AirPressureSensor() const;
299
306
309 public: void SetAirPressureSensor(const AirPressure &_air);
310
313 public: void SetCameraSensor(const Camera &_cam);
314
320 public: const Camera *CameraSensor() const;
321
328
331 public: void SetNavSatSensor(const NavSat &_navsat);
332
338 public: const NavSat *NavSatSensor() const;
339
346
349 public: void SetForceTorqueSensor(const ForceTorque &_ft);
350
356 public: const ForceTorque *ForceTorqueSensor() const;
357
364
367 public: void SetImuSensor(const Imu &_imu);
368
374 public: const Imu *ImuSensor() const;
375
381 public: Imu *ImuSensor();
382
388 public: const Lidar *LidarSensor() const;
389
395 public: Lidar *LidarSensor();
396
399 public: void SetLidarSensor(const Lidar &_lidar);
400
405 private: void SetXmlParentName(const std::string &_xmlParentName);
406
411 private: void SetPoseRelativeToGraph(
413
417 friend class Link;
418
420 IGN_UTILS_IMPL_PTR(dataPtr)
421 };
422 }
423}
424#endif
AirPressure contains information about a general purpose fluid pressure sensor.
Definition AirPressure.hh:35
Altimeter contains information about an altimeter sensor.
Definition Altimeter.hh:34
Information about a monocular camera sensor.
Definition Camera.hh:61
ForceTorque contains information about a force torque sensor.
Definition ForceTorque.hh:65
Imu contains information about an imu sensor.
Definition Imu.hh:34
Lidar contains information about a Lidar sensor.
Definition Lidar.hh:106
Magnetometer contains information about a magnetometer sensor.
Definition Magnetometer.hh:35
NavSat contains information about a NavSat sensor.
Definition NavSat.hh:76
Definition Collision.hh:39
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition SemanticPose.hh:55
Information about an SDF sensor.
Definition Sensor.hh:136
bool SetType(const std::string &_typeStr)
Set the sensor type from a string.
void SetNavSatSensor(const NavSat &_navsat)
Set the NAVSAT sensor.
void SetUpdateRate(double _hz)
Set the update rate.
sdf::SemanticPose SemanticPose() const
Get SemanticPose object of this object to aid in resolving poses.
void SetName(const std::string &_name)
Set the name of the sensor.
const NavSat * NavSatSensor() const
Get a pointer to a NAVSAT sensor, or nullptr if the sensor does not contain an NAVSAT sensor.
Sensor()
Default constructor.
AirPressure * AirPressureSensor()
Get a mutable air pressure sensor, or nullptr if this sensor type is not an AirPressure sensor.
void SetImuSensor(const Imu &_imu)
Set the IMU sensor.
Camera * CameraSensor()
Get a mutable camera sensor, or nullptr if the sensor does not contain a camera sensor.
ForceTorque * ForceTorqueSensor()
Get a mutable force torque sensor, or nullptr if the sensor does not contain a force torque sensor.
std::string Name() const
Get the name of the sensor.
bool operator==(const Sensor &_sensor) const
Return true if both Sensor objects contain the same values.
const Lidar * LidarSensor() const
Get the lidar sensor, or nullptr if this sensor type is not a Lidar.
void SetRawPose(const ignition::math::Pose3d &_pose)
Set the pose of the sensor.
void SetEnableMetrics(bool _enableMetrics)
Set flag to enable publishing performance metrics.
void SetAirPressureSensor(const AirPressure &_air)
Set the air pressure sensor.
Errors Load(ElementPtr _sdf)
Load the sensor based on a element pointer.
bool operator!=(const Sensor &_sensor) const
Return true this Sensor object does not contain the same values as the passed in parameter.
void SetForceTorqueSensor(const ForceTorque &_ft)
Set the force torque sensor.
void SetCameraSensor(const Camera &_cam)
Set the camera sensor.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
void SetMagnetometerSensor(const Magnetometer &_mag)
Set the magnetometer sensor.
SensorType Type() const
Get the sensor type.
void SetLidarSensor(const Lidar &_lidar)
Set the lidar sensor.
const Magnetometer * MagnetometerSensor() const
Get the magnetometer sensor, or nullptr if this sensor type is not a Magnetometer.
void SetAltimeterSensor(const Altimeter &_alt)
Set the altimeter sensor.
Magnetometer * MagnetometerSensor()
Get a mutable magnetometer sensor, or nullptr if this sensor type is not a Magnetometer.
const Altimeter * AltimeterSensor() const
Get the altimeter sensor, or nullptr if this sensor type is not an Altimeter.
Imu * ImuSensor()
Get a mutable IMU sensor, or nullptr if the sensor does not contain an IMU sensor.
const ForceTorque * ForceTorqueSensor() const
Get a pointer to a force torque sensor, or nullptr if the sensor does not contain a force torque sens...
void SetType(const SensorType _type)
Set the sensor type.
std::string Topic() const
Get the topic on which sensor data should be published.
const AirPressure * AirPressureSensor() const
Get the air pressure sensor, or nullptr if this sensor type is not an AirPressure sensor.
NavSat * NavSatSensor()
Get a mutable NAVSAT sensor, or nullptr if the sensor does not contain an NAVSAT sensor.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
Altimeter * AltimeterSensor()
Get a mutable altimeter sensor, or nullptr if this sensor type is not an Altimeter.
bool EnableMetrics() const
Get flag state for enabling performance metrics publication.
const Imu * ImuSensor() const
Get a pointer to an IMU sensor, or nullptr if the sensor does not contain an IMU sensor.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this sensor.
const ignition::math::Pose3d & RawPose() const
Get the pose of the sensor.
Lidar * LidarSensor()
Get a mutable lidar sensor, or nullptr if this sensor type is not a Lidar.
void SetTopic(const std::string &_topic)
Set the topic on which sensor data should be published.
std::string TypeStr() const
Get the sensor type as a string.
double UpdateRate() const
Get the update rate in Hz.
const Camera * CameraSensor() const
Get a pointer to a camera sensor, or nullptr if the sensor does not contain a camera sensor.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:106
std::shared_ptr< Element > ElementPtr
Definition Element.hh:54
SensorType
The set of sensor types.
Definition Sensor.hh:53
namespace for Simulation Description Format parser
Definition Actor.hh:34
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:41