Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tier4_autoware_utils): expand geometry and trajectory utility functions #990

Conversation

satoshi-ota
Copy link
Contributor

@satoshi-ota satoshi-ota commented May 30, 2022

Description

In this PR, I expanded geometry and trajectory utility functions:

geometry

support autoware_auto_planning_msgs::msg::PathWithLaneId

template <>
inline geometry_msgs::msg::Point getPoint(
  const autoware_auto_planning_msgs::msg::PathPointWithLaneId & p);

template <>
inline geometry_msgs::msg::Pose getPose(
  const autoware_auto_planning_msgs::msg::PathPointWithLaneId & p);

add new utility functions

  • setPose()
template <class T>
void setPose(const geometry_msgs::msg::Pose & pose, [[maybe_unused]] T & p);

template <>
inline void setPose(const geometry_msgs::msg::Pose & pose, geometry_msgs::msg::Pose & p);

template <>
inline void setPose(const geometry_msgs::msg::Pose & pose, geometry_msgs::msg::PoseStamped & p);

template <>
inline void setPose(
  const geometry_msgs::msg::Pose & pose, autoware_auto_planning_msgs::msg::PathPoint & p);

template <>
inline void setPose(
  const geometry_msgs::msg::Pose & pose, autoware_auto_planning_msgs::msg::PathPointWithLaneId & p);

template <>
inline void setPose(
  const geometry_msgs::msg::Pose & pose, autoware_auto_planning_msgs::msg::TrajectoryPoint & p);

trajectory

add new utility functions

  • calcLongitudinalOffsetPoint()
/**
 * @brief calculate the point offset from source point along the trajectory (or path)
 * @param points points of trajectory, path, ...
 * @param src_idx index of source point
 * @param offset length of offset from source point
 * @return offset point
 */
template <class T>
boost::optional<geometry_msgs::msg::Point> calcLongitudinalOffsetPoint(
  const T & points, const size_t src_idx, const double offset);

/**
 * @brief calculate the point offset from source point along the trajectory (or path)
 * @param points points of trajectory, path, ...
 * @param src_point source point
 * @param offset length of offset from source point
 * @return offset point
 */
template <class T>
boost::optional<geometry_msgs::msg::Point> calcLongitudinalOffsetPoint(
  const T & points, const geometry_msgs::msg::Point & src_point, const double offset);
  • calcLongitudinalOffsetPose()
/**
 * @brief calculate the point offset from source point along the trajectory (or path)
 * @param points points of trajectory, path, ...
 * @param src_idx index of source point
 * @param offset length of offset from source point
 * @return offset pose
 */
template <class T>
boost::optional<geometry_msgs::msg::Point> calcLongitudinalOffsetPose(
  const T & points, const size_t src_idx, const double offset);

/**
 * @brief calculate the point offset from source point along the trajectory (or path)
 * @param points points of trajectory, path, ...
 * @param src_point source point
 * @param offset length of offset from source point
 * @return offset pose
 */
template <class T>
boost::optional<geometry_msgs::msg::Point> calcLongitudinalOffsetPoint(
  const T & points, const geometry_msgs::msg::Point & src_point, const double offset);
  • insertTargetPoint()
/**
 * @brief calculate the point offset from source point along the trajectory (or path)
 * @param seg_idx segment index of point at beginning of length
 * @param p_target point to be inserted
 * @param points output points of trajectory, path, ...
 * @return index of insert point
 */
template <class T>
inline size_t insertTargetPoint(
  const size_t seg_idx, const geometry_msgs::msg::Point & p_target, T & points,
  const double overlap_threshold = 1e-3)

Related links

Tests performed

  • please check whether unit test is valid.

Notes for reviewers

Example usage

Insert a stop point 5.0m before the obstacle.

...
auto output_trajectory = input_trajectory;

const auto obstacle_poisition = ... (geometry_msgs::msg::Point)
const auto target_point = calcLongitudinalOffsetPoint(input_trajectory.points, obstacle_position, -5.0);
const size_t base_idx = findNearestSegmetnIndex(input_trajectory.points, obstacle_position);
const size_t insert_idx = insertTargetPoint(base_idx, target_point, output_trajectory.points);

for (size_t i = insert_idx; i < output_trajectory.points.size(); ++i)
{
  output_trajectory.points.at(i).longitudinal_velocity_mps = 0.0;
}
...

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

  • The PR follows the pull request guidelines.
  • The PR has been properly tested.
  • The PR has been reviewed by the code owners.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.
  • The PR is ready for merge.

After all checkboxes are checked, anyone who has write access can merge the PR.

@satoshi-ota satoshi-ota marked this pull request as ready for review May 30, 2022 06:10
@satoshi-ota satoshi-ota force-pushed the feature/expand-tier4-autoware-utils branch 2 times, most recently from 7794250 to 1bd835a Compare May 30, 2022 23:13
@codecov
Copy link

codecov bot commented May 31, 2022

Codecov Report

Merging #990 (567a39c) into main (138b159) will increase coverage by 0.75%.
The diff coverage is 38.28%.

