Skip to content

Commit 6e71e41

Browse files
Merge pull request #28 from SteveMacenski/master
ROS2 port of geographic_msgs and geographic_info for robot_localization
2 parents e9291ea + 42ba053 commit 6e71e41

21 files changed

+161
-205
lines changed

geodesy/CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Change history
22
==============
33

4+
0.5.3 (2018-03-27)
5+
------------------
6+
47
0.5.2 (2017-04-15)
58
------------------
69

geodesy/CMakeLists.txt

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,41 @@
1-
# http://ros.org/doc/groovy/api/catkin/html/user_guide/supposed.html
2-
cmake_minimum_required(VERSION 2.8.3)
1+
cmake_minimum_required(VERSION 3.5)
32
project(geodesy)
4-
find_package(catkin REQUIRED
5-
COMPONENTS
6-
angles
7-
geographic_msgs
8-
geometry_msgs
9-
sensor_msgs
10-
tf
11-
unique_id
12-
uuid_msgs)
3+
find_package(ament_cmake REQUIRED)
4+
find_package(angles REQUIRED)
5+
find_package(geographic_msgs REQUIRED)
6+
find_package(geometry_msgs REQUIRED)
7+
find_package(sensor_msgs REQUIRED)
8+
find_package(unique_identifier_msgs REQUIRED)
139

14-
include_directories(include ${catkin_INCLUDE_DIRS})
15-
catkin_python_setup()
10+
include_directories(
11+
include
12+
)
1613

17-
# what other packages will need to use this one
18-
catkin_package(CATKIN_DEPENDS
19-
geographic_msgs
20-
geometry_msgs
21-
sensor_msgs
22-
tf
23-
unique_id
24-
uuid_msgs
25-
INCLUDE_DIRS include
26-
LIBRARIES geoconv)
14+
set(dependencies
15+
angles
16+
geographic_msgs
17+
geometry_msgs
18+
sensor_msgs
19+
unique_identifier_msgs
20+
)
21+
22+
ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR src/${PROJECT_NAME})
2723

2824
# build C++ coordinate conversion library
29-
add_library(geoconv src/conv/utm_conversions.cpp)
30-
target_link_libraries(geoconv ${catkin_LIBRARIES})
31-
add_dependencies(geoconv ${catkin_EXPORTED_TARGETS})
25+
add_library(geoconv STATIC src/conv/utm_conversions.cpp)
26+
ament_target_dependencies(geoconv
27+
${dependencies}
28+
)
3229

3330
install(DIRECTORY include/${PROJECT_NAME}/
34-
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
31+
DESTINATION include/${PROJECT_NAME}/)
3532
install(TARGETS geoconv
36-
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
37-
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
38-
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
39-
40-
# unit tests
41-
if (CATKIN_ENABLE_TESTING)
42-
43-
catkin_add_gtest(test_wgs84 tests/test_wgs84.cpp)
44-
target_link_libraries(test_wgs84 ${catkin_LIBRARIES})
45-
add_dependencies(test_wgs84 ${catkin_EXPORTED_TARGETS})
46-
47-
catkin_add_gtest(test_utm tests/test_utm.cpp)
48-
target_link_libraries(test_utm geoconv ${catkin_LIBRARIES})
49-
add_dependencies(test_utm ${catkin_EXPORTED_TARGETS})
50-
51-
catkin_add_nosetests(tests/test_bounding_box.py)
52-
catkin_add_nosetests(tests/test_props.py)
53-
catkin_add_nosetests(tests/test_utm.py)
54-
catkin_add_nosetests(tests/test_wu_point.py)
33+
ARCHIVE DESTINATION lib
34+
LIBRARY DESTINATION lib
35+
RUNTIME DESTINATION lib/${PROJECT_NAME}
36+
)
5537

56-
endif (CATKIN_ENABLE_TESTING)
38+
ament_export_dependencies(${dependencies})
39+
ament_export_include_directories(include)
40+
ament_export_libraries(geoconv)
41+
ament_package()

geodesy/include/geodesy/utm.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
#include <iostream>
4444
#include <iomanip>
4545

