Apollo 10.0
自动驾驶开放平台
lexus_controller.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
18
19#include "modules/common_msgs/basic_msgs/vehicle_signal.pb.h"
20#include "cyber/common/log.h"
21#include "cyber/time/time.h"
26
27namespace apollo {
28namespace canbus {
29namespace lexus {
30
31using ::apollo::common::ErrorCode;
32using ::apollo::common::VehicleSignal;
33using ::apollo::control::ControlCommand;
34using ::apollo::drivers::canbus::ProtocolData;
35
36namespace {
37
38const int32_t kMaxFailAttempt = 10;
39const int32_t CHECK_RESPONSE_STEER_UNIT_FLAG = 1;
40const int32_t CHECK_RESPONSE_SPEED_UNIT_FLAG = 2;
41
42} // namespace
43
45 const VehicleParameter& params,
46 CanSender<::apollo::canbus::Lexus>* const can_sender,
47 MessageManager<::apollo::canbus::Lexus>* const message_manager) {
48 if (is_initialized_) {
49 AINFO << "LexusController has already been initiated.";
50 return ErrorCode::CANBUS_ERROR;
51 }
52 vehicle_params_.CopyFrom(
53 common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param());
54 params_.CopyFrom(params);
55 if (!params_.has_driving_mode()) {
56 AERROR << "Vehicle conf pb not set driving_mode.";
57 return ErrorCode::CANBUS_ERROR;
58 }
59
60 if (can_sender == nullptr) {
61 AERROR << "Canbus sender is null.";
62 return ErrorCode::CANBUS_ERROR;
63 }
64 can_sender_ = can_sender;
65
66 if (message_manager == nullptr) {
67 AERROR << "Protocol manager is null.";
68 return ErrorCode::CANBUS_ERROR;
69 }
70 message_manager_ = message_manager;
71
72 // Sender part
73 accel_cmd_100_ = dynamic_cast<Accelcmd100*>(
74 message_manager_->GetMutableProtocolDataById(Accelcmd100::ID));
75 if (accel_cmd_100_ == nullptr) {
76 AERROR << "Accelcmd100 does not exist in the LexusMessalexusanager!";
77 return ErrorCode::CANBUS_ERROR;
78 }
79
80 brake_cmd_104_ = dynamic_cast<Brakecmd104*>(
81 message_manager_->GetMutableProtocolDataById(Brakecmd104::ID));
82 if (brake_cmd_104_ == nullptr) {
83 AERROR << "Brakecmd104 does not exist in the LexusMessalexusanager!";
84 return ErrorCode::CANBUS_ERROR;
85 }
86
87 shift_cmd_128_ = dynamic_cast<Shiftcmd128*>(
88 message_manager_->GetMutableProtocolDataById(Shiftcmd128::ID));
89 if (shift_cmd_128_ == nullptr) {
90 AERROR << "Shiftcmd128 does not exist in the LexusMessalexusanager!";
91 return ErrorCode::CANBUS_ERROR;
92 }
93
94 turn_cmd_130_ = dynamic_cast<Turncmd130*>(
95 message_manager_->GetMutableProtocolDataById(Turncmd130::ID));
96 if (turn_cmd_130_ == nullptr) {
97 AERROR << "Turncmd130 does not exist in the LexusMessageManager!";
98 return ErrorCode::CANBUS_ERROR;
99 }
100
101 steering_cmd_12c_ = dynamic_cast<Steeringcmd12c*>(
102 message_manager_->GetMutableProtocolDataById(Steeringcmd12c::ID));
103 if (steering_cmd_12c_ == nullptr) {
104 AERROR << "Steeringcmd12c does not exist in the LexusMessageManager!";
105 return ErrorCode::CANBUS_ERROR;
106 }
107
108 can_sender_->AddMessage(Accelcmd100::ID, accel_cmd_100_, false);
109 can_sender_->AddMessage(Brakecmd104::ID, brake_cmd_104_, false);
110 can_sender_->AddMessage(Shiftcmd128::ID, shift_cmd_128_, false);
111 can_sender_->AddMessage(Steeringcmd12c::ID, steering_cmd_12c_, false);
112 can_sender_->AddMessage(Turncmd130::ID, turn_cmd_130_, false);
113
114 // Need to sleep to ensure all messages were received
115 AINFO << "LexusController is initialized.";
116
117 is_initialized_ = true;
118 return ErrorCode::OK;
119}
120
122
124 if (!is_initialized_) {
125 AERROR << "LexusController has NOT been initiated.";
126 return false;
127 }
128 const auto& update_func = [this] { SecurityDogThreadFunc(); };
129 thread_.reset(new std::thread(update_func));
130
131 return true;
132}
133
135 if (!is_initialized_) {
136 AERROR << "LexusController stops or starts improperly!";
137 return;
138 }
139
140 if (thread_ != nullptr && thread_->joinable()) {
141 thread_->join();
142 thread_.reset();
143 AINFO << "LexusController stopped.";
144 }
145}
146
148 chassis_.Clear();
149
150 Lexus chassis_detail;
151 message_manager_->GetSensorData(&chassis_detail);
152
153 // 21, 22, previously 1, 2
155 set_chassis_error_code(Chassis::NO_ERROR);
156 }
157
158 chassis_.set_driving_mode(driving_mode());
159 chassis_.set_error_code(chassis_error_code());
160
161 // 3
162 chassis_.set_engine_started(true);
163
164 // 5
165 if (chassis_detail.has_vehicle_speed_rpt_400() &&
166 chassis_detail.vehicle_speed_rpt_400().has_vehicle_speed()) {
167 chassis_.set_speed_mps(static_cast<float>(
168 chassis_detail.vehicle_speed_rpt_400().vehicle_speed()));
169 } else {
170 chassis_.set_speed_mps(0);
171 }
172
173 if (chassis_detail.has_wheel_speed_rpt_407()) {
174 // TODO(QiL) : No wheel speed valid bit in lexus, so default valid
175 chassis_.mutable_wheel_speed()->set_is_wheel_spd_rr_valid(true);
176 // chassis_.mutable_wheel_speed()->set_wheel_direction_rr(true);
177 chassis_.mutable_wheel_speed()->set_wheel_spd_rr(
178 chassis_detail.wheel_speed_rpt_407().wheel_spd_rear_right());
179
180 chassis_.mutable_wheel_speed()->set_is_wheel_spd_rl_valid(true);
181 /*
182 chassis_.mutable_wheel_speed()->set_wheel_direction_rl(
183 chassis_detail.vehicle_spd().wheel_direction_rl());
184 */
185 chassis_.mutable_wheel_speed()->set_wheel_spd_rl(
186 chassis_detail.wheel_speed_rpt_407().wheel_spd_rear_left());
187
188 chassis_.mutable_wheel_speed()->set_is_wheel_spd_fr_valid(true);
189 /*
190 chassis_.mutable_wheel_speed()->set_wheel_direction_fr(
191 chassis_detail.vehicle_spd().wheel_direction_fr());
192 */
193 chassis_.mutable_wheel_speed()->set_wheel_spd_fr(
194 chassis_detail.wheel_speed_rpt_407().wheel_spd_front_right());
195
196 chassis_.mutable_wheel_speed()->set_is_wheel_spd_fl_valid(true);
197 /*
198 chassis_.mutable_wheel_speed()->set_wheel_direction_fl(
199 chassis_detail.vehicle_spd().wheel_direction_fl());
200 */
201 chassis_.mutable_wheel_speed()->set_wheel_spd_fl(
202 chassis_detail.wheel_speed_rpt_407().wheel_spd_front_left());
203 }
204
205 // 7
206 chassis_.set_fuel_range_m(0);
207 // 8
208 if (chassis_detail.has_accel_rpt_200() &&
209 chassis_detail.accel_rpt_200().has_output_value()) {
210 // TODO(snehagn): Temp fix until AS to fix the scaling
211 chassis_.set_throttle_percentage(static_cast<float>(
212 chassis_detail.accel_rpt_200().output_value() * 100));
213 } else {
214 chassis_.set_throttle_percentage(0);
215 }
216 // 9
217 if (chassis_detail.has_brake_rpt_204() &&
218 chassis_detail.brake_rpt_204().has_output_value()) {
219 // TODO(snehagn): Temp fix until AS to fix the scaling
220 chassis_.set_brake_percentage(static_cast<float>(
221 chassis_detail.brake_rpt_204().output_value() * 100));
222 } else {
223 chassis_.set_brake_percentage(0);
224 }
225
226 // 23, previously 10
227 if (chassis_detail.has_shift_rpt_228() &&
228 chassis_detail.shift_rpt_228().has_output_value()) {
229 AINFO << "Start reading shift values";
231
232 if (chassis_detail.shift_rpt_228().output_value() ==
234 gear_pos = Chassis::GEAR_PARKING;
235 }
236
237 if (chassis_detail.shift_rpt_228().output_value() ==
239 gear_pos = Chassis::GEAR_NEUTRAL;
240 }
241 if (chassis_detail.shift_rpt_228().output_value() ==
243 gear_pos = Chassis::GEAR_REVERSE;
244 }
245 if (chassis_detail.shift_rpt_228().output_value() ==
247 gear_pos = Chassis::GEAR_DRIVE;
248 }
249
250 chassis_.set_gear_location(gear_pos);
251 } else {
252 chassis_.set_gear_location(Chassis::GEAR_NONE);
253 }
254
255 // 11
256 // TODO(QiL) : verify the unit here.
257 if (chassis_detail.has_steering_rpt_22c() &&
258 chassis_detail.steering_rpt_22c().has_output_value()) {
259 chassis_.set_steering_percentage(
260 static_cast<float>(chassis_detail.steering_rpt_22c().output_value() *
262 } else {
263 chassis_.set_steering_percentage(0);
264 }
265
266 // 16, 17
267 if (chassis_detail.has_turn_rpt_230() &&
268 chassis_detail.turn_rpt_230().has_output_value() &&
269 chassis_detail.turn_rpt_230().output_value() !=
271 if (chassis_detail.turn_rpt_230().output_value() ==
273 chassis_.mutable_signal()->set_turn_signal(
275 } else if (chassis_detail.turn_rpt_230().output_value() ==
277 chassis_.mutable_signal()->set_turn_signal(
279 } else {
280 chassis_.mutable_signal()->set_turn_signal(
282 }
283 } else {
284 chassis_.mutable_signal()->set_turn_signal(
286 }
287
288 // TODO(all): implement the rest here/
289 // 26
290 if (chassis_error_mask_) {
291 chassis_.set_chassis_error_mask(chassis_error_mask_);
292 }
293
294 // give engage_advice based on error_code and canbus feedback
295 if (!chassis_error_mask_ && !chassis_.parking_brake()) {
296 chassis_.mutable_engage_advice()->set_advice(
298 } else {
299 chassis_.mutable_engage_advice()->set_advice(
301 chassis_.mutable_engage_advice()->set_reason(
302 "CANBUS not ready, firmware error or emergency button pressed!");
303 }
304
305 return chassis_;
306}
307
308bool LexusController::VerifyID() { return true; }
309
310void LexusController::Emergency() {
312 ResetProtocol();
313}
314
315ErrorCode LexusController::EnableAutoMode() {
317 AINFO << "Already in COMPLETE_AUTO_DRIVE mode";
318 return ErrorCode::OK;
319 }
320
321 accel_cmd_100_->set_enable(true);
322 accel_cmd_100_->set_clear_override(true);
323 brake_cmd_104_->set_enable(true);
324 brake_cmd_104_->set_clear_override(true);
325 steering_cmd_12c_->set_enable(true);
326 steering_cmd_12c_->set_clear_override(true);
327 shift_cmd_128_->set_enable(true);
328 shift_cmd_128_->set_clear_override(true);
329
330 can_sender_->Update();
331 const int32_t flag =
332 CHECK_RESPONSE_STEER_UNIT_FLAG | CHECK_RESPONSE_SPEED_UNIT_FLAG;
333 if (!CheckResponse(flag, true)) {
334 AERROR << "Failed to switch to COMPLETE_AUTO_DRIVE mode.";
335 Emergency();
336 set_chassis_error_code(Chassis::CHASSIS_ERROR);
337 return ErrorCode::CANBUS_ERROR;
338 }
340 AINFO << "Switch to COMPLETE_AUTO_DRIVE mode ok.";
341 return ErrorCode::OK;
342}
343
344ErrorCode LexusController::DisableAutoMode() {
345 ResetProtocol();
346 can_sender_->Update();
348 set_chassis_error_code(Chassis::NO_ERROR);
349 AINFO << "Switch to COMPLETE_MANUAL ok.";
350 return ErrorCode::OK;
351}
352
353ErrorCode LexusController::EnableSteeringOnlyMode() {
357 AINFO << "Already in AUTO_STEER_ONLY mode";
358 return ErrorCode::OK;
359 }
360
361 accel_cmd_100_->set_enable(false);
362 brake_cmd_104_->set_enable(false);
363 steering_cmd_12c_->set_enable(false);
364 shift_cmd_128_->set_enable(false);
365
366 can_sender_->Update();
367 if (!CheckResponse(CHECK_RESPONSE_STEER_UNIT_FLAG, true)) {
368 AERROR << "Failed to switch to AUTO_STEER_ONLY mode.";
369 Emergency();
370 set_chassis_error_code(Chassis::CHASSIS_ERROR);
371 return ErrorCode::CANBUS_ERROR;
372 }
374 AINFO << "Switch to AUTO_STEER_ONLY mode ok.";
375 return ErrorCode::OK;
376}
377
378ErrorCode LexusController::EnableSpeedOnlyMode() {
382 AINFO << "Already in AUTO_SPEED_ONLY mode.";
383 return ErrorCode::OK;
384 }
385
386 accel_cmd_100_->set_enable(false);
387 brake_cmd_104_->set_enable(false);
388 steering_cmd_12c_->set_enable(false);
389 shift_cmd_128_->set_enable(false);
390
391 can_sender_->Update();
392 if (!CheckResponse(CHECK_RESPONSE_SPEED_UNIT_FLAG, true)) {
393 AERROR << "Failed to switch to AUTO_SPEED_ONLY mode.";
394 Emergency();
395 set_chassis_error_code(Chassis::CHASSIS_ERROR);
396 return ErrorCode::CANBUS_ERROR;
397 }
399 AINFO << "Switch to AUTO_SPEED_ONLY mode ok.";
400 return ErrorCode::OK;
401}
402
403// NEUTRAL, REVERSE, DRIVE
404void LexusController::Gear(Chassis::GearPosition gear_position) {
407 AINFO << "This drive mode no need to set gear.";
408 return;
409 }
410
411 switch (gear_position) {
414 break;
415 }
418 break;
419 }
420 case Chassis::GEAR_DRIVE: {
422 break;
423 }
426 break;
427 }
428 case Chassis::GEAR_LOW: {
430 break;
431 }
432 case Chassis::GEAR_NONE: {
434 break;
435 }
437 AERROR << "Gear command is invalid!";
439 break;
440 }
441 default: {
443 break;
444 }
445 }
446}
447
448// brake with new acceleration
449// acceleration:0.00~99.99, unit:
450// acceleration:0.0 ~ 7.0, unit:m/s^2
451// acceleration_spd:60 ~ 100, suggest: 90
452// -> pedal
453void LexusController::Brake(double pedal) {
454 // double real_value = params_.max_acc() * acceleration / 100;
457 AINFO << "The current drive mode does not need to set acceleration.";
458 return;
459 }
460 brake_cmd_104_->set_brake_cmd(pedal);
461}
462
463// drive with old acceleration
464// gas:0.00~99.99 unit:
465void LexusController::Throttle(double pedal) {
468 AINFO << "The current drive mode does not need to set acceleration.";
469 return;
470 }
471 accel_cmd_100_->set_accel_cmd(pedal);
472}
473
474// drive with acceleration/deceleration
475// acc:-7.0 ~ 5.0, unit:m/s^2
476void LexusController::Acceleration(double acc) {
479 AINFO << "The current drive mode does not need to set acceleration.";
480 return;
481 }
482 // None
483}
484
485// TODO(Yu/QiL): double check the physical range, unit and direction for Lexus
486// lexus default -32.768 ~ 32.767, unit: rad, left:-, right:+ in canbus protocol
487// need to be compatible with control module, so reverse steering
488// angle:-99.99~0.00~99.99, unit: %, left:+, right:- in control module
489void LexusController::Steer(double angle) {
492 AINFO << "The current driving mode does not need to set steer.";
493 return;
494 }
495 const double real_angle = vehicle_params_.max_steer_angle() * angle / 100.0;
496 // TODO(Yu/QiL): double checck to decide if reverse sign needed
497 steering_cmd_12c_->set_position(real_angle);
498 // TODO(QiL) : double check this rate
499 steering_cmd_12c_->set_rotation_rate(40);
500}
501
502// TODO(Yu/QiL): double check the physical range, unit and direction for Lexus
503// lexus default -32.768 ~ 32.767, unit: rad, left:-, right:+ in canbus protocol
504// lexus default 0 ~ 65.535, unit: rad/sec, in canbus protocol
505// steering with new angle speed
506// angle:-99.99~0.00~99.99, unit:%, left:+, right:- in control module
507// angle_spd:0.00~99.99, unit:%
508void LexusController::Steer(double angle, double angle_spd) {
511 AINFO << "The current driving mode does not need to set steer.";
512 return;
513 }
514
515 const double real_angle = vehicle_params_.max_steer_angle() * angle / 100.0;
516 const double real_angle_spd =
517 ProtocolData<::apollo::canbus::Lexus>::BoundedValue(
520 vehicle_params_.max_steer_angle_rate() * angle_spd / 100.0);
521 // TODO(Yu/QiL): double checck to decide if reverse sign needed
522 steering_cmd_12c_->set_position(real_angle);
523 steering_cmd_12c_->set_rotation_rate(real_angle_spd);
524}
525
526void LexusController::SetEpbBreak(const ControlCommand& command) {
527 if (command.parking_brake()) {
528 // None
529 } else {
530 // None
531 }
532}
533
534ErrorCode LexusController::HandleCustomOperation(
535 const external_command::ChassisCommand& command) {
536 return ErrorCode::OK;
537}
538
539void LexusController::SetBeam(const VehicleSignal& vehicle_signal) {
540 if (vehicle_signal.has_high_beam() && vehicle_signal.high_beam()) {
541 // None
542 } else if (vehicle_signal.has_low_beam() && vehicle_signal.low_beam()) {
543 // None
544 } else {
545 // None
546 }
547}
548
549void LexusController::SetHorn(const VehicleSignal& vehicle_signal) {
550 if (vehicle_signal.horn()) {
551 // None
552 } else {
553 // None
554 }
555}
556
557void LexusController::SetTurningSignal(const VehicleSignal& vehicle_signal) {
558 auto signal = vehicle_signal.turn_signal();
559 if (signal == common::VehicleSignal::TURN_LEFT) {
561 } else if (signal == common::VehicleSignal::TURN_RIGHT) {
563 } else {
565 }
566}
567
568void LexusController::ResetProtocol() { message_manager_->ResetSendMessages(); }
569
570bool LexusController::CheckChassisError() {
571 /* ADD YOUR OWN CAR CHASSIS OPERATION
572 */
573 return false;
574}
575
576void LexusController::SecurityDogThreadFunc() {
577 int32_t vertical_ctrl_fail = 0;
578 int32_t horizontal_ctrl_fail = 0;
579
580 if (can_sender_ == nullptr) {
581 AERROR << "Failed to run SecurityDogThreadFunc() because can_sender_ is "
582 "nullptr.";
583 return;
584 }
585 while (!can_sender_->IsRunning()) {
586 std::this_thread::yield();
587 }
588
589 std::chrono::duration<double, std::micro> default_period{50000};
590 int64_t start = 0;
591 int64_t end = 0;
592 while (can_sender_->IsRunning()) {
594 const Chassis::DrivingMode mode = driving_mode();
595 bool emergency_mode = false;
596
597 // 1. horizontal control check
598 if ((mode == Chassis::COMPLETE_AUTO_DRIVE ||
599 mode == Chassis::AUTO_STEER_ONLY) &&
600 !CheckResponse(CHECK_RESPONSE_STEER_UNIT_FLAG, false)) {
601 ++horizontal_ctrl_fail;
602 if (horizontal_ctrl_fail >= kMaxFailAttempt) {
603 emergency_mode = true;
604 set_chassis_error_code(Chassis::MANUAL_INTERVENTION);
605 }
606 } else {
607 horizontal_ctrl_fail = 0;
608 }
609
610 // 2. vertical control check
611 if ((mode == Chassis::COMPLETE_AUTO_DRIVE ||
612 mode == Chassis::AUTO_SPEED_ONLY) &&
613 !CheckResponse(CHECK_RESPONSE_SPEED_UNIT_FLAG, false)) {
614 ++vertical_ctrl_fail;
615 if (vertical_ctrl_fail >= kMaxFailAttempt) {
616 emergency_mode = true;
617 set_chassis_error_code(Chassis::MANUAL_INTERVENTION);
618 }
619 } else {
620 vertical_ctrl_fail = 0;
621 }
622 if (CheckChassisError()) {
623 set_chassis_error_code(Chassis::CHASSIS_ERROR);
624 emergency_mode = true;
625 }
626
627 if (emergency_mode && mode != Chassis::EMERGENCY_MODE) {
629 message_manager_->ResetSendMessages();
630 }
632 std::chrono::duration<double, std::micro> elapsed{end - start};
633 if (elapsed < default_period) {
634 std::this_thread::sleep_for(default_period - elapsed);
635 } else {
636 AERROR << "Too much time consumption in LexusController looping process:"
637 << elapsed.count();
638 }
639 }
640}
641
642bool LexusController::CheckResponse(const int32_t flags, bool need_wait) {
643 // for Lexus, we assume CheckResponse will take 300ms. We leave a 100ms buffer
644 // for it.
645 // TODO(Yu) : check whether the current retry_num match the assumed time
646 // consumption
647 int32_t retry_num = 20;
648 Lexus chassis_detail;
649 bool is_accel_enabled = false;
650 bool is_brake_enabled = false;
651 bool is_steering_enabled = false;
652
653 do {
654 if (message_manager_->GetSensorData(&chassis_detail) != ErrorCode::OK) {
655 AERROR_EVERY(100) << "Get chassis detail failed.";
656 return false;
657 }
658 bool check_ok = true;
659 if (flags & CHECK_RESPONSE_STEER_UNIT_FLAG) {
660 is_steering_enabled = chassis_detail.has_steering_rpt_22c() &&
661 chassis_detail.steering_rpt_22c().has_enabled() &&
662 chassis_detail.steering_rpt_22c().enabled();
663 check_ok = check_ok && is_steering_enabled;
664 }
665
666 if (flags & CHECK_RESPONSE_SPEED_UNIT_FLAG) {
667 is_brake_enabled = chassis_detail.has_brake_rpt_204() &&
668 chassis_detail.brake_rpt_204().has_enabled() &&
669 chassis_detail.brake_rpt_204().enabled();
670 is_accel_enabled = chassis_detail.has_accel_rpt_200() &&
671 chassis_detail.accel_rpt_200().has_enabled() &&
672 chassis_detail.accel_rpt_200().enabled();
673 check_ok = check_ok && is_brake_enabled && is_accel_enabled;
674 }
675 if (check_ok) {
676 return true;
677 }
678 if (need_wait) {
679 --retry_num;
680 std::this_thread::sleep_for(
681 std::chrono::duration<double, std::milli>(20));
682 }
683 } while (need_wait && retry_num);
684
685 // If check_response fails, then report the specific module failure online
686 AERROR << "check_response fail: is_steering_enabled:" << is_steering_enabled
687 << ", is_brake_enabled:" << is_brake_enabled
688 << ", is_accel_enabled:" << is_accel_enabled;
689 return false;
690}
691
692void LexusController::set_chassis_error_mask(const int32_t mask) {
693 std::lock_guard<std::mutex> lock(chassis_mask_mutex_);
694 chassis_error_mask_ = mask;
695}
696
697int32_t LexusController::chassis_error_mask() {
698 std::lock_guard<std::mutex> lock(chassis_mask_mutex_);
699 return chassis_error_mask_;
700}
701
702Chassis::ErrorCode LexusController::chassis_error_code() {
703 std::lock_guard<std::mutex> lock(chassis_error_code_mutex_);
704 return chassis_error_code_;
705}
706
707void LexusController::set_chassis_error_code(
708 const Chassis::ErrorCode& error_code) {
709 std::lock_guard<std::mutex> lock(chassis_error_code_mutex_);
710 chassis_error_code_ = error_code;
711}
712
713} // namespace lexus
714} // namespace canbus
715} // namespace apollo
Defines SenderMessage class and CanSender class.
virtual void set_driving_mode(const Chassis::DrivingMode &driving_mode)
MessageManager< ::apollo::canbus::Lexus > * message_manager_
Accelcmd100 * set_accel_cmd(double accel_cmd)
Accelcmd100 * set_enable(bool enable)
Accelcmd100 * set_clear_override(bool clear_override)
Brakecmd104 * set_clear_override(bool clear_override)
Brakecmd104 * set_brake_cmd(double brake_cmd)
Brakecmd104 * set_enable(bool enable)
bool Start() override
start the vehicle controller.
Chassis chassis() override
calculate and return the chassis.
::apollo::common::ErrorCode Init(const VehicleParameter &params, CanSender<::apollo::canbus::Lexus > *const can_sender, MessageManager<::apollo::canbus::Lexus > *const message_manager) override
void Stop() override
stop the vehicle controller.
Shiftcmd128 * set_enable(bool enable)
Shiftcmd128 * set_clear_override(bool clear_override)
Shiftcmd128 * set_shift_cmd(Shift_cmd_128::Shift_cmdType shift_cmd)
Steeringcmd12c * set_clear_override(bool clear_override)
Steeringcmd12c * set_enable(bool enable)
Steeringcmd12c * set_position(double position)
Steeringcmd12c * set_rotation_rate(double rotation_rate)
Turncmd130 * set_turn_signal_cmd(Turn_cmd_130::Turn_signal_cmdType turn_signal_cmd)
uint64_t ToMicrosecond() const
convert time to microsecond (us).
Definition time.cc:85
static Time Now()
get the current time.
Definition time.cc:57
#define AERROR
Definition log.h:44
#define AERROR_EVERY(freq)
Definition log.h:86
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37
The class of ProtocolData
optional double output_value
Definition lexus.proto:633
optional double output_value
Definition lexus.proto:657
optional bool parking_brake
Definition chassis.proto:94
optional Accel_rpt_200 accel_rpt_200
Definition lexus.proto:1305
optional Steering_rpt_22c steering_rpt_22c
Definition lexus.proto:1283
optional Brake_rpt_204 brake_rpt_204
Definition lexus.proto:1306
optional Shift_rpt_228 shift_rpt_228
Definition lexus.proto:1317
optional Vehicle_speed_rpt_400 vehicle_speed_rpt_400
Definition lexus.proto:1311
optional Turn_rpt_230 turn_rpt_230
Definition lexus.proto:1292
optional Wheel_speed_rpt_407 wheel_speed_rpt_407
Definition lexus.proto:1296
optional Output_valueType output_value
Definition lexus.proto:962
optional Output_valueType output_value
Definition lexus.proto:417
The class of VehicleController