硬件架构图
可以看到左下角的“GNSS定位模块”其实是有IMU和GPS Antenna 组成的。
执行分析
代码
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;
}
}
分析
gps monitor 核心内容就70 line code
基本思路如下:
- 从配置文件中查找GPS是否是被配置的监控组件
- 如果是的话,订阅GnssBestPose topic,并收取数据
- 获取最新的数据,如果最新的数据为null,发出ERROR级别的故障
- 如果获取的数据类型为NARROW_INT,表示正常
- 如果获取的数据类型为SINGLE,表示WARN
- 这里根据apollo 的定位算法设计与硬件架构,不难猜SINGLE 代表IMU 惯性单元或GPS有一个没有正常输出数据
- 如果获取的数据类型为其他情况,表示ERROR
GnssBestPose 和 SolutionType 的定义都来自 GNSS 驱动。
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;
}