Apollo 10.0
自动驾驶开放平台
canbus_component.h
浏览该文件的文档.
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 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#include <string>
25#include <utility>
26#include <vector>
27
28#include "modules/common_msgs/control_msgs/control_cmd.pb.h"
29#include "modules/common_msgs/guardian_msgs/guardian.pb.h"
30
31#include "cyber/common/macros.h"
33#include "cyber/cyber.h"
34#include "cyber/timer/timer.h"
43
48namespace apollo {
49namespace canbus {
50
58 public:
64 std::string Name() const;
65
66 private:
71 bool Init() override;
72
76 bool Proc() override;
77
81 void Clear() override;
82
83 void PublishChassis();
84 void OnControlCommand(const apollo::control::ControlCommand &control_command);
85 void OnControlCommandCheck(
86 const apollo::control::ControlCommand &control_command);
87 void OnChassisCommand(
88 const apollo::external_command::ChassisCommand &chassis_command);
89 void OnGuardianCommand(
90 const apollo::guardian::GuardianCommand &guardian_command);
91 void OnGuardianCommandCheck(
92 const apollo::guardian::GuardianCommand &guardian_command);
93 apollo::common::Status OnError(const std::string &error_msg);
94 void ProcessTimeoutByClearCanSender();
95 void ProcessGuardianCmdTimeout(
96 apollo::guardian::GuardianCommand *guardian_command);
97
98 CanbusConf canbus_conf_;
99 std::shared_ptr<::apollo::canbus::AbstractVehicleFactory> vehicle_object_ =
100 nullptr;
101 std::shared_ptr<cyber::Reader<apollo::guardian::GuardianCommand>>
102 guardian_cmd_reader_;
103 std::shared_ptr<cyber::Reader<apollo::control::ControlCommand>>
104 control_command_reader_;
105 std::shared_ptr<cyber::Reader<apollo::external_command::ChassisCommand>>
106 chassis_command_reader_;
107 double last_timestamp_controlcmd_ = 0.0;
108 int64_t last_timestamp_chassiscmd_ = 0;
109 ::apollo::common::monitor::MonitorLogBuffer monitor_logger_buffer_;
110 std::shared_ptr<cyber::Writer<Chassis>> chassis_writer_;
111 bool is_control_cmd_time_delay_ = false;
112 bool is_control_cmd_time_delay_previous_ = false;
113};
114
116
117} // namespace canbus
118} // namespace apollo
Defines the CanFrame struct and CanClient interface.
Defines CanReceiver class.
Defines SenderMessage class and CanSender class.
std::string Name() const
obtain module name
A general class to denote the return status of an API call.
Definition status.h:43
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
The class of MessageManager
The class of MonitorLogBuffer
class register implement
Definition arena_queue.h:37
The class of VehicleController