Apollo 10.0
自动驾驶开放平台
worker_cyber_node.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 *****************************************************************************/
17
18#include <memory>
19#include <string>
20
23
24constexpr double kRADIANS_TO_DEGREES = 180.0 / M_PI;
25constexpr double kDEGRESS_TO_RADIANS = M_PI / 180.0;
26
27namespace apollo {
28namespace hdmap {
29
31 std::shared_ptr<MapDataCheckerAgent> agent, bool *init_success) {
32 if (!agent) {
33 AFATAL << "MapDataCheckerAgent pointer is nullptr";
34 *init_success = false;
35 return;
36 }
37
38 agent_ = agent->GetWorkerAgent();
39 node_ = apollo::cyber::CreateNode(std::string("cybernode_map_datachecker"));
40 if (!node_) {
41 AFATAL << "Create cybertron node failed.";
42 *init_success = false;
43 return;
44 }
45
46 // Readers
47 CreateChannelSubscriber();
48
49 *init_success = true;
50 AINFO << "map-datachecker cyber node create successfully";
51}
52
53int MapDataCheckerCyberNode::CreateChannelSubscriber() {
54 AINFO << "create bestgnsspos reader, topic: " << FLAGS_topic_bestgnsspos;
55 bestgnsspos_reader_ = node_->CreateReader<GnssBestPose_t>(
56 FLAGS_topic_bestgnsspos,
57 [this](const std::shared_ptr<const GnssBestPose_t> &msg) {
58 agent_->GetSpPoseCollectionAgent()->OnBestgnssposCallback(msg);
59 });
60 if (!bestgnsspos_reader_) {
61 AFATAL << "create bestgnsspos reader error";
62 return -1;
63 }
64 return 0;
65}
66
67} // namespace hdmap
68} // namespace apollo
MapDataCheckerCyberNode(std::shared_ptr< MapDataCheckerAgent > agent, bool *init_success)
apollo::drivers::gnss::GnssBestPose GnssBestPose_t
#define AFATAL
Definition log.h:45
#define AINFO
Definition log.h:42
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
Definition cyber.cc:33
class register implement
Definition arena_queue.h:37
constexpr double kDEGRESS_TO_RADIANS
constexpr double kRADIANS_TO_DEGREES