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 <string>
21 #include <ignition/math/Pose3.hh>
22 #include "sdf/Element.hh"
23 #include "sdf/Types.hh"
24 #include "sdf/system_util.hh"
25 
26 namespace sdf
27 {
28  // Inline bracket to help doxygen filtering.
29  inline namespace SDF_VERSION_NAMESPACE {
30  //
31 
32  // Forward declarations.
33  class AirPressure;
34  class Altimeter;
35  class Camera;
36  class Imu;
37  class Lidar;
38  class Magnetometer;
39  class SensorPrivate;
40 
43  // Developer note: Make sure to update sensorTypeStrs in the source file
44  // when changing this enum.
45  enum class SensorType
46  {
48  NONE = 0,
49 
51  ALTIMETER = 1,
52 
54  CAMERA = 2,
55 
57  CONTACT = 3,
58 
60  DEPTH_CAMERA = 4,
61 
63  FORCE_TORQUE = 5,
64 
66  GPS = 6,
67 
69  GPU_LIDAR = 7,
70 
72  IMU = 8,
73 
75  LOGICAL_CAMERA = 9,
76 
78  MAGNETOMETER = 10,
79 
81  MULTICAMERA = 11,
82 
84  LIDAR = 12,
85 
87  RFID = 13,
88 
90  RFIDTAG = 14,
91 
93  SONAR = 15,
94 
96  WIRELESS_RECEIVER = 16,
97 
100 
102  AIR_PRESSURE = 18,
103 
106  RGBD_CAMERA = 19
107  };
108 
111  {
113  public: Sensor();
114 
117  public: Sensor(const Sensor &_sensor);
118 
121  public: Sensor(Sensor &&_sensor) noexcept;
122 
124  public: ~Sensor();
125 
132  public: Errors Load(ElementPtr _sdf);
133 
137  public: std::string Name() const;
138 
142  public: void SetName(const std::string &_name);
143 
146  public: std::string Topic() const;
147 
150  public: void SetTopic(const std::string &_topic);
151 
157  public: const ignition::math::Pose3d &Pose() const;
158 
162  public: void SetPose(const ignition::math::Pose3d &_pose);
163 
168  public: const std::string &PoseFrame() const;
169 
174  public: void SetPoseFrame(const std::string &_frame);
175 
180  public: sdf::ElementPtr Element() const;
181 
184  public: SensorType Type() const;
185 
188  public: void SetType(const SensorType _type);
189 
196  public: bool SetType(const std::string &_typeStr);
197 
200  public: std::string TypeStr() const;
201 
206  public: double UpdateRate() const;
207 
212  public: void SetUpdateRate(double _hz);
213 
217  public: Sensor &operator=(const Sensor &_sensor);
218 
222  public: Sensor &operator=(Sensor &&_sensor);
223 
227  public: bool operator==(const Sensor &_sensor) const;
228 
233  public: bool operator!=(const Sensor &_sensor) const;
234 
240  public: const Magnetometer *MagnetometerSensor() const;
241 
244  public: void SetMagnetometerSensor(const Magnetometer &_mag);
245 
251  public: const Altimeter *AltimeterSensor() const;
252 
255  public: void SetAltimeterSensor(const Altimeter &_alt);
256 
262  public: const AirPressure *AirPressureSensor() const;
263 
266  public: void SetAirPressureSensor(const AirPressure &_air);
267 
270  public: void SetCameraSensor(const Camera &_cam);
271 
277  public: const Camera *CameraSensor() const;
278 
281  public: void SetImuSensor(const Imu &_imu);
282 
288  public: const Imu *ImuSensor() const;
289 
295  public: const Lidar *LidarSensor() const;
296 
299  public: void SetLidarSensor(const Lidar &_lidar);
300 
302  private: SensorPrivate *dataPtr = nullptr;
303  };
304  }
305 }
306 #endif
SensorType
The set of sensor types.
Definition: Sensor.hh:45
class SDFORMAT_VISIBLE Element
Definition: Element.hh:47
Information about an SDF sensor.
Definition: Sensor.hh:110
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:51
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:74
An RGBD sensor, which produces both a color image and a depth image.
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
namespace for Simulation Description Format parser
Definition: AirPressure.hh:25