30
30
#include < string>
31
31
#include < vector>
32
32
33
- // for writing the svg file
34
- #include < fstream>
35
- #include < iostream>
36
- // for the geometry types
37
- #include < tier4_autoware_utils/geometry/geometry.hpp>
38
- // for the svg mapper
39
- #include < boost/geometry/io/svg/svg_mapper.hpp>
40
- #include < boost/geometry/io/svg/write.hpp>
41
-
42
33
namespace behavior_velocity_planner ::out_of_lane
43
34
{
44
35
void cut_predicted_path_beyond_line (
@@ -59,14 +50,16 @@ void cut_predicted_path_beyond_line(
59
50
}
60
51
path_segment.first = path_segment.second ;
61
52
}
62
- auto cut_idx = stop_line_idx;
63
- double arc_length = 0 ;
64
- while (cut_idx > 0 && arc_length < object_front_overhang) {
65
- arc_length += tier4_autoware_utils::calcDistance2d (
66
- predicted_path.path [cut_idx], predicted_path.path [cut_idx - 1 ]);
67
- --cut_idx;
53
+ if (found) {
54
+ auto cut_idx = stop_line_idx;
55
+ double arc_length = 0 ;
56
+ while (cut_idx > 0 && arc_length < object_front_overhang) {
57
+ arc_length += tier4_autoware_utils::calcDistance2d (
58
+ predicted_path.path [cut_idx], predicted_path.path [cut_idx - 1 ]);
59
+ --cut_idx;
60
+ }
61
+ predicted_path.path .resize (cut_idx);
68
62
}
69
- predicted_path.path .resize (cut_idx);
70
63
}
71
64
72
65
std::optional<const lanelet::BasicLineString2d> find_next_stop_line (
@@ -98,23 +91,10 @@ std::optional<const lanelet::BasicLineString2d> find_next_stop_line(
98
91
// / @param [in] planner_data planner data to get the map and traffic light information
99
92
void cut_predicted_path_beyond_red_lights (
100
93
autoware_auto_perception_msgs::msg::PredictedPath & predicted_path,
101
- const PlannerData & planner_data, const double object_front_overhang, int i )
94
+ const PlannerData & planner_data, const double object_front_overhang)
102
95
{
103
- // Declare a stream and an SVG mapper
104
- std::ofstream svg (
105
- " /home/mclement/Pictures/image" + std::to_string (i) + " .svg" ); // /!\ CHANGE PATH
106
- boost::geometry::svg_mapper<tier4_autoware_utils::Point2d> mapper (svg, 400 , 400 );
107
96
const auto stop_line = find_next_stop_line (predicted_path, planner_data);
108
- lanelet::BasicLineString2d path_ls;
109
- for (const auto & p : predicted_path.path ) path_ls.emplace_back (p.position .x , p.position .y );
110
97
if (stop_line) cut_predicted_path_beyond_line (predicted_path, *stop_line, object_front_overhang);
111
- lanelet::BasicLineString2d cut_path_ls;
112
- for (const auto & p : predicted_path.path ) cut_path_ls.emplace_back (p.position .x , p.position .y );
113
- mapper.add (cut_path_ls);
114
- if (stop_line) mapper.add (*stop_line);
115
- mapper.map (path_ls, " opacity:0.3;fill:black;stroke:black;stroke-width:2" );
116
- if (stop_line) mapper.map (*stop_line, " opacity:0.5;fill:black;stroke:red;stroke-width:2" );
117
- mapper.map (cut_path_ls, " opacity:0.3;fill:red;stroke:red;stroke-width:2" );
118
98
}
119
99
120
100
// / @brief filter predicted objects and their predicted paths
@@ -153,11 +133,10 @@ autoware_auto_perception_msgs::msg::PredictedObjects filter_predicted_objects(
153
133
const auto new_end =
154
134
std::remove_if (predicted_paths.begin (), predicted_paths.end (), is_invalid_predicted_path);
155
135
predicted_paths.erase (new_end, predicted_paths.end ());
156
- auto i = 0 ;
157
- if (true || params.objects_cut_predicted_paths_beyond_red_lights )
136
+ if (params.objects_cut_predicted_paths_beyond_red_lights )
158
137
for (auto & predicted_path : predicted_paths)
159
138
cut_predicted_path_beyond_red_lights (
160
- predicted_path, planner_data, filtered_object.shape .dimensions .x , i++ );
139
+ predicted_path, planner_data, filtered_object.shape .dimensions .x );
161
140
predicted_paths.erase (
162
141
std::remove_if (
163
142
predicted_paths.begin (), predicted_paths.end (),
0 commit comments