17#include "modules/common_msgs/planning_msgs/pad_msg.pb.h"
18#include "modules/planning/planning_base/proto/planning_config.pb.h"
40 PadTerminal() : node_(
CreateNode(
"planning_pad_terminal")) {}
42 const std::string planning_config_file =
43 "/apollo/modules/planning/planning_component/conf/"
44 "planning_config.pb.txt";
45 PlanningConfig planning_config;
47 <<
"failed to load planning config file " << planning_config_file;
49 pad_writer_ = node_->CreateWriter<PadMessage>(
50 planning_config.topic_config().planning_pad_topic());
51 terminal_thread_.reset(
new std::thread([
this] { terminal_thread_func(); }));
54 AINFO <<
"COMMAND:0~10\n";
55 AINFO <<
"\t0: follow";
56 AINFO <<
"\t1: change left";
57 AINFO <<
"\t2: change right";
58 AINFO <<
"\t3: pull over";
60 AINFO <<
"\t5: resume cruise";
61 AINFO <<
"\t10: exit";
62 AINFO <<
"\tother number: print help";
65 void send(
int action) {
67 pad.set_action(PadMessage::DrivingAction(action));
68 if (action == PadMessage::FOLLOW) {
69 AINFO <<
"sending FOLLOW action command.";
70 }
else if (action == PadMessage::CHANGE_LEFT) {
71 AINFO <<
"sending CHANGE LEFT action command.";
72 }
else if (action == PadMessage::CHANGE_RIGHT) {
73 AINFO <<
"sending CHANGE RIGHT action command.";
74 }
else if (action == PadMessage::PULL_OVER) {
75 AINFO <<
"sending PULL OVER action command.";
76 }
else if (action == PadMessage::STOP) {
77 AINFO <<
"sending STOP action command.";
78 }
else if (action == PadMessage::RESUME_CRUISE) {
79 AINFO <<
"sending RESUME CRUISE action command.";
81 apollo::common::util::FillHeader(
"terminal", &pad);
82 pad_writer_->Write(pad);
83 AINFO <<
"send pad_message OK";
86 void terminal_thread_func() {
88 bool should_exit =
false;
89 while (std::cin >> mode) {
92 send(PadMessage::FOLLOW);
95 send(PadMessage::CHANGE_LEFT);
98 send(PadMessage::CHANGE_RIGHT);
101 send(PadMessage::PULL_OVER);
104 send(PadMessage::STOP);
107 send(PadMessage::RESUME_CRUISE);
121 void stop() { terminal_thread_->join(); }
124 std::unique_ptr<std::thread> terminal_thread_;
125 std::shared_ptr<Writer<PadMessage>> pad_writer_;
126 std::shared_ptr<Node> node_;
131int main(
int argc,
char **argv) {
133 FLAGS_alsologtostderr =
true;
135 google::ParseCommandLineFlags(&argc, &argv,
true);
136 PadTerminal pad_terminal;
Node is the fundamental building block of Cyber RT.
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,...
bool Init(const char *binary_name, const std::string &dag_info)
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)