25#include "modules/external_command/old_routing_adapter/proto/old_routing_adapter.pb.h"
34namespace old_routing_adapter {
48 AERROR <<
"Unable to load OldRoutingAdapter conf file: "
55 [
this](
const std::shared_ptr<routing::RoutingRequest>& routing_request) {
56 ADEBUG <<
"Received routing request: run callback.";
57 OnRoutingRequest(routing_request);
59 lane_follow_command_client_ =
63 valet_parking_command_client_ =
70void OldRoutingAdapter::OnRoutingRequest(
71 const std::shared_ptr<routing::RoutingRequest>& routing_request) {
73 cyber::SleepFor(std::chrono::microseconds(500));
74 AINFO <<
"Receive routing request " << routing_request->DebugString();
75 if (routing_request->has_parking_info()) {
76 auto valet_parking_command = std::make_shared<ValetParkingCommand>();
84 valet_parking_command->set_parking_spot_id(
85 routing_request->parking_info().parking_space_id());
87 valet_parking_command_client_->SendRequest(valet_parking_command);
88 AINFO <<
"Send valet parking command "
89 << valet_parking_command->DebugString();
90 if (
nullptr == response) {
91 AERROR <<
"Failed to send request of valet parking!";
94 auto lane_follow_command = std::make_shared<LaneFollowCommand>();
96 int way_point_size = routing_request->waypoint().size();
97 AINFO << routing_request->DebugString();
98 CHECK_GT(way_point_size, 0);
99 if (way_point_size > 1) {
100 routing_request->mutable_waypoint()->DeleteSubrange(0, 1);
101 CopyRoutingRequest<LaneFollowCommand>(
102 routing_request, 0, way_point_size - 2, lane_follow_command.get());
106 lane_follow_command->mutable_header()->CopyFrom(routing_request->header());
107 Convert(routing_request->waypoint().Get(way_point_size - 1),
108 lane_follow_command->mutable_end_pose());
109 AINFO <<
"Send lane follow command " << lane_follow_command->DebugString();
111 lane_follow_command_client_->SendRequest(lane_follow_command);
112 if (
nullptr == response) {
113 AERROR <<
"Failed to get response of lane follow!";
118void OldRoutingAdapter::Convert(
121 CHECK(lane_way_point.has_pose());
122 const auto& way_pose = lane_way_point.
pose();
123 pose->set_x(way_pose.x());
124 pose->set_y(way_pose.y());
125 if (lane_way_point.has_heading()) {
126 pose->set_heading(lane_way_point.
heading());
130 if (lane_way_point.has_id()) {
132 GetNearestHeading(lane_way_point.
id(), way_pose.x(), way_pose.y()));
136double OldRoutingAdapter::GetNearestHeading(
const std::string& lane_id,
137 double x,
double y)
const {
143 common::math::Vec2d proj_pt(0.0, 0.0);
144 common::math::Vec2d point(x, y);
145 double s_offset = 0.0;
146 int s_offset_index = 0;
147 lane->DistanceTo(point, &proj_pt, &s_offset, &s_offset_index);
148 return lane->headings()[s_offset_index];
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
static const HDMap * BaseMapPtr()
LaneInfoConstPtr GetLaneById(const Id &id) const
std::string BaseMapFile()
get base map file path from flags.
required string routing_request_topic
required string lane_follow_command_topic
required string valet_parking_command_topic
optional apollo::common::PointENU pose