Skip to content

Commit 0d47c47

Browse files
committed
Fixed gps heading correction bug
1 parent 3850fd9 commit 0d47c47

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

math/gps_util.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
using Eigen::Rotation2Dd;
1515
using Eigen::Vector2d;
16+
using math_util::AngleMod;
1617
using math_util::DegToRad;
1718
using std::string;
1819

@@ -197,7 +198,9 @@ inline Eigen::Vector2d gpsToGlobalCoord(const GPSPoint& p0,
197198
}
198199

199200
inline double gpsToGlobalHeading(const GPSPoint& p0) {
200-
return DegToRad(90.0 - p0.heading);
201+
double heading =
202+
M_PI / 2.0 - DegToRad(p0.heading); // convert to radians expected REP 105
203+
return AngleMod(heading);
201204
}
202205

203206
inline Eigen::Affine2f gpsToLocal(const GPSPoint& current,
@@ -206,9 +209,9 @@ inline Eigen::Affine2f gpsToLocal(const GPSPoint& current,
206209
const auto& dvec = gpsToGlobalCoord(current, goal);
207210

208211
// Step 2: Convert the current heading to radians and adjust for x-axis
209-
// reference Since 0 degrees points along the y-axis and rotates
210-
// counter-clockwise, convert to radians with 0 degrees aligned along the
211-
// x-axis
212+
// reference Since 0 degrees pogpsToGlobalHeadingints along the y-axis and
213+
// rotates counter-clockwise, convert to radians with 0 degrees aligned along
214+
// the x-axis
212215
double current_heading_rad = (90.0 - current.heading) * M_PI / 180.0;
213216

214217
// Step 3: Rotate the translation vector to the robot's local frame

0 commit comments

Comments
 (0)