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 <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/config.hh"
29#include "sdf/system_util.hh"
30
31namespace 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 kSensorTypeStrs 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
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
106
109
111 AIR_PRESSURE = 18,
112
115 RGBD_CAMERA = 19,
116
118 THERMAL_CAMERA = 20,
119
121 NAVSAT = 21,
122
125
128
130 CUSTOM = 24,
131
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 FrameId() const;
166
169 public: void SetFrameId(const std::string &_frameId);
170
173 public: std::string Topic() const;
174
177 public: void SetTopic(const std::string &_topic);
178
181 public: bool EnableMetrics() const;
182
185 public: void SetEnableMetrics(bool _enableMetrics);
186
192 public: const gz::math::Pose3d &RawPose() const;
193
197 public: void SetRawPose(const gz::math::Pose3d &_pose);
198
203 public: const std::string &PoseRelativeTo() const;
204
209 public: void SetPoseRelativeTo(const std::string &_frame);
210
215
220 public: sdf::ElementPtr Element() const;
221
227 public: sdf::ElementPtr ToElement() const;
228
235 public: sdf::ElementPtr ToElement(sdf::Errors &_errors) const;
236
239 public: SensorType Type() const;
240
243 public: void SetType(const SensorType _type);
244
251 public: bool SetType(const std::string &_typeStr);
252
255 public: std::string TypeStr() const;
256
261 public: double UpdateRate() const;
262
267 public: void SetUpdateRate(double _hz);
268
272 public: bool operator==(const Sensor &_sensor) const;
273
278 public: bool operator!=(const Sensor &_sensor) const;
279
285 public: const Magnetometer *MagnetometerSensor() const;
286
293
296 public: void SetMagnetometerSensor(const Magnetometer &_mag);
297
303 public: const Altimeter *AltimeterSensor() const;
304
311
314 public: void SetAltimeterSensor(const Altimeter &_alt);
315
321 public: const AirPressure *AirPressureSensor() const;
322
329
332 public: void SetAirPressureSensor(const AirPressure &_air);
333
339 public: const AirSpeed *AirSpeedSensor() const;
340
347
350 public: void SetAirSpeedSensor(const AirSpeed &_air);
351
354 public: void SetCameraSensor(const Camera &_cam);
355
361 public: const Camera *CameraSensor() const;
362
369
372 public: void SetNavSatSensor(const NavSat &_navsat);
373
379 public: const NavSat *NavSatSensor() const;
380
387
390 public: void SetForceTorqueSensor(const ForceTorque &_ft);
391
397 public: const ForceTorque *ForceTorqueSensor() const;
398
405
408 public: void SetImuSensor(const Imu &_imu);
409
415 public: const Imu *ImuSensor() const;
416
422 public: Imu *ImuSensor();
423
429 public: const Lidar *LidarSensor() const;
430
436 public: Lidar *LidarSensor();
437
440 public: void SetLidarSensor(const Lidar &_lidar);
441
445 public: const sdf::Plugins &Plugins() const;
446
451
453 public: void ClearPlugins();
454
457 public: void AddPlugin(const Plugin &_plugin);
458
463 private: void SetXmlParentName(const std::string &_xmlParentName);
464
469 private: void SetPoseRelativeToGraph(
471
475 friend class Link;
479 friend class Joint;
480
482 GZ_UTILS_IMPL_PTR(dataPtr)
483 };
484 }
485}
486#endif
AirPressure contains information about a general purpose fluid pressure sensor.
Definition AirPressure.hh:35
AirSpeed contains information about a general purpose air speed sensor.
Definition AirSpeed.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
Definition Joint.hh:86
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 Plugin.hh:46
Definition Collision.hh:44
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:141
const gz::math::Pose3d & RawPose() const
Get the pose of the sensor.
void SetImuSensor(const Imu &_imu)
Set the IMU sensor.
void SetMagnetometerSensor(const Magnetometer &_mag)
Set the magnetometer sensor.
sdf::Plugins & Plugins()
Get a mutable vector of plugins attached to this object.
AirPressure * AirPressureSensor()
Get a mutable air pressure sensor, or nullptr if this sensor type is not an AirPressure sensor.
Altimeter * AltimeterSensor()
Get a mutable altimeter sensor, or nullptr if this sensor type is not an Altimeter.
void SetName(const std::string &_name)
Set the name of the sensor.
ForceTorque * ForceTorqueSensor()
Get a mutable force torque sensor, or nullptr if the sensor does not contain a force torque sensor.
bool operator!=(const Sensor &_sensor) const
Return true this Sensor object does not contain the same values as the passed in parameter.
void SetEnableMetrics(bool _enableMetrics)
Set flag to enable publishing performance metrics.
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 SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
Magnetometer * MagnetometerSensor()
Get a mutable magnetometer sensor, or nullptr if this sensor type is not a Magnetometer.
const AirPressure * AirPressureSensor() const
Get the air pressure sensor, or nullptr if this sensor type is not an AirPressure sensor.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
bool operator==(const Sensor &_sensor) const
Return true if both Sensor objects contain the same values.
void SetAirPressureSensor(const AirPressure &_air)
Set the air pressure sensor.
void SetNavSatSensor(const NavSat &_navsat)
Set the NAVSAT sensor.
const NavSat * NavSatSensor() const
Get a pointer to a NAVSAT sensor, or nullptr if the sensor does not contain an NAVSAT sensor.
const AirSpeed * AirSpeedSensor() const
Get the air speed sensor, or nullptr if this sensor type is not an AirSpeed sensor.
const Imu * ImuSensor() const
Get a pointer to an IMU sensor, or nullptr if the sensor does not contain an IMU sensor.
void SetFrameId(const std::string &_frameId)
Set the frame ID of the sensor.
const Altimeter * AltimeterSensor() const
Get the altimeter sensor, or nullptr if this sensor type is not an Altimeter.
void SetAirSpeedSensor(const AirSpeed &_air)
Set the air pressure sensor.
void SetCameraSensor(const Camera &_cam)
Set the camera sensor.
bool EnableMetrics() const
Get flag state for enabling performance metrics publication.
void AddPlugin(const Plugin &_plugin)
Add a plugin to this object.
const Lidar * LidarSensor() const
Get the lidar sensor, or nullptr if this sensor type is not a Lidar.
std::string FrameId() const
Get the frame ID of the sensor.
void SetRawPose(const gz::math::Pose3d &_pose)
Set the pose of the sensor.
std::string Name() const
Get the name of the sensor.
Camera * CameraSensor()
Get a mutable camera sensor, or nullptr if the sensor does not contain a camera sensor.
void SetForceTorqueSensor(const ForceTorque &_ft)
Set the force torque sensor.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
std::string TypeStr() const
Get the sensor type as a string.
sdf::ElementPtr ToElement(sdf::Errors &_errors) const
Create and return an SDF element filled with data from this sensor.
void SetTopic(const std::string &_topic)
Set the topic on which sensor data should be published.
void SetType(const SensorType _type)
Set the sensor type.
std::string Topic() const
Get the topic on which sensor data should be published.
const sdf::Plugins & Plugins() const
Get the plugins attached to this object.
void SetAltimeterSensor(const Altimeter &_alt)
Set the altimeter sensor.
Lidar * LidarSensor()
Get a mutable lidar sensor, or nullptr if this sensor type is not a Lidar.
void SetUpdateRate(double _hz)
Set the update rate.
NavSat * NavSatSensor()
Get a mutable NAVSAT sensor, or nullptr if the sensor does not contain an NAVSAT sensor.
void SetLidarSensor(const Lidar &_lidar)
Set the lidar sensor.
Errors Load(ElementPtr _sdf)
Load the sensor based on a element pointer.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this sensor.
AirSpeed * AirSpeedSensor()
Get a mutable air speed sensor, or nullptr if this sensor type is not an AirSpeed sensor.
Imu * ImuSensor()
Get a mutable IMU sensor, or nullptr if the sensor does not contain an IMU sensor.
SensorType Type() const
Get the sensor type.
const Magnetometer * MagnetometerSensor() const
Get the magnetometer sensor, or nullptr if this sensor type is not a Magnetometer.
const Camera * CameraSensor() const
Get a pointer to a camera sensor, or nullptr if the sensor does not contain a camera sensor.
double UpdateRate() const
Get the update rate in Hz.
bool SetType(const std::string &_typeStr)
Set the sensor type from a string.
Sensor()
Default constructor.
sdf::SemanticPose SemanticPose() const
Get SemanticPose object of this object to aid in resolving poses.
void ClearPlugins()
Remove all plugins.
std::vector< Plugin > Plugins
A vector of Plugin.
Definition Plugin.hh:245
SensorType
The set of sensor types.
Definition Sensor.hh:55
@ WIRELESS_TRANSMITTER
A wireless transmitter.
@ GPU_LIDAR
A GPU based lidar sensor.
@ NAVSAT
A NavSat sensor, such as GPS.
@ LOGICAL_CAMERA
A logical camera sensor.
@ WIRELESS_RECEIVER
A wireless receiver.
@ AIR_PRESSURE
An air pressure sensor.
@ THERMAL_CAMERA
A thermal camera sensor.
@ BOUNDINGBOX_CAMERA
A boundingbox camera sensor.
@ WIDE_ANGLE_CAMERA
A wide angle camera sensor.
@ RGBD_CAMERA
An RGBD sensor, which produces both a color image and a depth image.
@ SEGMENTATION_CAMERA
A segmentation camera sensor.
@ FORCE_TORQUE
A force-torque sensor.
@ MULTICAMERA
A multicamera sensor.
@ MAGNETOMETER
A magnetometer sensor.
@ LIDAR
A CPU based lidar sensor.
@ CAMERA
A monocular camera sensor.
@ DEPTH_CAMERA
A depth camera sensor.
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:81
std::shared_ptr< Element > ElementPtr
Definition Element.hh:55
namespace for Simulation Description Format parser
Definition Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:25