Hardware Architecture Diagram
You can see that the "GNSS positioning module" in the lower left corner is actually composed of IMU and GPS Antenna.
perform analysis
the code
class GpsMonitor : public RecurrentRunner {
public:
GpsMonitor();
void RunOnce(const double current_time) override;
};
void GpsMonitor::RunOnce(const double current_time) {
auto manager = MonitorManager::Instance();
Component* component = apollo::common::util::FindOrNull(
*manager->GetStatus()->mutable_components(), FLAGS_gps_component_name);
if (component == nullptr) {
// GPS is not monitored in current mode, skip.
return;
}
ComponentStatus* component_status = component->mutable_other_status();
component_status->clear_status();
static auto gnss_best_pose_reader =
manager->CreateReader<GnssBestPose>(FLAGS_gnss_best_pose_topic);
gnss_best_pose_reader->Observe();
const auto gnss_best_pose_status = gnss_best_pose_reader->GetLatestObserved();
if (gnss_best_pose_status == nullptr) {
SummaryMonitor::EscalateStatus(ComponentStatus::ERROR,
"No GnssBestPose message", component_status);
return;
}
switch (gnss_best_pose_status->sol_type()) {
case SolutionType::NARROW_INT:
SummaryMonitor::EscalateStatus(ComponentStatus::OK, "", component_status);
break;
case SolutionType::SINGLE:
SummaryMonitor::EscalateStatus(
ComponentStatus::WARN, "SolutionType is SINGLE", component_status);
break;
default:
SummaryMonitor::EscalateStatus(ComponentStatus::ERROR,
"SolutionType is wrong", component_status);
break;
}
}
analyze
The core content of gps monitor is only 70 line code
The basic idea is as follows:
- Find out whether GPS is a configured monitoring component from the configuration file
- If yes, subscribe to GnssBestPose topic and receive data
- Get the latest data, if the latest data is null, issue an ERROR level fault
- If the obtained data type is NARROW_INT, it means normal
- If the obtained data type is SINGLE, it means WARN
- Here, according to Apollo's positioning algorithm design and hardware architecture, it is not difficult to guess that SINGLE means IMU inertial unit or GPS has no normal output data
- If the obtained data type is other cases, it means ERROR
Both GnssBestPose and SolutionType are defined from GNSS driver.
modules/drivers/gnss/proto/gnss_best_pose.proto
enum SolutionType {
NONE = 0;
FIXEDPOS = 1;
FIXEDHEIGHT = 2;
FLOATCONV = 4;
WIDELANE = 5;
NARROWLANE = 6;
DOPPLER_VELOCITY = 8;
SINGLE = 16;
PSRDIFF = 17;
WAAS = 18;
PROPOGATED = 19;
OMNISTAR = 20;
L1_FLOAT = 32;
IONOFREE_FLOAT = 33;
NARROW_FLOAT = 34;
L1_INT = 48;
WIDE_INT = 49;
NARROW_INT = 50;
RTK_DIRECT_INS =
51; // RTK filter is directly initialized from the INS filter.
INS_SBAS = 52;
INS_PSRSP = 53;
INS_PSRDIFF = 54;
INS_RTKFLOAT = 55;
INS_RTKFIXED = 56;
INS_OMNISTAR = 57;
INS_OMNISTAR_HP = 58;
INS_OMNISTAR_XP = 59;
OMNISTAR_HP = 64;
OMNISTAR_XP = 65;
PPP_CONVERGING = 68;
PPP = 69;
INS_PPP_CONVERGING = 73;
INS_PPP = 74;
}