Each stage does its business logic inside Process function.
If the stage want to transit to a different stage after finish, it should set the type of 'next_stage_'.
46 {
47 auto* mutable_open_space_info = frame->mutable_open_space_info();
48 const auto& free_space_command = GetContextAs<FreeSpaceContext>()->free_space_command;
49
50 std::vector<std::vector<common::math::Vec2d>> roi_boundary;
51 roi_boundary.emplace_back();
52 const auto& parking_roi = free_space_command.drivable_roi();
53 for (int j = 0; j < parking_roi.point_size(); j++) {
54 roi_boundary.back().emplace_back(parking_roi.point(j).x(), parking_roi.point(j).y());
55 }
56 if (roi_boundary.back().begin()->DistanceTo(*roi_boundary.back().rbegin()) > 0.01) {
57 roi_boundary.back().push_back(*roi_boundary.begin()->begin());
58 }
59
61
62 auto roi_x_min = mutable_open_space_info->mutable_ROI_xy_boundary()->at(0);
63 auto roi_x_max = mutable_open_space_info->mutable_ROI_xy_boundary()->at(1);
64 auto roi_y_min = mutable_open_space_info->mutable_ROI_xy_boundary()->at(2);
65 auto roi_y_max = mutable_open_space_info->mutable_ROI_xy_boundary()->at(3);
66 for (int i = 0; i < free_space_command.non_drivable_roi_size(); i++) {
67 roi_boundary.emplace_back();
68 const auto& parking_roi = free_space_command.non_drivable_roi(i);
69 for (int j = 0; j < parking_roi.point_size(); j++) {
70 auto x = parking_roi.point(j).x();
71 auto y = parking_roi.point(j).y();
72 if (x < roi_x_min || x > roi_x_max || y < roi_y_min || y > roi_y_max) {
73 AERROR <<
"non drivable roi should be contained by drivable roi";
75 }
76 roi_boundary.back().emplace_back(x, y);
77 }
78 }
79 if (roi_boundary.back().begin()->DistanceTo(*roi_boundary.back().rbegin()) > 0.01) {
80 roi_boundary.back().push_back(*roi_boundary.begin()->begin());
81 }
82
83 auto* open_space_end_pose = mutable_open_space_info->mutable_open_space_end_pose();
84 open_space_end_pose->push_back(free_space_command.parking_spot_pose().x());
85 open_space_end_pose->push_back(free_space_command.parking_spot_pose().y());
86 open_space_end_pose->push_back(free_space_command.parking_spot_pose().heading());
87 open_space_end_pose->push_back(0);
88
90 double d_x = frame->vehicle_state().x() - free_space_command.parking_spot_pose().x();
91 double d_y = frame->vehicle_state().y() - free_space_command.parking_spot_pose().y();
92 double d_heading = frame->vehicle_state().heading() - free_space_command.parking_spot_pose().heading();
93 AINFO <<
"Current position diff with end pose! x= " << d_x <<
";y= " << d_y <<
";heading" << d_heading
94 << ";Distance with end pose:" << std::sqrt(d_x * d_x + d_y * d_y);
95
100 mutable_open_space_info->ROI_xy_boundary(),
101 frame,
102 &roi_boundary);
103 }
104 *mutable_open_space_info->mutable_obstacles_vertices_vec() = roi_boundary;
105
106 const auto& xy_boundary = mutable_open_space_info->ROI_xy_boundary();
107 Vec2d origin_point(xy_boundary[0], xy_boundary[2]);
109
112 }
113 mutable_open_space_info->set_is_on_open_space_trajectory(true);
114
116 if (result.HasError()) {
117 AERROR <<
"StageFreeSpace planning error";
119 }
121}
static bool FormulateBoundaryConstraints(OpenSpaceInfo *const open_space_info)
main process to compute and load info needed by open space planner
static bool LoadObstacles(const double filtering_distance, const double perception_obstacle_buffer, const std::vector< double > &xy_boundary, Frame *const frame, std::vector< std::vector< common::math::Vec2d > > *const roi_parking_boundary)
Load obstacle polygon to roi_boundary in clock wise order
static void TransformByOriginPoint(const common::math::Vec2d &origin_point, const double heading, std::vector< std::vector< common::math::Vec2d > > *roi_parking_boundary)
static void GetRoiXYBoundary(const std::vector< std::vector< common::math::Vec2d > > &roi_parking_boundary, std::vector< double > *const XYBoundary)
get XY boundary which is minmax x or y in roi boundary
StageResult ExecuteTaskOnOpenSpace(Frame *frame)
optional double perception_obstacle_buffer
optional double filtering_distance
optional bool enabled_perception_obstacles