Apollo 10.0
自动驾驶开放平台
gps_monitor.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
18
19#include "cyber/common/log.h"
22#include "modules/common_msgs/sensor_msgs/gnss_best_pose.pb.h"
25
26DEFINE_string(gps_monitor_name, "GpsMonitor", "Name of the GPS monitor.");
27DEFINE_double(gps_monitor_interval, 3, "GPS status checking interval (s).");
28DEFINE_string(gps_component_name, "GPS", "GPS component name.");
29
30namespace apollo {
31namespace monitor {
32
35
37 : RecurrentRunner(FLAGS_gps_monitor_name, FLAGS_gps_monitor_interval) {}
38
39void GpsMonitor::RunOnce(const double current_time) {
40 auto manager = MonitorManager::Instance();
41 Component* component = apollo::common::util::FindOrNull(
42 *manager->GetStatus()->mutable_components(), FLAGS_gps_component_name);
43 if (component == nullptr) {
44 // GPS is not monitored in current mode, skip.
45 return;
46 }
47 ComponentStatus* component_status = component->mutable_other_status();
48 component_status->clear_status();
49
50 static auto gnss_best_pose_reader =
51 manager->CreateReader<GnssBestPose>(FLAGS_gnss_best_pose_topic);
52 gnss_best_pose_reader->Observe();
53 const auto gnss_best_pose_status = gnss_best_pose_reader->GetLatestObserved();
54 if (gnss_best_pose_status == nullptr) {
55 SummaryMonitor::EscalateStatus(ComponentStatus::ERROR,
56 "No GnssBestPose message", component_status);
57 return;
58 }
59 switch (gnss_best_pose_status->sol_type()) {
60 case SolutionType::NARROW_INT:
61 SummaryMonitor::EscalateStatus(ComponentStatus::OK, "", component_status);
62 break;
63 case SolutionType::SINGLE:
65 ComponentStatus::WARN, "SolutionType is SINGLE", component_status);
66 break;
67 default:
68 SummaryMonitor::EscalateStatus(ComponentStatus::ERROR,
69 "SolutionType is wrong", component_status);
70 break;
71 }
72}
73
74} // namespace monitor
75} // namespace apollo
void RunOnce(const double current_time) override
static void EscalateStatus(const ComponentStatus::Status new_status, const std::string &message, ComponentStatus *current_status)
DEFINE_double(gps_monitor_interval, 3, "GPS status checking interval (s).")
DEFINE_string(gps_monitor_name, "GpsMonitor", "Name of the GPS monitor.")
Some map util functions.
class register implement
Definition arena_queue.h:37