Apollo 10.0
自动驾驶开放平台
control_component.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 atis_control_test_mode
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *****************************************************************************/
16
17#include "absl/strings/str_cat.h"
18
19#include "cyber/common/file.h"
20#include "cyber/common/log.h"
21#include "cyber/time/clock.h"
26
27namespace apollo {
28namespace control {
29
37
38const double kDoubleEpsilon = 1e-6;
39
41 : monitor_logger_buffer_(common::monitor::MonitorMessageItem::CONTROL) {}
42
44 injector_ = std::make_shared<DependencyInjector>();
45 init_time_ = Clock::Now();
46
47 AINFO << "Control init, starting ...";
48
49 ACHECK(
50 cyber::common::GetProtoFromFile(FLAGS_pipeline_file, &control_pipeline_))
51 << "Unable to load control pipeline file: " + FLAGS_pipeline_file;
52
53 AINFO << "ControlTask pipeline config file: " << FLAGS_pipeline_file
54 << " is loaded.";
55
56 // initial controller agent when not using control submodules
57 ADEBUG << "FLAGS_use_control_submodules: " << FLAGS_use_control_submodules;
58 if (!FLAGS_is_control_ut_test_mode) {
59 if (!FLAGS_use_control_submodules &&
60 !control_task_agent_.Init(injector_, control_pipeline_).ok()) {
61 // set controller
62 ADEBUG << "original control";
63 monitor_logger_buffer_.ERROR(
64 "Control init controller failed! Stopping...");
65 return false;
66 }
67 }
68
69 cyber::ReaderConfig chassis_reader_config;
70 chassis_reader_config.channel_name = FLAGS_chassis_topic;
71 chassis_reader_config.pending_queue_size = FLAGS_chassis_pending_queue_size;
72
73 chassis_reader_ =
74 node_->CreateReader<Chassis>(chassis_reader_config, nullptr);
75 ACHECK(chassis_reader_ != nullptr);
76
77 cyber::ReaderConfig planning_reader_config;
78 planning_reader_config.channel_name = FLAGS_planning_trajectory_topic;
79 planning_reader_config.pending_queue_size = FLAGS_planning_pending_queue_size;
80
81 trajectory_reader_ =
82 node_->CreateReader<ADCTrajectory>(planning_reader_config, nullptr);
83 ACHECK(trajectory_reader_ != nullptr);
84
85 cyber::ReaderConfig planning_command_status_reader_config;
86 planning_command_status_reader_config.channel_name =
87 FLAGS_planning_command_status;
88 planning_command_status_reader_config.pending_queue_size =
89 FLAGS_planning_status_msg_pending_queue_size;
90 planning_command_status_reader_ =
92 planning_command_status_reader_config, nullptr);
93 ACHECK(planning_command_status_reader_ != nullptr);
94
95 cyber::ReaderConfig localization_reader_config;
96 localization_reader_config.channel_name = FLAGS_localization_topic;
97 localization_reader_config.pending_queue_size =
98 FLAGS_localization_pending_queue_size;
99
100 localization_reader_ = node_->CreateReader<LocalizationEstimate>(
101 localization_reader_config, nullptr);
102 ACHECK(localization_reader_ != nullptr);
103
104 cyber::ReaderConfig pad_msg_reader_config;
105 pad_msg_reader_config.channel_name = FLAGS_pad_topic;
106 pad_msg_reader_config.pending_queue_size = FLAGS_pad_msg_pending_queue_size;
107
108 pad_msg_reader_ =
109 node_->CreateReader<PadMessage>(pad_msg_reader_config, nullptr);
110 ACHECK(pad_msg_reader_ != nullptr);
111
112 if (!FLAGS_use_control_submodules) {
113 control_cmd_writer_ =
114 node_->CreateWriter<ControlCommand>(FLAGS_control_command_topic);
115 ACHECK(control_cmd_writer_ != nullptr);
116 } else {
117 local_view_writer_ =
118 node_->CreateWriter<LocalView>(FLAGS_control_local_view_topic);
119 ACHECK(local_view_writer_ != nullptr);
120 }
121 control_interactive_writer_ = node_->CreateWriter<ControlInteractiveMsg>(
122 FLAGS_control_interative_topic);
123 ACHECK(control_interactive_writer_ != nullptr);
124
125 // set initial vehicle state by cmd
126 // need to sleep, because advertised channel is not ready immediately
127 // simple test shows a short delay of 80 ms or so
128 AINFO << "Control resetting vehicle state, sleeping for 1000 ms ...";
129 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
130
131 // should init_vehicle first, let car enter work status, then use status msg
132 // trigger control
133
134 AINFO << "Control default driving action is "
135 << DrivingAction_Name((enum DrivingAction)FLAGS_action);
136 pad_msg_.set_action((enum DrivingAction)FLAGS_action);
137
138 return true;
139}
140
141void ControlComponent::OnPad(const std::shared_ptr<PadMessage> &pad) {
142 std::lock_guard<std::mutex> lock(mutex_);
143 pad_msg_.CopyFrom(*pad);
144 ADEBUG << "Received Pad Msg:" << pad_msg_.DebugString();
145 AERROR_IF(!pad_msg_.has_action()) << "pad message check failed!";
146}
147
148void ControlComponent::OnChassis(const std::shared_ptr<Chassis> &chassis) {
149 ADEBUG << "Received chassis data: run chassis callback.";
150 std::lock_guard<std::mutex> lock(mutex_);
151 latest_chassis_.CopyFrom(*chassis);
152}
153
154void ControlComponent::OnPlanning(
155 const std::shared_ptr<ADCTrajectory> &trajectory) {
156 ADEBUG << "Received chassis data: run trajectory callback.";
157 std::lock_guard<std::mutex> lock(mutex_);
158 latest_trajectory_.CopyFrom(*trajectory);
159}
160
161void ControlComponent::OnPlanningCommandStatus(
162 const std::shared_ptr<external_command::CommandStatus>
163 &planning_command_status) {
164 ADEBUG << "Received plannning command status data: run planning command "
165 "status callback.";
166 std::lock_guard<std::mutex> lock(mutex_);
167 planning_command_status_.CopyFrom(*planning_command_status);
168}
169
170void ControlComponent::OnLocalization(
171 const std::shared_ptr<LocalizationEstimate> &localization) {
172 ADEBUG << "Received control data: run localization message callback.";
173 std::lock_guard<std::mutex> lock(mutex_);
174 latest_localization_.CopyFrom(*localization);
175}
176
177void ControlComponent::OnMonitor(
178 const common::monitor::MonitorMessage &monitor_message) {
179 for (const auto &item : monitor_message.item()) {
180 if (item.log_level() == common::monitor::MonitorMessageItem::FATAL) {
181 estop_ = true;
182 return;
183 }
184 }
185}
186
187Status ControlComponent::ProduceControlCommand(
188 ControlCommand *control_command) {
189 Status status = CheckInput(&local_view_);
190 // check data
191 if (!status.ok()) {
192 AERROR_EVERY(100) << "Control input data failed: "
193 << status.error_message();
194 control_command->mutable_engage_advice()->set_advice(
196 control_command->mutable_engage_advice()->set_reason(
197 status.error_message());
198 estop_ = true;
199 estop_reason_ = status.error_message();
200 } else {
201 estop_ = false;
202 Status status_ts = CheckTimestamp(local_view_);
203 if (!status_ts.ok()) {
204 AERROR << "Input messages timeout";
205 // Clear trajectory data to make control stop if no data received again
206 // next cycle.
207 // keep the history trajectory for control compute.
208 // latest_trajectory_.Clear();
209 estop_ = true;
210 status = status_ts;
211 if (local_view_.chassis().driving_mode() !=
213 control_command->mutable_engage_advice()->set_advice(
215 control_command->mutable_engage_advice()->set_reason(
216 status.error_message());
217 }
218 } else {
219 control_command->mutable_engage_advice()->set_advice(
221 estop_ = false;
222 }
223 }
224
225 // check estop
226 estop_ = FLAGS_enable_persistent_estop
227 ? estop_ || local_view_.trajectory().estop().is_estop()
228 : local_view_.trajectory().estop().is_estop();
229
230 if (local_view_.trajectory().estop().is_estop()) {
231 estop_ = true;
232 estop_reason_ = "estop from planning : ";
233 estop_reason_ += local_view_.trajectory().estop().reason();
234 }
235
236 if (local_view_.trajectory().trajectory_point().empty()) {
237 AWARN_EVERY(100) << "planning has no trajectory point. ";
238 estop_ = true;
239 estop_reason_ = "estop for empty planning trajectory, planning headers: " +
240 local_view_.trajectory().header().ShortDebugString();
241 }
242
243 if (FLAGS_enable_gear_drive_negative_speed_protection) {
244 const double kEpsilon = 0.001;
245 auto first_trajectory_point = local_view_.trajectory().trajectory_point(0);
246 if (local_view_.chassis().gear_location() == Chassis::GEAR_DRIVE &&
247 first_trajectory_point.v() < -1 * kEpsilon) {
248 estop_ = true;
249 estop_reason_ = "estop for negative speed when gear_drive";
250 }
251 }
252
253 if (!estop_) {
254 if (local_view_.chassis().driving_mode() == Chassis::COMPLETE_MANUAL) {
255 control_task_agent_.Reset();
256 AINFO_EVERY(100) << "Reset Controllers in Manual Mode";
257 }
258
259 auto debug = control_command->mutable_debug()->mutable_input_debug();
260 debug->mutable_localization_header()->CopyFrom(
261 local_view_.localization().header());
262 debug->mutable_canbus_header()->CopyFrom(local_view_.chassis().header());
263 debug->mutable_trajectory_header()->CopyFrom(
264 local_view_.trajectory().header());
265
266 if (local_view_.trajectory().is_replan()) {
267 latest_replan_trajectory_header_ = local_view_.trajectory().header();
268 }
269
270 if (latest_replan_trajectory_header_.has_sequence_num()) {
271 debug->mutable_latest_replan_trajectory_header()->CopyFrom(
272 latest_replan_trajectory_header_);
273 }
274 }
275
276 if (!local_view_.trajectory().trajectory_point().empty()) {
277 // controller agent
278 Status status_compute = control_task_agent_.ComputeControlCommand(
279 &local_view_.localization(), &local_view_.chassis(),
280 &local_view_.trajectory(), control_command);
281 ADEBUG << "status_compute is " << status_compute;
282
283 if (!status_compute.ok()) {
284 AERROR << "Control main function failed" << " with localization: "
285 << local_view_.localization().ShortDebugString()
286 << " with chassis: " << local_view_.chassis().ShortDebugString()
287 << " with trajectory: "
288 << local_view_.trajectory().ShortDebugString()
289 << " with cmd: " << control_command->ShortDebugString()
290 << " status:" << status_compute.error_message();
291 estop_ = true;
292 estop_reason_ = status_compute.error_message();
293 status = status_compute;
294 }
295 }
296
297 // if planning set estop, then no control process triggered
298 if (estop_) {
299 AWARN_EVERY(100) << "Estop triggered! No control core method executed!";
300 // set Estop command
301 control_command->set_speed(0);
302 control_command->set_throttle(0);
303 control_command->set_brake(FLAGS_soft_estop_brake);
304 control_command->set_gear_location(Chassis::GEAR_DRIVE);
305 previous_steering_command_ =
306 injector_->previous_control_command_mutable()->steering_target();
307 control_command->set_steering_target(previous_steering_command_);
308 }
309 // check signal
310 if (local_view_.trajectory().decision().has_vehicle_signal()) {
311 control_command->mutable_signal()->CopyFrom(
312 local_view_.trajectory().decision().vehicle_signal());
313 }
314 return status;
315}
316
318 const auto start_time = Clock::Now();
319
320 injector_->control_debug_info_clear();
321
322 chassis_reader_->Observe();
323 const auto &chassis_msg = chassis_reader_->GetLatestObserved();
324 if (chassis_msg == nullptr) {
325 AERROR << "Chassis msg is not ready!";
326 injector_->set_control_process(false);
327 return false;
328 }
329 OnChassis(chassis_msg);
330
331 trajectory_reader_->Observe();
332 const auto &trajectory_msg = trajectory_reader_->GetLatestObserved();
333 if (trajectory_msg == nullptr) {
334 AERROR << "planning msg is not ready!";
335 } else {
336 // Check if new planning data received.
337 if (latest_trajectory_.header().sequence_num() !=
338 trajectory_msg->header().sequence_num()) {
339 OnPlanning(trajectory_msg);
340 }
341 }
342
343 planning_command_status_reader_->Observe();
344 const auto &planning_status_msg =
345 planning_command_status_reader_->GetLatestObserved();
346 if (planning_status_msg != nullptr) {
347 OnPlanningCommandStatus(planning_status_msg);
348 ADEBUG << "Planning command status msg is \n"
349 << planning_command_status_.ShortDebugString();
350 }
351 injector_->set_planning_command_status(planning_command_status_);
352
353 localization_reader_->Observe();
354 const auto &localization_msg = localization_reader_->GetLatestObserved();
355 if (localization_msg == nullptr) {
356 AERROR << "localization msg is not ready!";
357 injector_->set_control_process(false);
358 return false;
359 }
360 OnLocalization(localization_msg);
361
362 pad_msg_reader_->Observe();
363 const auto &pad_msg = pad_msg_reader_->GetLatestObserved();
364 if (pad_msg != nullptr) {
365 OnPad(pad_msg);
366 }
367
368 {
369 // TODO(SHU): to avoid redundent copy
370 std::lock_guard<std::mutex> lock(mutex_);
371 local_view_.mutable_chassis()->CopyFrom(latest_chassis_);
372 local_view_.mutable_trajectory()->CopyFrom(latest_trajectory_);
373 local_view_.mutable_localization()->CopyFrom(latest_localization_);
374 if (pad_msg != nullptr) {
375 local_view_.mutable_pad_msg()->CopyFrom(pad_msg_);
376 }
377 }
378
379 // use control submodules
380 if (FLAGS_use_control_submodules) {
381 local_view_.mutable_header()->set_lidar_timestamp(
382 local_view_.trajectory().header().lidar_timestamp());
383 local_view_.mutable_header()->set_camera_timestamp(
384 local_view_.trajectory().header().camera_timestamp());
385 local_view_.mutable_header()->set_radar_timestamp(
386 local_view_.trajectory().header().radar_timestamp());
387 common::util::FillHeader(FLAGS_control_local_view_topic, &local_view_);
388
389 const auto end_time = Clock::Now();
390
391 // measure latency
392 static apollo::common::LatencyRecorder latency_recorder(
393 FLAGS_control_local_view_topic);
394 latency_recorder.AppendLatencyRecord(
395 local_view_.trajectory().header().lidar_timestamp(), start_time,
396 end_time);
397
398 local_view_writer_->Write(local_view_);
399 return true;
400 }
401
402 if (pad_msg != nullptr) {
403 ADEBUG << "pad_msg: " << pad_msg_.ShortDebugString();
404 ADEBUG << "pad_msg is not nullptr";
405 if (pad_msg_.action() == DrivingAction::RESET) {
406 AINFO << "Control received RESET action!";
407 estop_ = false;
408 estop_reason_.clear();
409 }
410 pad_received_ = true;
411 }
412
413 if (FLAGS_is_control_test_mode && FLAGS_control_test_duration > 0 &&
414 (start_time - init_time_).ToSecond() > FLAGS_control_test_duration) {
415 AERROR << "Control finished testing. exit";
416 injector_->set_control_process(false);
417 return false;
418 }
419
420 injector_->set_control_process(true);
421
422 injector_->mutable_control_debug_info()
423 ->mutable_control_component_debug()
424 ->Clear();
425 CheckAutoMode(&local_view_.chassis());
426
427 ControlCommand control_command;
428
429 Status status;
430 if (local_view_.chassis().driving_mode() ==
432 status = ProduceControlCommand(&control_command);
433 ADEBUG << "Produce control command normal.";
434 } else {
435 ADEBUG << "Into reset control command.";
436 ResetAndProduceZeroControlCommand(&control_command);
437 }
438
439 AERROR_IF(!status.ok()) << "Failed to produce control command:"
440 << status.error_message();
441
442 if (pad_received_) {
443 control_command.mutable_pad_msg()->CopyFrom(pad_msg_);
444 pad_received_ = false;
445 }
446
447 // forward estop reason among following control frames.
448 if (estop_) {
449 control_command.mutable_header()->mutable_status()->set_msg(estop_reason_);
450 }
451
452 // set header
453 control_command.mutable_header()->set_lidar_timestamp(
454 local_view_.trajectory().header().lidar_timestamp());
455 control_command.mutable_header()->set_camera_timestamp(
456 local_view_.trajectory().header().camera_timestamp());
457 control_command.mutable_header()->set_radar_timestamp(
458 local_view_.trajectory().header().radar_timestamp());
459
460 if (FLAGS_is_control_test_mode) {
461 ADEBUG << "Skip publish control command in test mode";
462 return true;
463 }
464
465 if (fabs(control_command.debug().simple_lon_debug().vehicle_pitch()) <
467 injector_->vehicle_state()->Update(local_view_.localization(),
468 local_view_.chassis());
469 GetVehiclePitchAngle(&control_command);
470 }
471
472 const auto end_time = Clock::Now();
473 const double time_diff_ms = (end_time - start_time).ToSecond() * 1e3;
474 ADEBUG << "total control time spend: " << time_diff_ms << " ms.";
475
476 control_command.mutable_latency_stats()->set_total_time_ms(time_diff_ms);
477 control_command.mutable_latency_stats()->set_total_time_exceeded(
478 time_diff_ms > FLAGS_control_period * 1e3);
479 if (control_command.mutable_latency_stats()->total_time_exceeded()) {
480 AINFO << "total control cycle time is exceeded: " << time_diff_ms << " ms.";
481 }
482 status.Save(control_command.mutable_header()->mutable_status());
483
484 // measure latency
485 if (local_view_.trajectory().header().has_lidar_timestamp()) {
486 static apollo::common::LatencyRecorder latency_recorder(
487 FLAGS_control_command_topic);
488 latency_recorder.AppendLatencyRecord(
489 local_view_.trajectory().header().lidar_timestamp(), start_time,
490 end_time);
491 }
492
493 common::util::FillHeader(node_->Name(), &control_command);
494 ADEBUG << control_command.ShortDebugString();
495 control_cmd_writer_->Write(control_command);
496
497 // save current control command
498 injector_->Set_pervious_control_command(&control_command);
499 injector_->previous_control_command_mutable()->CopyFrom(control_command);
500 // save current control debug
501 injector_->previous_control_debug_mutable()->CopyFrom(
502 injector_->control_debug_info());
503
504 PublishControlInteractiveMsg();
505 const auto end_process_control_time = Clock::Now();
506 const double process_control_time_diff =
507 (end_process_control_time - start_time).ToSecond() * 1e3;
508 if (control_command.mutable_latency_stats()->total_time_exceeded()) {
509 AINFO << "control all spend time is: " << process_control_time_diff
510 << " ms.";
511 }
512
513 return true;
514}
515
516Status ControlComponent::CheckInput(LocalView *local_view) {
517 ADEBUG << "Received localization:"
518 << local_view->localization().ShortDebugString();
519 ADEBUG << "Received chassis:" << local_view->chassis().ShortDebugString();
520
521 if (!local_view->trajectory().estop().is_estop() &&
522 local_view->trajectory().trajectory_point().empty()) {
523 AWARN_EVERY(100) << "planning has no trajectory point. ";
524 const std::string msg =
525 absl::StrCat("planning has no trajectory point. planning_seq_num:",
526 local_view->trajectory().header().sequence_num());
527 return Status(ErrorCode::CONTROL_COMPUTE_ERROR, msg);
528 }
529
530 for (auto &trajectory_point :
531 *local_view->mutable_trajectory()->mutable_trajectory_point()) {
532 if (std::abs(trajectory_point.v()) < FLAGS_minimum_speed_resolution &&
533 std::abs(trajectory_point.a()) < FLAGS_max_acceleration_when_stopped) {
534 trajectory_point.set_v(0.0);
535 trajectory_point.set_a(0.0);
536 }
537 }
538
539 injector_->vehicle_state()->Update(local_view->localization(),
540 local_view->chassis());
541
542 return Status::OK();
543}
544
545Status ControlComponent::CheckTimestamp(const LocalView &local_view) {
546 if (!FLAGS_enable_input_timestamp_check || FLAGS_is_control_test_mode) {
547 ADEBUG << "Skip input timestamp check by gflags.";
548 return Status::OK();
549 }
550 double current_timestamp = Clock::NowInSeconds();
551 double localization_diff =
552 current_timestamp - local_view.localization().header().timestamp_sec();
553 if (localization_diff >
554 (FLAGS_max_localization_miss_num * FLAGS_localization_period)) {
555 AERROR << "Localization msg lost for " << std::setprecision(6)
556 << localization_diff << "s";
557 monitor_logger_buffer_.ERROR("Localization msg lost");
558 return Status(ErrorCode::CONTROL_COMPUTE_ERROR, "Localization msg timeout");
559 }
560
561 double chassis_diff =
562 current_timestamp - local_view.chassis().header().timestamp_sec();
563 if (chassis_diff > (FLAGS_max_chassis_miss_num * FLAGS_chassis_period)) {
564 AERROR << "Chassis msg lost for " << std::setprecision(6) << chassis_diff
565 << "s";
566 monitor_logger_buffer_.ERROR("Chassis msg lost");
567 return Status(ErrorCode::CONTROL_COMPUTE_ERROR, "Chassis msg timeout");
568 }
569
570 double trajectory_diff =
571 current_timestamp - local_view.trajectory().header().timestamp_sec();
572 if (trajectory_diff >
573 (FLAGS_max_planning_miss_num * FLAGS_trajectory_period)) {
574 AERROR << "Trajectory msg lost for " << std::setprecision(6)
575 << trajectory_diff << "s";
576 monitor_logger_buffer_.ERROR("Trajectory msg lost");
577 return Status(ErrorCode::CONTROL_COMPUTE_ERROR, "Trajectory msg timeout");
578 }
579 return Status::OK();
580}
581
582void ControlComponent::ResetAndProduceZeroControlCommand(
583 ControlCommand *control_command) {
584 control_command->set_throttle(0.0);
585 control_command->set_steering_target(0.0);
586 control_command->set_steering_rate(0.0);
587 control_command->set_speed(0.0);
588 control_command->set_brake(0.0);
589 control_command->set_gear_location(Chassis::GEAR_DRIVE);
590 control_task_agent_.Reset();
591 latest_trajectory_.mutable_trajectory_point()->Clear();
592 latest_trajectory_.mutable_path_point()->Clear();
593 trajectory_reader_->ClearData();
594}
595
596void ControlComponent::GetVehiclePitchAngle(ControlCommand *control_command) {
597 double vehicle_pitch = injector_->vehicle_state()->pitch() * 180 / M_PI;
598 control_command->mutable_debug()
599 ->mutable_simple_lon_debug()
600 ->set_vehicle_pitch(vehicle_pitch + FLAGS_pitch_offset_deg);
601}
602
603void ControlComponent::CheckAutoMode(const canbus::Chassis *chassis) {
604 if (!injector_->previous_control_debug_mutable()
605 ->mutable_control_component_debug()
606 ->is_auto() &&
607 chassis->driving_mode() == apollo::canbus::Chassis::COMPLETE_AUTO_DRIVE) {
608 from_else_to_auto_ = true;
609 AINFO << "From else to auto!!!";
610 } else {
611 from_else_to_auto_ = false;
612 }
613 ADEBUG << "from_else_to_auto_: " << from_else_to_auto_;
614 injector_->mutable_control_debug_info()
615 ->mutable_control_component_debug()
616 ->set_from_else_to_auto(from_else_to_auto_);
617
618 if (chassis->driving_mode() == apollo::canbus::Chassis::COMPLETE_AUTO_DRIVE) {
619 is_auto_ = true;
620 } else {
621 is_auto_ = false;
622 }
623 injector_->mutable_control_debug_info()
624 ->mutable_control_component_debug()
625 ->set_is_auto(is_auto_);
626}
627
628void ControlComponent::PublishControlInteractiveMsg() {
629 auto control_interactive_msg = injector_->control_interactive_info();
630 common::util::FillHeader(node_->Name(), &control_interactive_msg);
631 ADEBUG << "control interactive msg is: "
632 << control_interactive_msg.ShortDebugString();
633 control_interactive_writer_->Write(control_interactive_msg);
634}
635
636} // namespace control
637} // namespace apollo
void AppendLatencyRecord(const uint64_t message_id, const apollo::cyber::Time &begin_time, const apollo::cyber::Time &end_time)
A general class to denote the return status of an API call.
Definition status.h:43
bool ok() const
check whether the return status is OK.
Definition status.h:67
const std::string & error_message() const
returns the error message of the status, empty if the status is OK.
Definition status.h:91
void Save(StatusPb *status_pb)
save the error_code and error message to protobuf
Definition status.h:109
static Status OK()
generate a success status.
Definition status.h:60
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.
common::Status Reset()
reset ControlTaskAgent
common::Status Init(std::shared_ptr< DependencyInjector > injector, const ControlPipeline &control_pipeline)
initialize ControlTaskAgent
common::Status ComputeControlCommand(const localization::LocalizationEstimate *localization, const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory, control::ControlCommand *cmd)
compute control command based on current vehicle status and target trajectory
a singleton clock that can be used to get the current timestamp.
Definition clock.h:39
static double NowInSeconds()
gets the current time in second.
Definition clock.cc:56
static Time Now()
PRECISION >= 1000000 means the precision is at least 1us.
Definition clock.cc:40
std::shared_ptr< Node > node_
#define ACHECK(cond)
Definition log.h:80
#define ADEBUG
Definition log.h:41
#define AINFO_EVERY(freq)
Definition log.h:82
#define AERROR
Definition log.h:44
#define AERROR_EVERY(freq)
Definition log.h:86
#define AWARN_EVERY(freq)
Definition log.h:84
#define AERROR_IF(cond)
Definition log.h:74
#define AINFO
Definition log.h:42
const double kDoubleEpsilon
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
class register implement
Definition arena_queue.h:37
optional GearPosition gear_location
optional apollo::common::Header header
optional DrivingMode driving_mode
optional uint32 sequence_num
Definition header.proto:16
optional uint64 camera_timestamp
Definition header.proto:22
optional uint64 lidar_timestamp
Definition header.proto:19
optional uint64 radar_timestamp
Definition header.proto:25
optional SimpleLongitudinalDebug simple_lon_debug
optional apollo::planning::ADCTrajectory trajectory
optional apollo::canbus::Chassis chassis
optional apollo::localization::LocalizationEstimate localization
optional DrivingAction action
Definition pad_msg.proto:17
uint32_t pending_queue_size
configuration for responding ChannelBuffer.
optional apollo::common::Header header
repeated apollo::common::TrajectoryPoint trajectory_point
optional apollo::common::Header header
optional apollo::planning::DecisionResult decision
optional string reason
LocalView contains all necessary data as planning input