feat(autoware_trajectory): add temporal trajectory class#998
Draft
yhisaki wants to merge 60 commits intoautowarefoundation:mainfrom
Draft
feat(autoware_trajectory): add temporal trajectory class#998yhisaki wants to merge 60 commits intoautowarefoundation:mainfrom
yhisaki wants to merge 60 commits intoautowarefoundation:mainfrom
Conversation
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
33aba16 to
4bb9904
Compare
b912720 to
87b17db
Compare
…calculation Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Apply trajectory offsets with full quaternion rotation instead of yaw only so roll, pitch, and vertical offsets are respected. Update the utility documentation and extend tests to cover pitched and fully oriented trajectory points. Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Simplify the offset test helpers by using a single trajectory point factory that covers position and full orientation inputs. This keeps the test setup consistent across yaw-only and 3D pose cases while preserving coverage for combined offset behavior. Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Trim the example to focus on generating and visualizing offset trajectories from position-only points. Use trajectory direction alignment to derive orientations instead of manually assigning yaw and remove unused velocity diagnostics to keep the sample easier to follow. Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…istance management features Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…tionality Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Extract time-distance mapping into a dedicated helper and use it for time range cropping, stopline edits, and distance-to-time queries. This allows temporal trajectories to build from single-point inputs and from points with duplicate timestamps by extending time bases instead of failing. It also simplifies restore behavior and adds an example mode to plot restored underlying points. Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Add add_offset() utility function to compute trajectory offset from base_link by a fixed vehicle-frame offset. - Add position offset using pose orientation (or trajectory azimuth for Point) - Adjust velocity for rotational motion using heading_rate_rps - Add unit tests for position and velocity offset - Add example with circular arc trajectory and plotting Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…tions and related tests Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Add crop_distance() method to crop the trajectory by distance interval instead of time interval. - Add crop_distance(start_distance, length) declaration to header - Add implementation that converts distance to time for time-distance mapping - Crop spatial trajectory and update time range accordingly Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…of returning nullopt Change TimeDistanceMapping::time_at_distance() to clamp the input distance to the valid range instead of returning std::nullopt when the distance is outside the visible trajectory range. - Clamp distance to [start_distance(), end_distance()] - Update documentation to reflect new behavior Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…le instead of optional Change TimeDistanceMapping::time_at_distance() and TemporalTrajectory::distance_to_time() to return double instead of std::optional<double>. The distance is now clamped to the valid range instead of returning nullopt when out of bounds. - Update return type from std::optional<double> to double - Add distance clamping in time_at_distance() - Update all callers to use non-optional return value Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Update test_temporal_trajectory.cpp to use the new double return type for distance_to_time() instead of std::optional<double>. Add new test cases: - distance_to_time_clamps_below_range - distance_to_time_clamps_above_range - compute_from_distance_at_boundaries - compute_from_time_at_boundaries - restore_after_crop_time Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…ory::add_offset Use compute_from_distance() instead of spatial_traj.compute() to preserve the time_from_start field when building the offset trajectory. This ensures the duration is correctly maintained after offset. Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…ting in tests Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…rajectory processing Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…additional scenarios and refactor existing tests Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…enhance tests for duplicate points handling Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…s to support end time retrieval and update related tests Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…d accuracy in restored trajectory validation Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…tion and improve error handling for duration and length parameters Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…nhance curvature calculation for improved accuracy Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
- Updated various functions to replace the use of `k_points_minimum_dist_threshold` with `k_epsilon_distance` for better precision in distance comparisons. - Enhanced the `is_almost_same` function to include quaternion comparisons using `tf2` for improved accuracy in orientation checks. - Modified the `pretty_build_temporal` function to utilize `k_epsilon_distance` for trajectory length validation. - Adjusted test cases across multiple files to reflect the new threshold constants and ensure consistency in distance checks. - Introduced `is_almost_same` as a parameter in the `crossed_with_constraint_impl` function to allow for customizable comparison logic. Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Kotakku
reviewed
Apr 21, 2026
Comment on lines
+247
to
+249
| friend TemporalTrajectory set_stopline(TemporalTrajectory trajectory, double arc_length); | ||
| friend TemporalTrajectory set_stopline( | ||
| TemporalTrajectory trajectory, double arc_length, double duration); |
Contributor
There was a problem hiding this comment.
The two set_stopline overloads share a name but behave quite differently, which is confusing. I'd recommend splitting them into distinct function names to avoid confusion.
| /** @brief Return the user-configured time offset in seconds. */ | ||
| [[nodiscard]] double time_offset() const; | ||
|
|
||
| /** @brief Return the stored time bases. */ |
Contributor
There was a problem hiding this comment.
The current docstring "Return the stored time bases." is slightly misleading.
the function actually returns the cropped/offset-adjusted bases, not the raw stored ones. Suggest aligning with the spatial Trajectory<T>::get_underlying_bases() wording, e.g. "Get the underlying time bases of the trajectory".
…t_stop_duration for clarity Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…precated for clarity Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
…_minimum_dist_threshold Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Before this PR,
autoware_trajectoryonly provided spatial trajectory utilities, and it did not support consistent time-parameterized trajectory evaluation, cropping, or stopline editing on aTrajectoryPointsequence.This PR adds and refactors temporal trajectory support in
autoware_trajectory.TemporalTrajectoryand the internalTimeDistanceMappingutility to evaluate a trajectory from both time and distance.crop_time,crop_distance,set_stopline,set_time_offset,time_to_distance, anddistance_to_time, and make zero-length crop edge cases valid.add_offset,crossed,find_intervals, andpretty_build_temporal.Linear,CubicSpline,AkimaSpline, andSphericalLinearto remove near-duplicate bases usingk_points_minimum_dist_thresholdbefore interpolation.ENABLE_TEST_PLOT=1.Execution Results of examples
example_temporal_trajectory.cppexample_temporal_crop.cppexample_temporal_curvature.cppRelated links
Parent Issue:
Notes for reviewers
Please review this PR in the following order:
include/autoware/trajectory/temporal_trajectory.hppandsrc/temporal_trajectory.cppinclude/autoware/trajectory/detail/time_distance_mapping.hppandsrc/detail/time_distance_mapping.cpputils/add_offset.hpp,utils/crop.hpp,utils/crossed.hpp,utils/find_intervals.hpp,utils/pretty_build.hpp,utils/set_stopline.hpp, andutils/set_time_offset.hpptest/test_temporal_trajectory.cpp,test/test_utils_temporal_trajectory.cpp,test/test_add_offset.cpp, andtest/test_crossed.cpptest/test_main.cppEffects on system behavior
autoware::experimental::trajectory::TemporalTrajectorybecomes a new public API for time-parameterizedTrajectoryPointhandling.add_offsetnow supportsTemporalTrajectoryin addition to spatialTrajectory<PointType>.crossednow supportsTemporalTrajectoryand returnsTimeDistancePairvalues.find_intervalsnow supports temporal queries and returnsTemporalIntervalwith both distance and time ranges.pretty_build_temporalbecomes available as a convenience wrapper for temporal trajectory construction.set_time_offsetbecomes available to shift the public time axis without rebuilding the spatial trajectory.distance_to_timenow supports disambiguating stop plateaus withreturn_end_time; by default it returns the first stop time, and withtrueit returns the stop end time.time_to_distance,distance_to_time,compute_from_time, andcompute_from_distancequeries throwstd::out_of_range.crossed,crossed_with_constraint, andcrossed_with_polygonno longer take optional search-range arguments; callers should crop the trajectory first when they want a limited search range.add_offsetno longer adjusts velocity fields when applying a geometric offset.ENABLE_TEST_PLOT=1is set.