Apollo 10.0
自动驾驶开放平台
external_command_wrapper_demo.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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#pragma once
17
18#include <memory>
19#include <string>
20#include <vector>
21
22#include "modules/common_msgs/external_command_msgs/action_command.pb.h"
23#include "modules/common_msgs/external_command_msgs/chassis_command.pb.h"
24#include "modules/common_msgs/external_command_msgs/command_status.pb.h"
25#include "modules/common_msgs/external_command_msgs/free_space_command.pb.h"
26#include "modules/common_msgs/external_command_msgs/lane_follow_command.pb.h"
27#include "modules/common_msgs/external_command_msgs/path_follow_command.pb.h"
28#include "modules/common_msgs/external_command_msgs/speed_command.pb.h"
29#include "modules/common_msgs/external_command_msgs/valet_parking_command.pb.h"
30#include "modules/common_msgs/external_command_msgs/zone_cover_command.pb.h"
31#include "modules/common_msgs/planning_msgs/planning.pb.h"
32#include "modules/external_command/external_command_demo/proto/demo_config.pb.h"
33
35#include "cyber/cyber.h"
38
40 public:
42
43 bool Init() override;
44
45 bool Proc() override;
46
47 private:
48 template <typename T>
49 void FillCommandHeader(const std::shared_ptr<T>& command);
50
51 void SendActionCommand(
53
54 void SendSpeedCommand(double speed);
55
56 void SendSpeedFactorCommand(double speed_factor);
57
58 void RestoreSpeed();
59
60 void SendLaneFollowCommand(
61 const std::vector<apollo::external_command::Pose>& way_points,
62 const apollo::external_command::Pose& end, double target_speed);
63
64 void SendValetParkingCommand(const std::string& parking_spot_id,
65 double target_speed);
66
67 void SendVehicleSignalCommand();
68
69 void SendCustomChassisCommand();
70
71 void SendPathFollowCommandWithPathRecord(const std::string& record_path);
72
73 void SendPathFollowCommandWithLocationRecord(const std::string& record_dir);
74
75 void CheckCommandStatus(const uint64_t command_id);
76
77 void SendFreespaceCommand(
78 const std::vector<apollo::external_command::Point>& way_points,
80
81 void SendZoneCoverCommand(const std::string overlap_id);
82
83 void ReadPathFromPathRecord(
84 const std::string& record_file,
85 google::protobuf::RepeatedPtrField<apollo::external_command::Point>*
86 waypoints,
87 std::vector<apollo::external_command::Point>& left_boundary_points,
88 std::vector<apollo::external_command::Point>& right_boundary_points);
89
90 void ReadPathFromLocationRecord(
91 const std::string& record_file,
92 google::protobuf::RepeatedPtrField<apollo::external_command::Point>*
93 waypoints) const;
94
95 std::shared_ptr<
98 action_command_client_;
99 std::shared_ptr<
102 chassis_command_client_;
103 std::shared_ptr<
106 free_space_command_client_;
107
108 std::shared_ptr<
111 zone_cover_command_client_;
112
113 std::shared_ptr<
116 lane_follow_command_client_;
117 std::shared_ptr<
120 path_follow_command_client_;
121 std::shared_ptr<
124 speed_command_client_;
125 std::shared_ptr<apollo::common::ClientWrapper<
128 valet_parking_command_client_;
129 std::shared_ptr<apollo::common::ClientWrapper<
132 status_client_;
133
134 uint64_t command_id_;
135 const std::string module_name_;
137};
138
139template <typename T>
140void ExternalCommandWrapperDemo::FillCommandHeader(
141 const std::shared_ptr<T>& command) {
142 apollo::common::util::FillHeader(module_name_, command.get());
143 command->set_command_id(++command_id_);
144}
145
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.
Wrapper of cyber::Client which sends a topic with service name when SendRequst is invoked.
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
Some string util functions.