Skip to content

Commit

Permalink
Merge branch 'master' into myocpn
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakansv committed Jan 19, 2025
2 parents be420ad + b06a51d commit f4d21b9
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions gui/src/ocpn_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5214,21 +5214,22 @@ void MyFrame::HandleBasicNavMsg(std::shared_ptr<const BasicNavDataMsg> msg) {
gSog_gt = gSog;
fix_time_gt = fix_time_gt_now;

if (std::isnan(gCog_gt_m1)) return; // Startup

if ((fabs(gSog - implied_sog) / gSog) > 0.5) {
// Probably a synthetic data stream, with multiple position sources.
// Do not try to interpolate position at 10 Hz.
gSog_gt = 0;
cog_rate_gt = 0;
} else {
// Calculate an estimated Rate-of-turn
double diff = gCog_gt - gCog_gt_m1;
double tentative_cog_rate_gt = diff / (fix_time_gt - fix_time_gt_last);
tentative_cog_rate_gt *= 1e9; // degrees / sec
// Sanity check, and resolve the "phase" problem at +/- North
if (fabs(tentative_cog_rate_gt - cog_rate_gt) < 180.)
cog_rate_gt = tentative_cog_rate_gt;
if (!std::isnan(gCog_gt_m1)) { // Startup
if ((fabs(gSog - implied_sog) / gSog) > 0.5) {
// Probably a synthetic data stream, with multiple position sources.
// Do not try to interpolate position at 10 Hz.
gSog_gt = 0;
cog_rate_gt = 0;
} else {
// Calculate an estimated Rate-of-turn
double diff = gCog_gt - gCog_gt_m1;
double tentative_cog_rate_gt =
diff / (fix_time_gt - fix_time_gt_last);
tentative_cog_rate_gt *= 1e9; // degrees / sec
// Sanity check, and resolve the "phase" problem at +/- North
if (fabs(tentative_cog_rate_gt - cog_rate_gt) < 180.)
cog_rate_gt = tentative_cog_rate_gt;
}
}
}
} else if ((msg->vflag & HDT_UPDATE) == HDT_UPDATE) {
Expand All @@ -5244,18 +5245,19 @@ void MyFrame::HandleBasicNavMsg(std::shared_ptr<const BasicNavDataMsg> msg) {
gHdt_gt_m1 = gHdt_gt;
gHdt_gt = gHdt;

if (std::isnan(gHdt_gt_m1)) return; // startup

// Calculate an estimated Rate-of-change of gHdt
double tentative_hdt_rate_gt =
(gHdt_gt - gHdt_gt_m1) / (hdt_time_gt - hdt_time_gt_last);
tentative_hdt_rate_gt *= 1e9; // degrees / sec
// Sanity check, and resolve the "phase" problem at +/- North
if (fabs(tentative_hdt_rate_gt - hdt_rate_gt) < 180.)
hdt_rate_gt = tentative_hdt_rate_gt;
if (!std::isnan(gHdt_gt_m1)) { // startup
// Calculate an estimated Rate-of-change of gHdt
double tentative_hdt_rate_gt =
(gHdt_gt - gHdt_gt_m1) / (hdt_time_gt - hdt_time_gt_last);
tentative_hdt_rate_gt *= 1e9; // degrees / sec
// Sanity check, and resolve the "phase" problem at +/- North
if (fabs(tentative_hdt_rate_gt - hdt_rate_gt) < 180.)
hdt_rate_gt = tentative_hdt_rate_gt;
}
}
}
}

if (std::isnan(gHdt)) gHdt_gt = NAN; // Handle loss of signal

// Some housekeeping
Expand Down

0 comments on commit f4d21b9

Please sign in to comment.