Apollo 11.0
自动驾驶开放平台
navigation_dummy.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
17#include "gflags/gflags.h"
18
19#include "cyber/common/file.h"
20#include "cyber/common/log.h"
21#include "cyber/cyber.h"
22#include "cyber/time/rate.h"
25#include "modules/common_msgs/planning_msgs/navigation.pb.h"
26
28
29DEFINE_string(navigation_dummy_file,
30 "modules/map/testdata/navigation_dummy/navigation_info.pb.txt",
31 "Used for sending navigation result to relative_map node.");
32
33int main(int argc, char** argv) {
34 google::ParseCommandLineFlags(&argc, &argv, true);
35 // Init the cyber framework
36 apollo::cyber::Init(argv[0]);
37 FLAGS_alsologtostderr = true;
38
40 if (!apollo::cyber::common::GetProtoFromFile(FLAGS_navigation_dummy_file,
41 &navigation_info)) {
42 AERROR << "failed to load file: " << FLAGS_navigation_dummy_file;
43 return -1;
44 }
45
46 std::shared_ptr<apollo::cyber::Node> node(
47 apollo::cyber::CreateNode("navigation_info"));
48 auto writer = node->CreateWriter<apollo::relative_map::NavigationInfo>(
49 FLAGS_navigation_topic);
50 Rate rate(0.3);
51
52 while (apollo::cyber::OK()) {
53 apollo::common::util::FillHeader(node->Name(), &navigation_info);
54 writer->Write(navigation_info);
55 ADEBUG << "Sending navigation info:" << navigation_info.DebugString();
56 rate.Sleep();
57 }
58
59 return 0;
60}
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
Some string util functions.
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
bool Init(const char *binary_name, const std::string &dag_info)
Definition init.cc:99
bool OK()
Definition state.h:44
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
Definition cyber.cc:33
int main(int argc, char **argv)
DEFINE_string(navigation_dummy_file, "modules/map/testdata/navigation_dummy/navigation_info.pb.txt", "Used for sending navigation result to relative_map node.")