36 auto can_factory = CanClientFactory::Instance();
37 can_factory->RegisterCanClients();
40 AERROR <<
"Failed to create can client.";
43 AINFO <<
"Can client is successfully created.";
45 message_manager_ = this->CreateMessageManager();
46 if (message_manager_ ==
nullptr) {
47 AERROR <<
"Failed to create message manager.";
50 AINFO <<
"Message manager is successfully created.";
52 if (can_receiver_.Init(can_client_.get(), message_manager_.get(),
54 AERROR <<
"Failed to init can receiver.";
57 AINFO <<
"The can receiver is successfully initialized.";
59 if (can_sender_.Init(can_client_.get(), message_manager_.get(),
61 AERROR <<
"Failed to init can sender.";
64 AINFO <<
"The can sender is successfully initialized.";
66 vehicle_controller_ = CreateVehicleController();
67 if (vehicle_controller_ ==
nullptr) {
68 AERROR <<
"Failed to create vehicle controller.";
71 AINFO <<
"The vehicle controller is successfully created.";
74 message_manager_.get()) != ErrorCode::OK) {
75 AERROR <<
"Failed to init vehicle controller.";
79 AINFO <<
"The vehicle controller is successfully"
80 <<
" initialized with canbus conf as : "
86 FLAGS_chassis_detail_topic);
93 if (can_client_->Start() != ErrorCode::OK) {
94 AERROR <<
"Failed to start can client";
97 AINFO <<
"Can client is started.";
100 if (can_receiver_.Start() != ErrorCode::OK) {
101 AERROR <<
"Failed to start can receiver.";
104 AINFO <<
"Can receiver is started.";
107 if (can_sender_.Start() != ErrorCode::OK) {
108 AERROR <<
"Failed to start can sender.";
113 if (!vehicle_controller_->Start()) {
114 AERROR <<
"Failed to start vehicle controller.";
123 can_receiver_.Stop();
125 vehicle_controller_->Stop();
126 AINFO <<
"Cleanup cansender, canreceiver, canclient, vehicle controller.";
131 if (vehicle_controller_->Update(*control_command) != ErrorCode::OK) {
132 AERROR <<
"Failed to process callback function OnControlCommand because "
133 "vehicle_controller_->Update error.";
136 can_sender_.Update();
141 if (vehicle_controller_->Update(*chassis_command) != ErrorCode::OK) {
142 AERROR <<
"Failed to process callback function OnControlCommand because "
143 "vehicle_controller_->Update error.";
146 can_sender_.Update();
150 Chassis chassis = vehicle_controller_->chassis();
151 ADEBUG << chassis.ShortDebugString();
157 message_manager_->GetSensorData(&chassis_detail);
158 ADEBUG << chassis_detail.ShortDebugString();
159 chassis_detail_writer_->Write(chassis_detail);
162std::unique_ptr<VehicleController<::apollo::canbus::Lincoln>>
163LincolnVehicleFactory::CreateVehicleController() {
164 return std::unique_ptr<VehicleController<::apollo::canbus::Lincoln>>(
168std::unique_ptr<MessageManager<::apollo::canbus::Lincoln>>
169LincolnVehicleFactory::CreateMessageManager() {
170 return std::unique_ptr<MessageManager<::apollo::canbus::Lincoln>>(
171 new lincoln::LincolnMessageManager());
Defines the CanClientFactory class.
void UpdateCommand(const apollo::control::ControlCommand *control_command) override
update control command
void PublishChassisDetail() override
publish chassis for vehicle messages
bool Init(const CanbusConf *canbus_conf) override
init vehicle factory
Chassis publish_chassis() override
publish chassis messages
void Stop() override
stop canclient, cansender, canreceiver, vehicle controller
bool Start() override
start canclient, cansender, canreceiver, vehicle controller
this class implements the vehicle controller for lincoln vehicle.
CanClientFactory inherites apollo::common::util::Factory.
The class of LincolnController
the class of LincolnMessageManager
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
optional apollo::drivers::canbus::CANCardParameter can_card_parameter
optional bool enable_receiver_log
optional bool enable_sender_log
optional VehicleParameter vehicle_parameter