Apollo 10.0
自动驾驶开放平台
devkit_vehicle_factory.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 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
21#pragma once
22
23#include <memory>
24
25#include "modules/canbus/proto/canbus_conf.pb.h"
26#include "modules/canbus/proto/vehicle_parameter.pb.h"
27#include "modules/canbus_vehicle/devkit/proto/devkit.pb.h"
28#include "modules/common_msgs/control_msgs/control_cmd.pb.h"
29
30#include "cyber/cyber.h"
40
45namespace apollo {
46namespace canbus {
47
55 public:
59 virtual ~DevkitVehicleFactory() = default;
60
65 bool Init(const CanbusConf *canbus_conf) override;
66
71 bool Start() override;
72
77 void Stop() override;
78
82 void UpdateCommand(
83 const apollo::control::ControlCommand *control_command) override;
84
85 void UpdateCommand(
86 const apollo::external_command::ChassisCommand *chassis_command) override;
87
91 Chassis publish_chassis() override;
92
96 void UpdateHeartbeat() override;
97
101 void PublishChassisDetail() override;
102
106 void PublishChassisDetailSender() override;
107
111 bool CheckChassisCommunicationFault() override;
112
116 void AddSendProtocol() override;
117
121 void ClearSendProtocol() override;
122
126 bool IsSendProtocolClear() override;
127
132
133 private:
138 std::unique_ptr<VehicleController<::apollo::canbus::Devkit>>
139 CreateVehicleController();
140
145 std::unique_ptr<MessageManager<::apollo::canbus::Devkit>>
146 CreateMessageManager();
147
148 std::unique_ptr<::apollo::cyber::Node> node_ = nullptr;
149 std::unique_ptr<apollo::drivers::canbus::CanClient> can_client_;
150 CanSender<::apollo::canbus::Devkit> can_sender_;
152 std::unique_ptr<MessageManager<::apollo::canbus::Devkit>> message_manager_;
153 std::unique_ptr<VehicleController<::apollo::canbus::Devkit>>
154 vehicle_controller_;
155
156 std::shared_ptr<::apollo::cyber::Writer<::apollo::canbus::Devkit>>
157 chassis_detail_writer_;
158 std::shared_ptr<::apollo::cyber::Writer<::apollo::canbus::Devkit>>
159 chassis_detail_sender_writer_;
160};
161
163
164} // namespace canbus
165} // namespace apollo
#define CYBER_REGISTER_VEHICLEFACTORY(name)
Defines the CanFrame struct and CanClient interface.
Defines CanReceiver class.
Defines SenderMessage class and CanSender class.
this class is the abstract factory following the AbstractFactory design pattern.
this class is inherited from AbstractVehicleFactory.
bool Start() override
start canclient, cansender, canreceiver, vehicle controller
void ClearSendProtocol() override
clear the can sender messages
void AddSendProtocol() override
add the can sender messages
virtual ~DevkitVehicleFactory()=default
destructor
Chassis::DrivingMode Driving_Mode() override
get the latest chassis driving mode
void PublishChassisDetail() override
publish chassis for vehicle messages
bool Init(const CanbusConf *canbus_conf) override
init vehicle factory
bool IsSendProtocolClear() override
check the sender message clear or not
void Stop() override
create ch vehicle controller
void UpdateHeartbeat() override
create cansender heartbeat
void UpdateCommand(const apollo::control::ControlCommand *control_command) override
update control command
bool CheckChassisCommunicationFault() override
check chassis can receiver lost
Chassis publish_chassis() override
publish chassis messages
void PublishChassisDetailSender() override
publish chassis for apollo sender messages
The class of MessageManager
class register implement
Definition arena_queue.h:37
The class of VehicleController