Apollo 10.0
自动驾驶开放平台
external_command_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/planning_msgs/planning.pb.h"
31#include "modules/external_command/external_command_demo/proto/demo_config.pb.h"
32
34#include "cyber/cyber.h"
36
38 public:
40
41 bool Init() override;
42
43 bool Proc() override;
44
45 private:
46 template <typename T>
47 void FillCommandHeader(const std::shared_ptr<T>& command);
48
49 void SendActionCommand(
51
52 void SendSpeedCommand(double speed);
53
54 void SendSpeedFactorCommand(double speed_factor);
55
56 void RestoreSpeed();
57
58 void SendLaneFollowCommand(
59 const std::vector<apollo::external_command::Pose>& way_points,
60 const apollo::external_command::Pose& end, double target_speed);
61
62 void SendValetParkingCommand(const std::string& parking_spot_id,
63 double target_speed);
64
65 void SendVehicleSignalCommand();
66
67 void SendCustomChassisCommand();
68
69 void SendPathFollowCommandWithPathRecord(const std::string& record_path);
70
71 void SendPathFollowCommandWithLocationRecord(const std::string& record_dir);
72
73 void CheckCommandStatus(const uint64_t command_id);
74
75 void SendFreespaceCommand(
76 const std::vector<apollo::external_command::Point>& way_points,
78
79 static void ReadPathFromPathRecord(
80 const std::string& record_file,
81 google::protobuf::RepeatedPtrField<apollo::external_command::Point>*
82 waypoints);
83
84 void ReadPathFromLocationRecord(
85 const std::string& record_file,
86 google::protobuf::RepeatedPtrField<apollo::external_command::Point>*
87 waypoints) const;
88
89 std::shared_ptr<
92 action_command_client_;
93 std::shared_ptr<
96 chassis_command_client_;
97 std::shared_ptr<
100 free_space_command_client_;
101 std::shared_ptr<
104 lane_follow_command_client_;
105 std::shared_ptr<
108 path_follow_command_client_;
109 std::shared_ptr<
112 speed_command_client_;
113 std::shared_ptr<
116 valet_parking_command_client_;
117 std::shared_ptr<
120 status_client_;
121
122 uint64_t command_id_;
123 const std::string module_name_;
125};
126
127template <typename T>
128void ExternalCommandDemo::FillCommandHeader(const std::shared_ptr<T>& command) {
129 apollo::common::util::FillHeader(module_name_, command.get());
130 command->set_command_id(++command_id_);
131}
132
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.
Client get Response from a responding Service by sending a Request
Definition client.h:47
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
Some string util functions.