|
14 | 14 |
|
15 | 15 | #include "autoware/path_generator/utils.hpp"
|
16 | 16 |
|
| 17 | +#include "autoware/trajectory/interpolator/linear.hpp" |
17 | 18 | #include "autoware/trajectory/utils/find_intervals.hpp"
|
18 | 19 |
|
19 | 20 | #include <autoware/motion_utils/constants.hpp>
|
@@ -447,32 +448,11 @@ std::vector<geometry_msgs::msg::Point> crop_line_string(
|
447 | 448 | const std::vector<geometry_msgs::msg::Point> & line_string, const double s_start,
|
448 | 449 | const double s_end)
|
449 | 450 | {
|
450 |
| - // TODO(mitukou1109): use autoware_trajectory |
451 |
| - const auto lanelet_line_string = to_lanelet_points(line_string); |
452 |
| - std::vector<geometry_msgs::msg::Point> cropped_line_string; |
453 |
| - auto s = 0.; |
454 |
| - |
455 |
| - for (auto it = std::next(lanelet_line_string.begin()); it != lanelet_line_string.end(); ++it) { |
456 |
| - const lanelet::BasicLineString3d segment{*std::prev(it), *it}; |
457 |
| - const auto segment_length = lanelet::geometry::length(segment); |
458 |
| - if (s <= s_start) { |
459 |
| - if (s + segment_length < s_start) { |
460 |
| - s += segment_length; |
461 |
| - continue; |
462 |
| - } |
463 |
| - cropped_line_string.push_back(lanelet::utils::conversion::toGeomMsgPt( |
464 |
| - lanelet::geometry::interpolatedPointAtDistance(segment, s_start - s))); |
465 |
| - } |
466 |
| - s += segment_length; |
467 |
| - if (s >= s_end) { |
468 |
| - cropped_line_string.push_back(lanelet::utils::conversion::toGeomMsgPt( |
469 |
| - lanelet::geometry::interpolatedPointAtDistance(segment, s_end - s))); |
470 |
| - break; |
471 |
| - } |
472 |
| - cropped_line_string.push_back(lanelet::utils::conversion::toGeomMsgPt(*it)); |
473 |
| - } |
474 |
| - |
475 |
| - return cropped_line_string; |
| 451 | + auto trajectory = autoware::trajectory::Trajectory<geometry_msgs::msg::Point>::Builder() |
| 452 | + .set_xy_interpolator<trajectory::interpolator::Linear>() |
| 453 | + .build(line_string); |
| 454 | + trajectory->crop(s_start, s_end - s_start); |
| 455 | + return trajectory->restore(); |
476 | 456 | }
|
477 | 457 |
|
478 | 458 | std::array<double, 2> get_arc_length_on_bounds(
|
|
0 commit comments