46-
#include <tf/tf.h>
47-
4846
#include <geodesy/wgs84.h>
49-
#include <geometry_msgs/Point.h>
50-
#include <geometry_msgs/Pose.h>
47+
#include "geographic_msgs/msg/geo_point.hpp"
48+
#include "geometry_msgs/msg/point.hpp"
49+
#include "geographic_msgs/msg/geo_pose.hpp"
50+
#include "geometry_msgs/msg/pose.hpp"
5151

5252
/** @file
5353
@@ -101,7 +101,7 @@ class UTMPoint
101101
band(that.band)
102102
{}
103103

104-
UTMPoint(const geographic_msgs::GeoPoint &pt);
104+
UTMPoint(const geographic_msgs::msg::GeoPoint &pt);
105105

106106
/** Create a flattened 2-D grid point. */
107107
UTMPoint(double _easting, double _northing, uint8_t _zone, char _band):
@@ -149,36 +149,36 @@ class UTMPose
149149
{}
150150

151151
/** Create from a WGS 84 geodetic pose. */
152-
UTMPose(const geographic_msgs::GeoPose &pose):
152+
UTMPose(const geographic_msgs::msg::GeoPose &pose):
153153
position(pose.position),
154154
orientation(pose.orientation)
155155
{}
156156

157157
/** Create from a UTMPoint and a quaternion. */
158158
UTMPose(UTMPoint pt,
159-
const geometry_msgs::Quaternion &q):
159+
const geometry_msgs::msg::Quaternion &q):
160160
position(pt),
161161
orientation(q)
162162
{}
163163

164164
/** Create from a WGS 84 geodetic point and a quaternion. */
165-
UTMPose(const geographic_msgs::GeoPoint &pt,
166-
const geometry_msgs::Quaternion &q):
165+
UTMPose(const geographic_msgs::msg::GeoPoint &pt,
166+
const geometry_msgs::msg::Quaternion &q):
167167
position(pt),
168168
orientation(q)
169169
{}
170170

171171
// data members
172172
UTMPoint position;
173-
geometry_msgs::Quaternion orientation;
173+
geometry_msgs::msg::Quaternion orientation;
174174

175175
}; // class UTMPose
176176

177177
// conversion function prototypes
178-
void fromMsg(const geographic_msgs::GeoPoint &from, UTMPoint &to);
179-
void fromMsg(const geographic_msgs::GeoPose &from, UTMPose &to);
180-
geographic_msgs::GeoPoint toMsg(const UTMPoint &from);
181-
geographic_msgs::GeoPose toMsg(const UTMPose &from);
178+
void fromMsg(const geographic_msgs::msg::GeoPoint &from, UTMPoint &to);
179+
void fromMsg(const geographic_msgs::msg::GeoPose &from, UTMPose &to);
180+
geographic_msgs::msg::GeoPoint toMsg(const UTMPoint &from);
181+
geographic_msgs::msg::GeoPose toMsg(const UTMPose &from);
182182

183183
/** @return true if no altitude specified. */
184184
static inline bool is2D(const UTMPoint &pt)
@@ -203,7 +203,7 @@ bool isValid(const UTMPose &pose);
203203
*/
204204
static inline void normalize(UTMPoint &pt)
205205
{
206-
geographic_msgs::GeoPoint ll(toMsg(pt));
206+
geographic_msgs::msg::GeoPoint ll(toMsg(pt));
207207
normalize(ll);
208208
fromMsg(ll, pt);
209209
}
@@ -241,19 +241,19 @@ static inline bool sameGridZone(const UTMPose &pose1, const UTMPose &pose2)
241241
}
242242

243243
/** @return a geometry Point corresponding to a UTM point. */
244-
static inline geometry_msgs::Point toGeometry(const UTMPoint &from)
244+
static inline geometry_msgs::msg::Point toGeometry(const UTMPoint &from)
245245
{
246-
geometry_msgs::Point to;
246+
geometry_msgs::msg::Point to;
247247
to.x = from.easting;
248248
to.y = from.northing;
249249
to.z = from.altitude;
250250
return to;
251251
}
252252

