Skip to content

Commit b889d93

Browse files
Dotrarchapulinaadlarkin
authored
Add GPS sensor to sdf9 (#453)
Signed-off-by: Dre Westcook <dre.west@outlook.com> Signed-off-by: Dre Westcook <sir.dre.west@outlook.com> Signed-off-by: Ashton Larkin <ashton@openrobotics.org> Co-authored-by: Louise Poubel <louise@openrobotics.org> Co-authored-by: Ashton Larkin <ashton@openrobotics.org>
1 parent 42f8fad commit b889d93

13 files changed

+650
-15
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
build
33
build_*
44
*.*.sw?
5+
.vscode

include/sdf/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ set (headers
2929
Material.hh
3030
Mesh.hh
3131
Model.hh
32+
NavSat.hh
3233
Noise.hh
3334
Param.hh
3435
parser.hh

include/sdf/NavSat.hh

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/*
2+
* Copyright 2021 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_NAVSAT_HH_
18+
#define SDF_NAVSAT_HH_
19+
20+
#include <sdf/Error.hh>
21+
#include <sdf/Element.hh>
22+
#include <sdf/Noise.hh>
23+
#include <sdf/sdf_config.h>
24+
25+
#include <ignition/math/Angle.hh>
26+
27+
namespace sdf
28+
{
29+
// Inline bracket to help doxygen filtering.
30+
inline namespace SDF_VERSION_NAMESPACE {
31+
//
32+
class NavSatPrivate;
33+
34+
/// \brief NavSat contains information about a NavSat sensor.
35+
/// This sensor can be attached to a link. The NavSat sensor can be defined
36+
/// SDF XML by the "navsat" type.
37+
///
38+
/// # Example SDF XML using navsat type:
39+
///
40+
/// ~~~{.xml}
41+
/// <sensor name="navsat_sensor" type="navsat">
42+
/// <pose>1 2 3 0 0 0</pose>
43+
/// <topic>/navsat</topic>
44+
/// <navsat>
45+
/// <position_sensing>
46+
/// <horizontal>
47+
/// <noise type="gaussian">
48+
/// <mean>0.98</mean>
49+
/// <stddev>0.76</stddev>
50+
/// </noise>
51+
/// </horizontal>
52+
/// <vertical>
53+
/// <noise type="gaussian">
54+
/// <mean>0.98</mean>
55+
/// <stddev>0.76</stddev>
56+
/// </noise>
57+
/// </vertical>
58+
/// </position_sensing>
59+
/// <velocity_sensing>
60+
/// <horizontal>
61+
/// <noise type="gaussian">
62+
/// <mean>0.98</mean>
63+
/// <stddev>0.76</stddev>
64+
/// </noise>
65+
/// </horizontal>
66+
/// <vertical>
67+
/// <noise type="gaussian">
68+
/// <mean>0.98</mean>
69+
/// <stddev>0.76</stddev>
70+
/// </noise>
71+
/// </vertical>
72+
/// </velocity_sensing>
73+
/// </navsat>
74+
/// </sensor>
75+
/// ~~~
76+
class SDFORMAT_VISIBLE NavSat
77+
{
78+
/// \brief Default constructor
79+
public: NavSat();
80+
81+
/// \brief Copy constructor
82+
/// \param[in] _navsat NavSat to copy.
83+
public: NavSat(const NavSat &_navsat);
84+
85+
/// \brief Move constructor
86+
/// \param[in] _navsat NavSat to move.
87+
public: NavSat(NavSat &&_navsat) noexcept;
88+
89+
/// \brief Destructor
90+
public: ~NavSat();
91+
92+
/// \brief Assignment operator
93+
/// \param[in] _navsat The navsat to set values from.
94+
/// \return *this
95+
public: NavSat &operator=(const NavSat &_navsat);
96+
97+
/// \brief Move assignment operator
98+
/// \param[in] _navsat The navsat to set values from.
99+
/// \return *this
100+
public: NavSat &operator=(NavSat &&_navsat) noexcept;
101+
102+
/// \brief Load the navsat based on an element pointer. This is *not*
103+
/// the usual entry point. Typical usage of the SDF DOM is through the Root
104+
/// object.
105+
/// \param[in] _sdf The SDF Element pointer
106+
/// \return Errors, which is a vector of Error objects. Each Error includes
107+
/// an error code and message. An empty vector indicates no error.
108+
public: Errors Load(ElementPtr _sdf);
109+
110+
/// \brief Get a pointer to the SDF element that was used during
111+
/// load.
112+
/// \return SDF element pointer. The value will be nullptr if Load has
113+
/// not been called.
114+
public: sdf::ElementPtr Element() const;
115+
116+
/// \brief Set the noise values for the horizontal position sensor
117+
/// \param[in] _noise Noise values to set to
118+
public: void SetHorizontalPositionNoise(const Noise &_noise);
119+
120+
/// \brief Get noise value for horizontal position sensor
121+
/// \return Noise values
122+
public: const Noise &HorizontalPositionNoise() const;
123+
124+
/// \brief Set the noise values for the vertical position sensor
125+
/// \param[in] _noise Noise values to set to
126+
public: void SetVerticalPositionNoise(const Noise &_noise);
127+
128+
/// \brief Get noise value for vertical position sensor
129+
/// \return Noise values
130+
public: const Noise &VerticalPositionNoise() const;
131+
132+
/// \brief Set the noise values for the horizontal velocity sensor
133+
/// \param[in] _noise Noise values to set to
134+
public: void SetHorizontalVelocityNoise(const Noise &_noise);
135+
136+
/// \brief Get noise value for horizontal velocity sensor
137+
/// \return Noise values
138+
public: const Noise &HorizontalVelocityNoise() const;
139+
140+
/// \brief Set the noise values for the vertical velocity sensor
141+
/// \param[in] _noise Noise values to set to
142+
public: void SetVerticalVelocityNoise(const Noise &_noise);
143+
144+
/// \brief Get noise value for vertical velocity sensor
145+
/// \return Noise values
146+
public: const Noise &VerticalVelocityNoise() const;
147+
148+
/// \brief Return true if both NavSat objects contain the same values.
149+
/// \param[_in] _navsat NavSat value to compare.
150+
/// \return True if 'this' == _navsat.
151+
public: bool operator==(const NavSat &_navsat) const;
152+
153+
/// \brief Return true this NavSat object does not contain the same
154+
/// values as the passed in parameter.
155+
/// \param[_in] _navsat NavSat value to compare.
156+
/// \return True if 'this' != _navsat.
157+
public: bool operator!=(const NavSat &_navsat) const;
158+
159+
/// \brief Private data pointer.
160+
private: NavSatPrivate *dataPtr;
161+
};
162+
}
163+
}
164+
#endif

include/sdf/Sensor.hh

+16-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace sdf
3838
class Imu;
3939
class Lidar;
4040
class Magnetometer;
41+
class NavSat;
4142
class SensorPrivate;
4243
struct PoseRelativeToGraph;
4344

@@ -109,7 +110,10 @@ namespace sdf
109110
RGBD_CAMERA = 19,
110111

111112
/// \brief A thermal camera sensor
112-
THERMAL_CAMERA = 20
113+
THERMAL_CAMERA = 20,
114+
115+
/// \brief A NavSat sensor, such as GPS.
116+
NAVSAT = 21
113117
};
114118

115119
/// \brief Information about an SDF sensor.
@@ -319,6 +323,17 @@ namespace sdf
319323
/// \sa SensorType Type() const
320324
public: const Camera *CameraSensor() const;
321325

326+
/// \brief Set the NAVSAT sensor.
327+
/// \param[in] _navsat The NAVSAT sensor.
328+
public: void SetNavSatSensor(const NavSat &_navsat);
329+
330+
/// \brief Get a pointer to a NAVSAT sensor, or nullptr if the sensor
331+
/// does not contain an NAVSAT sensor.
332+
/// \return Pointer to the sensor's NAVSAT, or nullptr if the sensor
333+
/// is not an NAVSAT.
334+
/// \sa SensorType Type() const
335+
public: const NavSat *NavSatSensor() const;
336+
322337
/// \brief Set the IMU sensor.
323338
/// \param[in] _imu The IMU sensor.
324339
public: void SetImuSensor(const Imu &_imu);

sdf/1.7/navsat.sdf

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<element name="navsat" required="0">
2+
<description>These elements are specific to the NAVSAT sensor.</description>
3+
4+
<element name="position_sensing" required="0">
5+
<description>
6+
Parameters related to NAVSAT position measurement.
7+
</description>
8+
<element name="horizontal" required="0">
9+
<description>
10+
Noise parameters for horizontal position measurement, in units of meters.
11+
</description>
12+
<include filename="noise.sdf" required="0"/>
13+
</element>
14+
<element name="vertical" required="0">
15+
<description>
16+
Noise parameters for vertical position measurement, in units of meters.
17+
</description>
18+
<include filename="noise.sdf" required="0"/>
19+
</element>
20+
</element>
21+
22+
<element name="velocity_sensing" required="0">
23+
<description>
24+
Parameters related to NAVSAT position measurement.
25+
</description>
26+
<element name="horizontal" required="0">
27+
<description>
28+
Noise parameters for horizontal velocity measurement, in units of meters/second.
29+
</description>
30+
<include filename="noise.sdf" required="0"/>
31+
</element>
32+
<element name="vertical" required="0">
33+
<description>
34+
Noise parameters for vertical velocity measurement, in units of meters/second.
35+
</description>
36+
<include filename="noise.sdf" required="0"/>
37+
</element>
38+
</element>
39+
40+
</element>

sdf/1.7/sensor.sdf

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
logical_camera,
2323
magnetometer,
2424
multicamera,
25+
navsat,
2526
ray,
2627
rfid,
2728
rfidtag,
@@ -30,7 +31,7 @@
3031
thermal_camera, thermal,
3132
wireless_receiver, and
3233
wireless_transmitter.
33-
The "ray" and "gpu_ray" types are equivalent to "lidar" and "gpu_lidar", respectively. It is preferred to use "lidar" and "gpu_lidar" since "ray" and "gpu_ray" will be deprecated. The "ray" and "gpu_ray" types are maintained for legacy support.
34+
The "ray", "gpu_ray", and "gps" types are equivalent to "lidar", "gpu_lidar", and "navsat", respectively. It is preferred to use "lidar", "gpu_lidar", and "navsat" since "ray", "gpu_ray", and "gps" will be deprecated. The "ray", "gpu_ray", and "gps" types are maintained for legacy support.
3435
</description>
3536
</attribute>
3637

@@ -61,6 +62,7 @@
6162
<include filename="lidar.sdf" required="0"/>
6263
<include filename="logical_camera.sdf" required="0"/>
6364
<include filename="magnetometer.sdf" required="0"/>
65+
<include filename="navsat.sdf" required="0"/>
6466
<include filename="ray.sdf" required="0"/>
6567
<include filename="rfid.sdf" required="0"/>
6668
<include filename="rfidtag.sdf" required="0"/>

src/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ set (sources
4343
Material.cc
4444
Mesh.cc
4545
Model.cc
46+
NavSat.cc
4647
Noise.cc
4748
parser.cc
4849
parser_urdf.cc
@@ -122,6 +123,7 @@ if (BUILD_SDF_TEST)
122123
Material_TEST.cc
123124
Mesh_TEST.cc
124125
Model_TEST.cc
126+
NavSat_TEST.cc
125127
Noise_TEST.cc
126128
parser_urdf_TEST.cc
127129
Param_TEST.cc

0 commit comments

Comments
 (0)