@@ -896,7 +896,8 @@ void OsiMsgHandler::detected_static_objects_from_ground_truth() {
896
896
}
897
897
898
898
void OsiMsgHandler::from_osi_boundary_points (const osi3::LaneBoundary& osi_lb,
899
- cloe::LaneBoundary& lb) {
899
+ cloe::LaneBoundary& lb,
900
+ bool reverse_pt_order = false ) {
900
901
assert (osi_lb.boundary_line_size () > 0 );
901
902
for (int i = 0 ; i < osi_lb.boundary_line_size (); ++i) {
902
903
const auto & osi_pt = osi_lb.boundary_line (i);
@@ -906,6 +907,10 @@ void OsiMsgHandler::from_osi_boundary_points(const osi3::LaneBoundary& osi_lb,
906
907
cloe::utility::transform_point_to_child_frame (osi_sensor_pose_, &position);
907
908
lb.points .push_back (position);
908
909
}
910
+ // Provide points in ascending order.
911
+ if (reverse_pt_order) {
912
+ std::reverse (lb.points .begin (), lb.points .end ());
913
+ }
909
914
// Compute clothoid segment. TODO(tobias): implement curved segments.
910
915
lb.dx_start = lb.points .front ()(0 );
911
916
lb.dy_start = lb.points .front ()(1 );
@@ -918,8 +923,33 @@ void OsiMsgHandler::from_osi_boundary_points(const osi3::LaneBoundary& osi_lb,
918
923
919
924
void OsiMsgHandler::detected_lane_boundaries_from_ground_truth () {
920
925
const auto & osi_gt = ground_truth_->get_gt ();
921
- int lb_id = 0 ;
926
+ // Flip lane boundary point order if centerline is not in ascending order.
927
+ std::map<int , int > lbs_flip_pt_order;
928
+ for (const auto & osi_lane : osi_gt.lane ()) {
929
+ if (!osi_lane.has_classification ()) {
930
+ continue ;
931
+ }
932
+ if (osi_lane.classification ().centerline_is_driving_direction ()) {
933
+ continue ;
934
+ }
935
+ int lane_id;
936
+ osi_identifier_to_int (osi_lane.id (), lane_id);
937
+ int lb_id;
938
+ for (const auto & osi_lb_id : osi_lane.classification ().right_lane_boundary_id ()) {
939
+ osi_identifier_to_int (osi_lb_id, lb_id);
940
+ lbs_flip_pt_order[lb_id] = lane_id;
941
+ }
942
+ for (const auto & osi_lb_id : osi_lane.classification ().left_lane_boundary_id ()) {
943
+ osi_identifier_to_int (osi_lb_id, lb_id);
944
+ lbs_flip_pt_order[lb_id] = lane_id;
945
+ }
946
+ for (const auto & osi_lb_id : osi_lane.classification ().free_lane_boundary_id ()) {
947
+ osi_identifier_to_int (osi_lb_id, lb_id);
948
+ lbs_flip_pt_order[lb_id] = lane_id;
949
+ }
950
+ }
922
951
// If some of the OSI data does not have an id, avoid id clashes.
952
+ int lb_id = 0 ;
923
953
for (const auto & osi_lb : osi_gt.lane_boundary ()) {
924
954
if (osi_lb.has_classification () && osi_lb.has_id ()) {
925
955
int id;
@@ -940,7 +970,12 @@ void OsiMsgHandler::detected_lane_boundaries_from_ground_truth() {
940
970
lb.prev_id = -1 ; // no concatenated line segments for now
941
971
lb.next_id = -1 ;
942
972
++lb_id;
943
- from_osi_boundary_points (osi_lb, lb);
973
+ if (lbs_flip_pt_order.find (lb.id ) == lbs_flip_pt_order.end ()) {
974
+ from_osi_boundary_points (osi_lb, lb, false );
975
+
976
+ } else {
977
+ from_osi_boundary_points (osi_lb, lb, true );
978
+ }
944
979
lb.type = osi_lane_bdry_type_map.at (osi_lb.classification ().type ());
945
980
lb.color = osi_lane_bdry_color_map.at (osi_lb.classification ().color ());
946
981
store_lane_boundary (lb);
0 commit comments