Apollo 11.0
自动驾驶开放平台
old_routing_adapter.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
21#pragma once
22
23#include <memory>
24#include <string>
25#include <vector>
26
27#include "modules/common_msgs/external_command_msgs/command_status.pb.h"
28#include "modules/common_msgs/external_command_msgs/lane_follow_command.pb.h"
29#include "modules/common_msgs/external_command_msgs/valet_parking_command.pb.h"
30#include "modules/common_msgs/routing_msgs/routing.pb.h"
31
33
34namespace apollo {
35namespace hdmap {
36class HDMap;
37} // namespace hdmap
38} // namespace apollo
39
44namespace apollo {
45namespace old_routing_adapter {
46
53 public:
55
56 ~OldRoutingAdapter() = default;
57
58 bool Init() override;
59
60 private:
61 void OnRoutingRequest(
62 const std::shared_ptr<apollo::routing::RoutingRequest>& routing_request);
63
64 template <typename T>
65 void CopyRoutingRequest(
66 const std::shared_ptr<routing::RoutingRequest>& routing_request,
67 int start_index, int end_index, T* message);
68
69 void Convert(const apollo::routing::LaneWaypoint& lane_way_point,
71
72 double GetNearestHeading(const std::string& lane_id, double x,
73 double y) const;
74
75 std::shared_ptr<cyber::Reader<apollo::routing::RoutingRequest>>
76 routing_request_reader_;
77
78 // Coverted from RoutingRequest without parking id.
79 std::shared_ptr<
82 lane_follow_command_client_;
83 // Coverted from RoutingRequest with parking id.
84 std::shared_ptr<
87 valet_parking_command_client_;
88 uint64_t command_id_;
89 const hdmap::HDMap* hdmap_;
90};
91
92template <typename T>
93void OldRoutingAdapter::CopyRoutingRequest(
94 const std::shared_ptr<routing::RoutingRequest>& routing_request,
95 int start_index, int end_index, T* message) {
96 if (routing_request->has_header()) {
97 message->mutable_header()->CopyFrom(routing_request->header());
98 }
99 message->set_command_id(++command_id_);
100 const auto& way_points = routing_request->waypoint();
101 for (int i = start_index; i < end_index; ++i) {
102 Convert(way_points.Get(i), message->add_way_point());
103 }
104}
105
106CYBER_REGISTER_COMPONENT(OldRoutingAdapter)
107
108} // namespace old_routing_adapter
109} // namespace apollo
Client get Response from a responding Service by sending a Request
Definition client.h:47
High-precision map loader interface.
Definition hdmap.h:54
The external interface for processing external commands.
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:657
class register implement
Definition arena_queue.h:37