Apollo 10.0
自动驾驶开放平台
open_space_info.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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
22
23namespace apollo {
24namespace planning {
25
26void CopyTrajectory(const DiscretizedTrajectory trajectory_src,
27 apollo::common::Trajectory* trajectory_tgt_ptr) {
28 const size_t horizon = trajectory_src.NumOfPoints();
29 for (size_t i = 0; i < horizon; ++i) {
30 *trajectory_tgt_ptr->add_trajectory_point() =
31 trajectory_src.TrajectoryPointAt(i);
32 }
33}
34
35// record more trajectory information to info debug
37 // 1, Copy info into ptr_debug
38 *ptr_debug = debug_instance_;
39
40 // 2, record partitioned trajectories into ptr_debug
41 auto* ptr_partitioned_trajectories = ptr_debug->mutable_planning_data()
42 ->mutable_open_space()
43 ->mutable_partitioned_trajectories();
44
45 for (auto& iter : partitioned_trajectories_) {
46 const auto& picked_trajectory = iter.first;
47 auto* ptr_added_trajectory = ptr_partitioned_trajectories->add_trajectory();
48 CopyTrajectory(picked_trajectory, ptr_added_trajectory);
49 }
50
51 // 3, record chosen partitioned into ptr_debug
52 auto* ptr_chosen_trajectory = ptr_debug->mutable_planning_data()
53 ->mutable_open_space()
54 ->mutable_chosen_trajectory()
55 ->add_trajectory();
56 const auto& chosen_trajectory = chosen_partitioned_trajectory_.first;
57 CopyTrajectory(chosen_trajectory, ptr_chosen_trajectory);
58
59 // 4, record if the trajectory is fallback trajectory
60 ptr_debug->mutable_planning_data()
61 ->mutable_open_space()
62 ->set_is_fallback_trajectory(fallback_flag_);
63
64 // 5, record fallback trajectory if needed
65 if (fallback_flag_) {
66 auto* ptr_fallback_trajectory = ptr_debug->mutable_planning_data()
67 ->mutable_open_space()
68 ->mutable_fallback_trajectory()
69 ->add_trajectory();
70 const auto& fallback_trajectory = fallback_trajectory_.first;
71 CopyTrajectory(fallback_trajectory, ptr_fallback_trajectory);
72 ptr_debug->mutable_planning_data()
73 ->mutable_open_space()
74 ->mutable_future_collision_point()
75 ->CopyFrom(future_collision_point_);
76 }
77
78 auto open_space = ptr_debug->mutable_planning_data()->mutable_open_space();
79 open_space->set_time_latency(time_latency_);
80
81 open_space->mutable_origin_point()->set_x(origin_point_.x());
82 open_space->mutable_origin_point()->set_y(origin_point_.y());
83 open_space->mutable_origin_point()->set_z(0.0);
84
85 open_space->set_origin_heading_rad(origin_heading_);
86}
87
88} // namespace planning
89} // namespace apollo
double y() const
Getter for y component
Definition vec2d.h:57
double x() const
Getter for x component
Definition vec2d.h:54
const common::TrajectoryPoint & TrajectoryPointAt(const size_t index) const
const TrajGearPair & fallback_trajectory() const
void RecordDebug(apollo::planning_internal::Debug *ptr_debug)
Planning module main class.
void CopyTrajectory(const DiscretizedTrajectory trajectory_src, apollo::common::Trajectory *trajectory_tgt_ptr)
class register implement
Definition arena_queue.h:37