253253
/** @return a geometry Pose corresponding to a UTM pose. */
254-
static inline geometry_msgs::Pose toGeometry(const UTMPose &from)
254+
static inline geometry_msgs::msg::Pose toGeometry(const UTMPose &from)
255255
{
256-
geometry_msgs::Pose to;
256+
geometry_msgs::msg::Pose to;
257257
to.position = toGeometry(from.position);
258258
to.orientation = from.orientation;
259259
return to;

geodesy/include/geodesy/wgs84.h

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@
4040

4141
#include <limits>
4242
#include <ctype.h>
43-
#include <geographic_msgs/GeoPoint.h>
44-
#include <geographic_msgs/GeoPose.h>
45-
#include <sensor_msgs/NavSatFix.h>
46-
#include <tf/tf.h>
43+
#include "geographic_msgs/msg/geo_point.hpp"
44+
#include "geographic_msgs/msg/geo_pose.hpp"
45+
#include "sensor_msgs/msg/nav_sat_fix.hpp"
46+
47+
#define TF_QUATERNION_TOLERANCE 0.1
4748

4849
/** @file
4950
@@ -82,8 +83,8 @@ namespace geodesy
8283
* @param from WGS 84 point message.
8384
* @param to another point.
8485
*/
85-
static inline void fromMsg(const geographic_msgs::GeoPoint &from,
86-
geographic_msgs::GeoPoint &to)
86+
static inline void fromMsg(const geographic_msgs::msg::GeoPoint &from,
87+
geographic_msgs::msg::GeoPoint &to)
8788
{
8889
convert(from, to);
8990
}
@@ -93,26 +94,26 @@ namespace geodesy
9394
* @param from WGS 84 pose message.
9495
* @param to another pose.
9596
*/
96-
static inline void fromMsg(const geographic_msgs::GeoPose &from,
97-
geographic_msgs::GeoPose &to)
97+
static inline void fromMsg(const geographic_msgs::msg::GeoPose &from,
98+
geographic_msgs::msg::GeoPose &to)
9899
{
99100
convert(from, to);
100101
}
101102

102103
/** @return true if no altitude specified. */
103-
static inline bool is2D(const geographic_msgs::GeoPoint &pt)
104+
static inline bool is2D(const geographic_msgs::msg::GeoPoint &pt)
104105
{
105106
return (pt.altitude != pt.altitude);
106107
}
107108

108109
/** @return true if pose has no altitude. */
109-
static inline bool is2D(const geographic_msgs::GeoPose &pose)
110+
static inline bool is2D(const geographic_msgs::msg::GeoPose &pose)
110111
{
111112
return is2D(pose.position);
112113
}
113114

114115
/** @return true if point is valid. */
115-
static inline bool isValid(const geographic_msgs::GeoPoint &pt)
116+
static inline bool isValid(const geographic_msgs::msg::GeoPoint &pt)
116117
{
117118
if (pt.latitude < -90.0 || pt.latitude > 90.0)
118119
return false;
@@ -124,14 +125,14 @@ namespace geodesy
124125
}
125126

126127
/** @return true if pose is valid. */
127-
static inline bool isValid(const geographic_msgs::GeoPose &pose)
128+
static inline bool isValid(const geographic_msgs::msg::GeoPose &pose)
128129
{
129130
// check that orientation quaternion is normalized
130131
double len2 = (pose.orientation.x * pose.orientation.x
131132
+ pose.orientation.y * pose.orientation.y
132133
+ pose.orientation.z * pose.orientation.z
133134
+ pose.orientation.w * pose.orientation.w);
134-
if (fabs(len2 - 1.0) > tf::QUATERNION_TOLERANCE)
135+
if (fabs(len2 - 1.0) > TF_QUATERNION_TOLERANCE)
135136
return false;
136137

137138
return isValid(pose.position);
@@ -144,60 +145,60 @@ namespace geodesy
144145
* Normalizes the longitude to [-180, 180).
145146
* Clamps latitude to [-90, 90].
146147
*/
147-
static inline void normalize(geographic_msgs::GeoPoint &pt)
148+
static inline void normalize(geographic_msgs::msg::GeoPoint &pt)
148149
{
149150
pt.longitude =
150151
(fmod(fmod((pt.longitude + 180.0), 360.0) + 360.0, 360.0) - 180.0);
151152
pt.latitude = std::min(std::max(pt.latitude, -90.0), 90.0);
152153
}
153154

154155
/** @return a 2D WGS 84 geodetic point message. */
155-
static inline geographic_msgs::GeoPoint toMsg(double lat, double lon)
156+
static inline geographic_msgs::msg::GeoPoint toMsg(double lat, double lon)
156157
{
157-
geographic_msgs::GeoPoint pt;
158+
geographic_msgs::msg::GeoPoint pt;
158159
pt.latitude = lat;
159160
pt.longitude = lon;
160161
pt.altitude = std::numeric_limits<double>::quiet_NaN();
161162
return pt;
162163
}
163164

164165
/** @return a 3D WGS 84 geodetic point message. */
165-
static inline geographic_msgs::GeoPoint
166+
static inline geographic_msgs::msg::GeoPoint
166167
toMsg(double lat, double lon, double alt)
167168
{
168-
geographic_msgs::GeoPoint pt;
169+
geographic_msgs::msg::GeoPoint pt;
169170
pt.latitude = lat;
170171
pt.longitude = lon;
171172
pt.altitude = alt;
172173
return pt;
173174
}
174175

175176
/** @return a WGS 84 geodetic point message from a NavSatFix. */
176-
static inline geographic_msgs::GeoPoint
177-
toMsg(const sensor_msgs::NavSatFix &fix)
177+
static inline geographic_msgs::msg::GeoPoint
178+
toMsg(const sensor_msgs::msg::NavSatFix &fix)
178179
{
179-
geographic_msgs::GeoPoint pt;
180+
geographic_msgs::msg::GeoPoint pt;
180181
pt.latitude = fix.latitude;
181182
pt.longitude = fix.longitude;
182183
pt.altitude = fix.altitude;
183184
return pt;
184185
}
185186

186187
/** @return a WGS 84 geodetic point message from another. */
187-
static inline geographic_msgs::GeoPoint
188-
toMsg(const geographic_msgs::GeoPoint &from)
188+
static inline geographic_msgs::msg::GeoPoint
189+
toMsg(const geographic_msgs::msg::GeoPoint &from)
189190
{
190191
return from;
191192
}
192193

193194
/** @return a WGS 84 geodetic pose message from a point and a
194195
* quaternion.
195196
*/
196-
static inline geographic_msgs::GeoPose
197-
toMsg(const geographic_msgs::GeoPoint &pt,
198-
const geometry_msgs::Quaternion &q)
197+
static inline geographic_msgs::msg::GeoPose
198+
toMsg(const geographic_msgs::msg::GeoPoint &pt,
199+
const geometry_msgs::msg::Quaternion &q)
199200
{
200-
geographic_msgs::GeoPose pose;
201+
geographic_msgs::msg::GeoPose pose;
201202
pose.position = pt;
202203
pose.orientation = q;
203204
return pose;
@@ -206,19 +207,19 @@ namespace geodesy
206207
/** @return a WGS 84 geodetic pose message from a NavSatFix and a
207208
* quaternion.
208209
*/
209-
static inline geographic_msgs::GeoPose
210-
toMsg(const sensor_msgs::NavSatFix &fix,
211-
const geometry_msgs::Quaternion &q)
210+
static inline geographic_msgs::msg::GeoPose
211+
toMsg(const sensor_msgs::msg::NavSatFix &fix,
212+
const geometry_msgs::msg::Quaternion &q)
212213
{
213-
geographic_msgs::GeoPose pose;
214+
geographic_msgs::msg::GeoPose pose;
214215
pose.position = toMsg(fix);
215216
pose.orientation = q;
216217
return pose;
217218
}
218219

219220
/** @return a WGS 84 geodetic pose message from another. */
220-
static inline geographic_msgs::GeoPose
221-
toMsg(const geographic_msgs::GeoPose &from)
221+
static inline geographic_msgs::msg::GeoPose
222+
toMsg(const geographic_msgs::msg::GeoPose &from)
222223
{
223224
return from;
224225
}

0 commit comments

Comments
 (0)