@@           Coverage Diff            @@
##            main    #990      +/-   ##
========================================
+ Coverage   9.13%   9.89%   +0.75%     
========================================
  Files       1036    1042       +6     
  Lines      70787   74549    +3762     
  Branches   14781   17219    +2438     
========================================
+ Hits        6469    7375     +906     
- Misses     59008   60870    +1862     
- Partials    5310    6304     +994     
Flag Coverage Δ *Carryforward flag
differential 10.11% <36.52%> (?)
total 9.12% <57.14%> (ø) Carriedforward from 138b159

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
...lanner/include/behavior_path_planner/utilities.hpp 0.00% <ø> (ø)
...vior_velocity_planner/include/utilization/util.hpp 5.30% <ø> (+1.55%) ⬆️
...autoware_utils/test/src/geometry/test_geometry.cpp 44.27% <27.45%> (+4.83%) ⬆️
...ils/test/src/trajectory/test_path_with_lane_id.cpp 27.65% <27.65%> (ø)
...ware_utils/test/src/trajectory/test_trajectory.cpp 38.08% <30.29%> (-3.59%) ⬇️
...ware_utils/geometry/path_with_lane_id_geometry.hpp 33.33% <33.33%> (ø)
...t/src/geometry/test_path_with_lane_id_geometry.cpp 48.48% <48.48%> (ø)
...include/tier4_autoware_utils/geometry/geometry.hpp 90.60% <77.77%> (-1.45%) ⬇️
...r4_autoware_utils/trajectory/path_with_lane_id.hpp 83.33% <83.33%> (ø)
...ude/tier4_autoware_utils/trajectory/trajectory.hpp 90.77% <83.75%> (-2.33%) ⬇️
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 138b159...567a39c. Read the comment docs.

target_pose.position = p_target;
target_pose.orientation = createQuaternionFromYaw(yaw);

auto p_insert = points.at(seg_idx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

velocity, acceleration, ... should be interpolated? What do you think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's better to interpolate velocity, acceleration, and others outside of this function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's better to interpolate velocity, acceleration, and others outside of this function

I think so too.

@satoshi-ota satoshi-ota force-pushed the feature/expand-tier4-autoware-utils branch from 1bd835a to c965453 Compare June 20, 2022 08:25
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
@satoshi-ota satoshi-ota force-pushed the feature/expand-tier4-autoware-utils branch from c965453 to 7f4f5ef Compare June 27, 2022 05:11
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
@satoshi-ota satoshi-ota merged commit 940f912 into autowarefoundation:main Jun 28, 2022
@satoshi-ota satoshi-ota deleted the feature/expand-tier4-autoware-utils branch June 28, 2022 22:06
boyali referenced this pull request in boyali/autoware.universe Sep 28, 2022
…nctions (tier4#990)

* feat(tier4_autoware_utils): expand geometry utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(tier4_autoware_utils): expand trajectory utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_path_planner): remove unused function

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix typo

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): use calcInterpolatedPoint

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): calcLongitudinalOffsetPose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): separate path_with_lane_id utils

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix interpolated point pose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix copyright

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_velocity_planner): fix include header file

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
boyali referenced this pull request in boyali/autoware.universe Oct 3, 2022
…nctions (tier4#990)

* feat(tier4_autoware_utils): expand geometry utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(tier4_autoware_utils): expand trajectory utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_path_planner): remove unused function

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix typo

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): use calcInterpolatedPoint

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): calcLongitudinalOffsetPose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): separate path_with_lane_id utils

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix interpolated point pose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix copyright

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_velocity_planner): fix include header file

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
boyali referenced this pull request in boyali/autoware.universe Oct 3, 2022
…nctions (tier4#990)

* feat(tier4_autoware_utils): expand geometry utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(tier4_autoware_utils): expand trajectory utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_path_planner): remove unused function

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix typo

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): use calcInterpolatedPoint

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): calcLongitudinalOffsetPose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): separate path_with_lane_id utils

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix interpolated point pose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix copyright

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_velocity_planner): fix include header file

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
boyali referenced this pull request in boyali/autoware.universe Oct 19, 2022
…nctions (tier4#990)

* feat(tier4_autoware_utils): expand geometry utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(tier4_autoware_utils): expand trajectory utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_path_planner): remove unused function

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix typo

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): use calcInterpolatedPoint

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): calcLongitudinalOffsetPose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): separate path_with_lane_id utils

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix interpolated point pose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix copyright

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_velocity_planner): fix include header file

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
yn-mrse referenced this pull request in tier4/autoware.universe Jun 20, 2023
…nctions (#990)

* feat(tier4_autoware_utils): expand geometry utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(tier4_autoware_utils): expand trajectory utility functions

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_path_planner): remove unused function

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix typo

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): use calcInterpolatedPoint

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): calcLongitudinalOffsetPose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): separate path_with_lane_id utils

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix interpolated point pose

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(tier4_autoware_utils): fix copyright

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* fix(behavior_velocity_planner): fix include header file

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
satoshi-ota pushed a commit to satoshi-ota/autoware.universe that referenced this pull request Nov 29, 2023
…add-iou_x-and-validation

feat(perception): add iou x and change the points_num of the validator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants