Apollo 10.0
自动驾驶开放平台
print_debug_info.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2022 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
18
19#include <map>
20#include <string>
21#include <utility>
22#include <vector>
23
26
27namespace apollo {
28namespace planning {
29
31
32void PrintPoints::set_id(std::string id) { id_ = id; }
33void PrintPoints::AddPoint(double x, double y) { points.emplace_back(x, y); }
34
36 if (!FLAGS_enable_print_curve) {
37 return;
38 }
39 std::stringstream ssm;
40 ssm << "print_" << id_ << ":";
41 for (size_t i = 0; i < points.size(); i++) {
42 ssm << std::fixed << "(" << points[i].first << ", " << points[i].second
43 << ");";
44 }
45 AINFO << ssm.str();
46}
47
48void PrintCurves::AddPoint(std::string key, double x, double y) {
49 if (!FLAGS_enable_print_curve) {
50 return;
51 }
52 if (curve_map_.count(key) == 0) {
53 curve_map_[key] = PrintPoints(key);
54 }
55 curve_map_[key].AddPoint(x, y);
56}
57
58void PrintCurves::AddPoint(std::string key,
59 const apollo::common::math::Vec2d& point) {
60 if (!FLAGS_enable_print_curve) {
61 return;
62 }
63 if (curve_map_.count(key) == 0) {
64 curve_map_[key] = PrintPoints(key);
65 }
66 curve_map_[key].AddPoint(point.x(), point.y());
67}
68
69void PrintCurves::AddPoint(std::string key,
70 const std::vector<common::math::Vec2d>& points) {
71 if (!FLAGS_enable_print_curve) {
72 return;
73 }
74 for (const auto& point : points) {
75 AddPoint(key, point);
76 }
77}
79 if (!FLAGS_enable_print_curve) {
80 return;
81 }
82 for (auto iter = curve_map_.begin(); iter != curve_map_.end(); iter++) {
83 iter->second.PrintToLog();
84 }
85}
86
87void apollo::planning::PrintBox::AddAdcBox(double x, double y, double heading,
88 bool is_rear_axle_point) {
89 const auto& vehicle_param =
91 if (is_rear_axle_point) {
92 // rear center
93 double rear_axle_to_center =
94 vehicle_param.front_edge_to_center() - vehicle_param.length() / 2.0;
95 x += rear_axle_to_center * cos(heading);
96 y += rear_axle_to_center * sin(heading);
97 }
98 box_points.push_back(
99 {x, y, heading, vehicle_param.length(), vehicle_param.width()});
100}
101
103 std::stringstream ssm;
104 ssm << "print_" << id_ << ":";
105 for (size_t i = 0; i < box_points.size(); i++) {
106 ssm << "(";
107 for (size_t j = 0; j < box_points[i].size(); j++) {
108 ssm << std::fixed << box_points[i][j];
109 if (j != box_points[i].size() - 1) {
110 ssm << ", ";
111 }
112 }
113 ssm << ")";
114 if (i != box_points.size() - 1) {
115 ssm << ", ";
116 }
117 }
118 AINFO << ssm.str();
119}
120
121} // namespace planning
122} // namespace apollo
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
Implements a class of 2-dimensional vectors.
Definition vec2d.h:42
double y() const
Getter for y component
Definition vec2d.h:57
double x() const
Getter for x component
Definition vec2d.h:54
void AddAdcBox(double x, double y, double heading, bool is_rear_axle_point=true)
void AddPoint(std::string key, double x, double y)
add point to curve key
void set_id(std::string id)
set curve id
void PrintToLog()
print curve to log
void AddPoint(double x, double y)
add points to curve
Planning module main class.
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37
optional VehicleParam vehicle_param