25
25
#include < visualization_msgs/msg/detail/marker__struct.hpp>
26
26
#include < visualization_msgs/msg/detail/marker_array__struct.hpp>
27
27
28
+ #include < fmt/format.h>
29
+
28
30
#include < algorithm>
29
31
#include < cstdint>
30
32
#include < cstdlib>
31
- #include < sstream>
32
33
#include < string>
33
34
#include < vector>
34
35
@@ -52,27 +53,6 @@ MarkerArray showAllValidLaneChangePath(
52
53
const auto loop_size = std::min (lane_change_paths.size (), colors.size ());
53
54
marker_array.markers .reserve (loop_size);
54
55
55
- const auto info_prep_to_string =
56
- [](const autoware::behavior_path_planner::lane_change::Info & info) -> std::string {
57
- std::ostringstream ss_text;
58
- ss_text << std::setprecision (3 ) << " vel: " << info.velocity .prepare
59
- << " [m/s] | lon_acc: " << info.longitudinal_acceleration .prepare
60
- << " [m/s2] | t: " << info.duration .prepare << " [s] | L: " << info.length .prepare
61
- << " [m]" ;
62
- return ss_text.str ();
63
- };
64
-
65
- const auto info_lc_to_string =
66
- [](const autoware::behavior_path_planner::lane_change::Info & info) -> std::string {
67
- std::ostringstream ss_text;
68
- ss_text << std::setprecision (3 ) << " vel: " << info.velocity .lane_changing
69
- << " [m/s] | lon_acc: " << info.longitudinal_acceleration .lane_changing
70
- << " [m/s2] | lat_acc: " << info.lateral_acceleration
71
- << " [m/s2] | t: " << info.duration .lane_changing
72
- << " [s] | L: " << info.length .lane_changing << " [m]" ;
73
- return ss_text.str ();
74
- };
75
-
76
56
for (std::size_t idx = 0 ; idx < loop_size; ++idx) {
77
57
int32_t id{0 };
78
58
const auto & lc_path = lane_change_paths.at (idx);
@@ -91,19 +71,30 @@ MarkerArray showAllValidLaneChangePath(
91
71
marker.points .push_back (point.point .pose .position );
92
72
}
93
73
74
+ const auto & info = lc_path.info ;
94
75
auto text_marker = createDefaultMarker (
95
76
" map" , current_time, ns_with_idx, ++id, visualization_msgs::msg::Marker::TEXT_VIEW_FACING,
96
77
createMarkerScale (0.1 , 0.1 , 0.8 ), colors::yellow ());
97
78
const auto prep_idx = points.size () / 4 ;
98
79
text_marker.pose = points.at (prep_idx).point .pose ;
99
80
text_marker.pose .position .z += 2.0 ;
100
- text_marker.text = info_prep_to_string (lc_path.info );
81
+ text_marker.text = fmt::format (
82
+ " vel: {vel:.3f}[m/s] | lon_acc: {lon_acc:.3f}[m/s2] | t: {time:.3f}[s] | L: {length:.3f}[m]" ,
83
+ fmt::arg (" vel" , info.velocity .prepare ),
84
+ fmt::arg (" lon_acc" , info.longitudinal_acceleration .prepare ),
85
+ fmt::arg (" time" , info.duration .prepare ), fmt::arg (" length" , info.length .prepare ));
101
86
marker_array.markers .push_back (text_marker);
102
87
103
88
const auto lc_idx = points.size () / 2 ;
104
89
text_marker.id = ++id;
105
90
text_marker.pose = points.at (lc_idx).point .pose ;
106
- text_marker.text = info_lc_to_string (lc_path.info );
91
+ text_marker.text = fmt::format (
92
+ " vel: {vel:.3f}[m/s] | lon_acc: {lon_acc:.3f}[m/s2] | lat_acc: {lat_acc:.3f}[m/s2] | t: "
93
+ " {time:.3f}[s] | L: {length:.3f}[m]" ,
94
+ fmt::arg (" vel" , info.velocity .lane_changing ),
95
+ fmt::arg (" lon_acc" , info.longitudinal_acceleration .lane_changing ),
96
+ fmt::arg (" lat_acc" , info.lateral_acceleration ), fmt::arg (" time" , info.duration .lane_changing ),
97
+ fmt::arg (" length" , info.length .lane_changing ));
107
98
marker_array.markers .push_back (text_marker);
108
99
109
100
marker_array.markers .push_back (marker);
@@ -186,17 +177,10 @@ MarkerArray showExecutionInfo(const Debug & debug_data, const geometry_msgs::msg
186
177
safety_check_info_text.pose = ego_pose;
187
178
safety_check_info_text.pose .position .z += 4.0 ;
188
179
189
- std::ostringstream ss;
190
-
191
- ss << " \n DistToEndOfCurrentLane: " << std::setprecision (5 )
192
- << debug_data.distance_to_end_of_current_lane
193
- << " \n DistToLaneChangeFinished: " << debug_data.distance_to_lane_change_finished
194
- << (debug_data.is_stuck ? " \n VehicleStuck" : " " )
195
- << (debug_data.is_able_to_return_to_current_lane ? " \n AbleToReturnToCurrentLane" : " " )
196
- << (debug_data.is_abort ? " \n Aborting" : " " )
197
- << " \n DistanceToAbortFinished: " << debug_data.distance_to_abort_finished ;
198
-
199
- safety_check_info_text.text = ss.str ();
180
+ safety_check_info_text.text = fmt::format (
181
+ " {stuck} | {return_lane} | {abort}" , fmt::arg (" stuck" , debug_data.is_stuck ? " is stuck" : " " ),
182
+ fmt::arg (" return_lane" , debug_data.is_able_to_return_to_current_lane ? " " : " can't return" ),
183
+ fmt::arg (" abort" , debug_data.is_abort ? " aborting" : " " ));
200
184
marker_array.markers .push_back (safety_check_info_text);
201
185
return marker_array;
202
186
}
0 commit comments