Apollo 10.0
自动驾驶开放平台
cycle_routing_manager.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 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 *****************************************************************************/
17
19
20namespace apollo {
21namespace task_manager {
23 common::PointENU point_b, double distance) {
24 double x_dis = point_a.x() - point_b.x();
25 double y_dis = point_a.y() - point_b.y();
26 return x_dis * x_dis + y_dis * y_dis < distance * distance;
27}
28
30 const CycleRoutingTask& cycle_routing_task) {
31 cycle_ = cycle_routing_task.cycle_num();
32 auto waypoints = cycle_routing_task.lane_follow_command().way_point();
33 begin_point_ = waypoints[0];
34 end_point_ = cycle_routing_task.lane_follow_command().end_pose();
35 is_allowed_to_route_ = true;
36 original_lane_follow_command_ = cycle_routing_task.lane_follow_command();
37 map_service_.reset(new apollo::dreamview::MapService());
38
39 AINFO << "New cycle routing task: cycle " << cycle_ << ", begin point "
40 << begin_point_.x() << " " << begin_point_.y() << ", end point "
41 << end_point_.x() << " " << end_point_.y();
42
43 return common::Status::OK();
44}
45
47 const localization::Pose& pose,
48 external_command::LaneFollowCommand* lane_follow_command) {
49 AINFO << "GetNewRouting: localization_pose: " << pose.position().x() << " "
50 << pose.position().y() << ", begin point " << begin_point_.x() << " "
51 << begin_point_.y() << ", end point " << end_point_.x() << " "
52 << end_point_.y() << ", threshold "
53 << FLAGS_task_manager_threshold_for_destination_check
54 << ", allowed_to_send_routing_request " << is_allowed_to_route_;
55
56 if (is_allowed_to_route_) {
58 begin_point_, pose.position(),
59 FLAGS_task_manager_threshold_for_destination_check)) {
60 AINFO << "GetNewRouting: reach begin point."
61 << "Remaining cycles: " << cycle_;
62 lane_follow_command->CopyFrom(original_lane_follow_command_);
63 auto cur_point = lane_follow_command->mutable_way_point(0);
64 cur_point->Clear();
65 cur_point->set_x(pose.position().x());
66 cur_point->set_y(pose.position().y());
67 cur_point->set_heading(pose.heading());
68 is_allowed_to_route_ = false;
69 return true;
70 }
71 } else {
73 end_point_, pose.position(),
74 FLAGS_task_manager_threshold_for_destination_check)) {
75 AINFO << "GetNewRouting: reach end point. "
76 << "Remaining cycles: " << cycle_;
77 lane_follow_command->clear_way_point();
78 auto cur_point = lane_follow_command->add_way_point();
79 cur_point->Clear();
80 cur_point->set_x(pose.position().x());
81 cur_point->set_y(pose.position().y());
82 cur_point->set_heading(pose.heading());
83 auto end_pose = lane_follow_command->mutable_end_pose();
84 end_pose->CopyFrom(begin_point_);
85 --cycle_;
86 is_allowed_to_route_ = true;
87 return true;
88 }
89 }
90
91 return false;
92}
93
94} // namespace task_manager
95} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
static Status OK()
generate a success status.
Definition status.h:60
common::Status Init(const task_manager::CycleRoutingTask &cycle_routing_task)
module initialization function
bool GetNewRouting(const localization::Pose &pose, external_command::LaneFollowCommand *lane_follow_command)
Get new routing if the vehicle reaches the begin/end point
#define AINFO
Definition log.h:42
bool CheckPointDistanceInThreshold(external_command::Pose point_a, common::PointENU point_b, double distance)
class register implement
Definition arena_queue.h:37
optional double heading
Definition pose.proto:48
optional apollo::common::PointENU position
Definition pose.proto:26
optional apollo::external_command::LaneFollowCommand lane_follow_command