50 &control_.control_pipeline_)) {
51 AERROR <<
"Unable to load control conf file: " << FLAGS_pipeline_file;
55 AINFO <<
"Pipeline file: " << FLAGS_pipeline_file <<
" is loaded.";
58 control_.injector_ = std::make_shared<DependencyInjector>();
60 if (!control_.control_task_agent_
61 .
Init(control_.injector_, control_.control_pipeline_)
63 AERROR <<
"Control init controller failed! Stopping...";
66 control_.control_task_agent_.
Reset();
69 if (!FLAGS_test_pad_file.empty()) {
70 AINFO <<
"Into the pad load file.";
73 FLAGS_test_data_dir + FLAGS_test_pad_file, &pad_message)) {
74 AERROR <<
"Failed to load PadMesssage from file " << FLAGS_test_data_dir
75 << FLAGS_test_pad_file;
78 control_.OnPad(std::make_shared<apollo::control::PadMessage>(pad_message));
82 if (!FLAGS_test_localization_file.empty()) {
83 AINFO <<
"Into the localization load file.";
86 FLAGS_test_data_dir + FLAGS_test_localization_file,
88 AERROR <<
"Failed to load localization file " << FLAGS_test_data_dir
89 << FLAGS_test_localization_file;
92 control_.OnLocalization(
93 std::make_shared<apollo::localization::LocalizationEstimate>(
98 if (!FLAGS_test_planning_file.empty()) {
99 AINFO <<
"Into the planning load file.";
102 FLAGS_test_data_dir + FLAGS_test_planning_file, &trajectory)) {
103 AERROR <<
"Failed to load planning file " << FLAGS_test_data_dir
104 << FLAGS_test_planning_file;
108 std::make_shared<apollo::planning::ADCTrajectory>(trajectory));
112 if (!FLAGS_test_chassis_file.empty()) {
113 AINFO <<
"Into the chassis load file.";
116 FLAGS_test_data_dir + FLAGS_test_chassis_file, &chassis)) {
117 AERROR <<
"Failed to load chassis file " << FLAGS_test_data_dir
118 << FLAGS_test_chassis_file;
121 control_.OnChassis(std::make_shared<apollo::canbus::Chassis>(chassis));
125 if (!FLAGS_test_monitor_file.empty()) {
126 AINFO <<
"Into the monitor load file.";
129 FLAGS_test_data_dir + FLAGS_test_monitor_file, &monitor_message)) {
130 AERROR <<
"Failed to load monitor file " << FLAGS_test_data_dir
131 << FLAGS_test_monitor_file;
134 control_.OnMonitor(monitor_message);
137 control_.local_view_.mutable_chassis()->CopyFrom(control_.latest_chassis_);
138 control_.local_view_.mutable_trajectory()->CopyFrom(
139 control_.latest_trajectory_);
140 control_.local_view_.mutable_localization()->CopyFrom(
141 control_.latest_localization_);
143 auto err = control_.ProduceControlCommand(&control_command_);
145 ADEBUG <<
"control ProduceControlCommand failed";
148 AINFO <<
"Finish the test_control().";
161 const std::string golden_result_file =
162 absl::StrCat(
"result_", test_case_name,
"_", case_num,
".pb.txt");
163 std::string tmp_golden_path =
"/tmp/" + golden_result_file;
164 std::string full_golden_path = FLAGS_test_data_dir + golden_result_file;
166 control_command_.Clear();
169 AERROR <<
"test control failed";
173 trim_control_command(&control_command_);
174 if (FLAGS_test_update_golden_log) {
175 AINFO <<
"The golden file is " << tmp_golden_path <<
" Remember to:\n"
176 <<
"mv " << tmp_golden_path <<
" " << FLAGS_test_data_dir <<
"\n"
177 <<
"git add " << FLAGS_test_data_dir <<
"/" << golden_result_file;
184 AERROR <<
"Failed to load golden file: " << full_golden_path;
186 AINFO <<
"Current result is written to " << tmp_golden_path;
192 std::string tmp_test_result_file = tmp_golden_path +
".tmp";
194 tmp_test_result_file);
195 AERROR <<
"found diff " << tmp_test_result_file <<
" "
203 std::string apollo_root_dir_str =
"/apollo";
208 std::string plugin_lib_path =
209 "APOLLO_PLUGIN_LIB_PATH=" + apollo_root_dir_str +
210 "/bazel-bin:/opt/apollo/neo/lib";
211 std::cout <<
"plugin_lib_path:" << plugin_lib_path << std::endl;
212 char lib_path_chars[100];
213 memcpy(lib_path_chars, plugin_lib_path.c_str(), plugin_lib_path.size());
214 lib_path_chars[plugin_lib_path.size()] =
'\0';
215 std::cout <<
"lib_path_chars:" << lib_path_chars << std::endl;
216 putenv(lib_path_chars);
217 std::string lat_controller_plugin_xml_file =
218 "/apollo/modules/control/control_component/testdata/conf/plugins/"
219 "lat_based_lqr_controller/plugins.xml";
220 std::string lon_controller_plugin_xml_file =
221 "/apollo/modules/control/control_component/testdata/conf/plugins/"
222 "lon_based_pid_controller/plugins.xml";
224 lat_controller_plugin_xml_file);
226 lon_controller_plugin_xml_file);
bool GetProtoFromASCIIFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as ascii representation of protobufs,...
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,...