Skip to content

Commit 3850fd9

Browse files
committed
Added support for gps heading correction
1 parent f138093 commit 3850fd9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

math/gps_util.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ inline double gpsDistance(const GPSPoint& p0, const GPSPoint& p1) {
166166
const auto& [lat0, lon0] = std::make_tuple(p0.lat, p0.lon);
167167
const auto& [lat1, lon1] = std::make_tuple(p1.lat, p1.lon);
168168
// Convert latitude and longitude to radians
169-
double lat0_rad = p0.lat * M_PI / 180.0;
170-
double lon0_rad = p0.lon * M_PI / 180.0;
171-
double lat1_rad = p1.lat * M_PI / 180.0;
172-
double lon1_rad = p1.lon * M_PI / 180.0;
169+
double lat0_rad = lat0 * M_PI / 180.0;
170+
double lon0_rad = lon0 * M_PI / 180.0;
171+
double lat1_rad = lat1 * M_PI / 180.0;
172+
double lon1_rad = lon1 * M_PI / 180.0;
173173

174174
// Haversine formula for distance between two GPS coordinates
175175
double dlat = lat1_rad - lat0_rad;
@@ -196,6 +196,10 @@ inline Eigen::Vector2d gpsToGlobalCoord(const GPSPoint& p0,
196196
return {e1 - e0, n1 - n0}; // x y
197197
}
198198

199+
inline double gpsToGlobalHeading(const GPSPoint& p0) {
200+
return DegToRad(90.0 - p0.heading);
201+
}
202+
199203
inline Eigen::Affine2f gpsToLocal(const GPSPoint& current,
200204
const GPSPoint& goal) {
201205
// Step 1: Convert the GPS coordinates to global coordinates

0 commit comments

Comments
 (0)