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