Skip to content

Commit

Permalink
perf(autoware_map_based_prediction): improve orientation calculation …
Browse files Browse the repository at this point in the history
…and resample converted path (autowarefoundation#8427)

* refactor: improve orientation calculation and resample converted path with linear interpolation

Simplify the calculation of the orientation for each pose in the convertPathType function by directly calculating the sine and cosine of half the yaw angle. This improves efficiency and readability. Also, improve the resampling of the converted path by using linear interpolation for better performance.

Signed-off-by: Taekjin LEE <[email protected]>

* Update perception/autoware_map_based_prediction/src/map_based_prediction_node.cpp

Co-authored-by: Kotaro Uetake <[email protected]>

* Update perception/autoware_map_based_prediction/src/map_based_prediction_node.cpp

Co-authored-by: Kotaro Uetake <[email protected]>

---------

Signed-off-by: Taekjin LEE <[email protected]>
Co-authored-by: Shumpei Wakabayashi <[email protected]>
Co-authored-by: Kotaro Uetake <[email protected]>
  • Loading branch information
3 people authored and esteve committed Aug 13, 2024
1 parent 8acb53a commit 237e356
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,13 @@ std::vector<PosePath> MapBasedPredictionNode::convertPathType(

const double lane_yaw = std::atan2(
current_p.position.y - prev_p.position.y, current_p.position.x - prev_p.position.x);
current_p.orientation = autoware::universe_utils::createQuaternionFromYaw(lane_yaw);
const double sin_yaw_half = std::sin(lane_yaw / 2.0);
const double cos_yaw_half = std::cos(lane_yaw / 2.0);
current_p.orientation.x = 0.0;
current_p.orientation.y = 0.0;
current_p.orientation.z = sin_yaw_half;
current_p.orientation.w = cos_yaw_half;

converted_path.push_back(current_p);
prev_p = current_p;
}
Expand Down Expand Up @@ -2435,15 +2441,27 @@ std::vector<PosePath> MapBasedPredictionNode::convertPathType(

const double lane_yaw = std::atan2(
current_p.position.y - prev_p.position.y, current_p.position.x - prev_p.position.x);
current_p.orientation = autoware::universe_utils::createQuaternionFromYaw(lane_yaw);
const double sin_yaw_half = std::sin(lane_yaw / 2.0);
const double cos_yaw_half = std::cos(lane_yaw / 2.0);
current_p.orientation.x = 0.0;
current_p.orientation.y = 0.0;
current_p.orientation.z = sin_yaw_half;
current_p.orientation.w = cos_yaw_half;

converted_path.push_back(current_p);
prev_p = current_p;
}
}

// Resample Path
const auto resampled_converted_path =
autoware::motion_utils::resamplePoseVector(converted_path, reference_path_resolution_);
const bool use_akima_spline_for_xy = true;
const bool use_lerp_for_z = true;
// the options use_akima_spline_for_xy and use_lerp_for_z are set to true
// but the implementation of use_akima_spline_for_xy in resamplePoseVector and
// resamplePointVector is opposite to the options so the options are set to true to use linear
// interpolation for xy
const auto resampled_converted_path = autoware::motion_utils::resamplePoseVector(
converted_path, reference_path_resolution_, use_akima_spline_for_xy, use_lerp_for_z);
converted_paths.push_back(resampled_converted_path);
}

Expand Down

0 comments on commit 237e356

Please sign in to comment.