Feed map waypoints into local map
| 476 | |
| 477 | // Feed map waypoints into local map |
| 478 | bool FissPlannerNode::feedWaypoints() |
| 479 | { |
| 480 | if (lane_.points.empty()) |
| 481 | { |
| 482 | ROS_WARN("Local Planner: Waiting for Lane Points"); |
| 483 | return false; |
| 484 | } |
| 485 | else if (lane_.points.size() < 5) |
| 486 | { |
| 487 | ROS_WARN("Local Planner: Global Path has less than 5 points, unable to plan"); |
| 488 | return false; |
| 489 | } |
| 490 | |
| 491 | int start_id = lastWaypoint(current_state_, lane_); |
| 492 | |
| 493 | // if reached the end of the lane, stop |
| 494 | if (start_id >= lane_.points.size() - 2) // exclude last 2 waypoints for safety, and prevent code crashing |
| 495 | { |
| 496 | // ROS_WARN("Local Planner: Vehicle is at waypoint no.%d, with %d waypoints in total", start_id, int(lane_.points.size())); |
| 497 | ROS_WARN("Local Planner: Vehicle has reached the destination"); |
| 498 | return false; |
| 499 | } |
| 500 | |
| 501 | const double dist = distance(lane_.points[start_id].point.x, lane_.points[start_id].point.y, current_state_.x, current_state_.y); |
| 502 | const double heading_diff = unifyAngleRange(current_state_.yaw - lane_.points[start_id].point.yaw); |
| 503 | |
| 504 | if (dist > MAX_DIST_FROM_PATH) |
| 505 | { |
| 506 | ROS_WARN("Local Planner: Vehicle's Location Is Too Far From The Target Lane"); |
| 507 | return false; |
| 508 | } |
| 509 | else if (std::abs(heading_diff) > HEADING_DIFF_THRESH) |
| 510 | { |
| 511 | ROS_WARN("Local Planner: Vehicle's Is Heading In A Different Direction"); |
| 512 | return false; |
| 513 | } |
| 514 | |
| 515 | // clear the old waypoints |
| 516 | local_lane_.clear(); |
| 517 | |
| 518 | // Make sure there are at least 5 points in the remaining section of the global reference path |
| 519 | if (start_id > lane_.points.size() - 5) |
| 520 | { |
| 521 | start_id = lane_.points.size() - 5; |
| 522 | } |
| 523 | |
| 524 | // Check if the global waypoints need to be filtered |
| 525 | const double ref_spline_length = SETTINGS.highest_speed*(SETTINGS.max_t); |
| 526 | if ((lane_.points.back().point.s - lane_.points[start_id].point.s) >= ref_spline_length) |
| 527 | { |
| 528 | // Filter the waypoints to a uniform density |
| 529 | double s_current = lane_.points[start_id].point.s; |
| 530 | local_lane_.points.push_back(lane_.points[start_id]); |
| 531 | for (size_t i = start_id + 1; i < lane_.points.size(); i++) |
| 532 | { |
| 533 | if (local_lane_.points.size() >= 5) |
| 534 | { |
| 535 | break; |
nothing calls this directly
no test coverage detected