Skip to content

Commit

Permalink
Fixed gps heading correction bug
Browse files Browse the repository at this point in the history
  • Loading branch information
artzha committed Dec 10, 2024
1 parent 3850fd9 commit 0d47c47
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions math/gps_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

using Eigen::Rotation2Dd;
using Eigen::Vector2d;
using math_util::AngleMod;
using math_util::DegToRad;
using std::string;

Expand Down Expand Up @@ -197,7 +198,9 @@ inline Eigen::Vector2d gpsToGlobalCoord(const GPSPoint& p0,
}

inline double gpsToGlobalHeading(const GPSPoint& p0) {
return DegToRad(90.0 - p0.heading);
double heading =
M_PI / 2.0 - DegToRad(p0.heading); // convert to radians expected REP 105
return AngleMod(heading);
}

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

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

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

0 comments on commit 0d47c47

Please sign in to comment.