Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
fix(motion_velocity_smoother): use common ego nearest search (autowar…
Browse files Browse the repository at this point in the history
…efoundation#1584)

* fix(motion_velocity_smoother): use common ego nearest search

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

* fix

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

* fix build error and modify launch

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

* fix

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
  • Loading branch information
takayuki5168 authored Aug 31, 2022
1 parent 5c64f8a commit f1a8851
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ inline bool smoothPath(

// Resample trajectory with ego-velocity based interval distances
auto traj_resampled = smoother->resampleTrajectory(
*traj_lateral_acc_filtered, v0, current_pose, std::numeric_limits<double>::max());
*traj_lateral_acc_filtered, v0, current_pose, planner_data->ego_nearest_dist_threshold,
planner_data->ego_nearest_yaw_threshold);
const size_t traj_resampled_closest = motion_utils::findFirstNearestIndexWithSoftConstraints(
*traj_resampled, current_pose, planner_data->ego_nearest_dist_threshold,
planner_data->ego_nearest_yaw_threshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class MotionVelocitySmootherNode : public rclcpp::Node
double extract_ahead_dist; // forward waypoints distance from current position [m]
double extract_behind_dist; // backward waypoints distance from current position [m]
double stop_dist_to_prohibit_engage; // prevent to move toward close stop point
double delta_yaw_threshold; // for closest index calculation
double ego_nearest_dist_threshold; // for ego's closest index calculation
double ego_nearest_yaw_threshold; // for ego's closest index calculation

resampling::ResampleParam post_resample_param;
AlgorithmType algorithm_type; // Option : JerkFiltered, Linf, L2
} node_param_{};
Expand Down Expand Up @@ -225,9 +227,7 @@ class MotionVelocitySmootherNode : public rclcpp::Node
rclcpp::Publisher<Float32Stamped>::SharedPtr pub_closest_merged_velocity_;

// helper functions
boost::optional<size_t> findNearestIndex(
const TrajectoryPoints & points, const geometry_msgs::msg::Pose & p) const;
boost::optional<size_t> findNearestIndexFromEgo(const TrajectoryPoints & points) const;
size_t findNearestIndexFromEgo(const TrajectoryPoints & points) const;
bool isReverse(const TrajectoryPoints & points) const;
void flipVelocity(TrajectoryPoints & points) const;
void publishStopWatchTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ struct ResampleParam

boost::optional<TrajectoryPoints> resampleTrajectory(
const TrajectoryPoints & input, const double v_current,
const geometry_msgs::msg::Pose & current_pose, const double delta_yaw_threshold,
const ResampleParam & param, const bool use_zoh_for_v = true);
const geometry_msgs::msg::Pose & current_pose, const double nearest_dist_threshold,
const double nearest_yaw_threshold, const ResampleParam & param, const bool use_zoh_for_v = true);

boost::optional<TrajectoryPoints> resampleTrajectory(
const TrajectoryPoints & input, const geometry_msgs::msg::Pose & current_pose,
const double delta_yaw_threshold, const ResampleParam & param, const double nominal_ds,
const bool use_zoh_for_v = true);
const double nearest_dist_threshold, const double nearest_yaw_threshold,
const ResampleParam & param, const double nominal_ds, const bool use_zoh_for_v = true);
} // namespace resampling
} // namespace motion_velocity_smoother

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class AnalyticalJerkConstrainedSmoother : public SmootherBase
boost::optional<TrajectoryPoints> resampleTrajectory(
const TrajectoryPoints & input, [[maybe_unused]] const double v0,
[[maybe_unused]] const geometry_msgs::msg::Pose & current_pose,
[[maybe_unused]] const double delta_yaw_threshold) const override;
[[maybe_unused]] const double nearest_dist_threshold,
[[maybe_unused]] const double nearest_yaw_threshold) const override;

boost::optional<TrajectoryPoints> applyLateralAccelerationFilter(
const TrajectoryPoints & input, [[maybe_unused]] const double v0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class JerkFilteredSmoother : public SmootherBase

boost::optional<TrajectoryPoints> resampleTrajectory(
const TrajectoryPoints & input, [[maybe_unused]] const double v0,
const geometry_msgs::msg::Pose & current_pose, const double delta_yaw_threshold) const override;
const geometry_msgs::msg::Pose & current_pose, const double nearest_dist_threshold,
const double nearest_yaw_threshold) const override;

void setParam(const Param & param);
Param getParam() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class L2PseudoJerkSmoother : public SmootherBase

boost::optional<TrajectoryPoints> resampleTrajectory(
const TrajectoryPoints & input, const double v0, const geometry_msgs::msg::Pose & current_pose,
const double delta_yaw_threshold) const override;
const double nearest_dist_threshold, const double nearest_yaw_threshold) const override;

void setParam(const Param & smoother_param);
Param getParam() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LinfPseudoJerkSmoother : public SmootherBase

boost::optional<TrajectoryPoints> resampleTrajectory(
const TrajectoryPoints & input, const double v0, const geometry_msgs::msg::Pose & current_pose,
const double delta_yaw_threshold) const override;
const double nearest_dist_threshold, const double nearest_yaw_threshold) const override;

void setParam(const Param & smoother_param);
Param getParam() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SmootherBase

virtual boost::optional<TrajectoryPoints> resampleTrajectory(
const TrajectoryPoints & input, const double v0, const geometry_msgs::msg::Pose & current_pose,
const double delta_yaw_threshold) const = 0;
const double nearest_dist_threshold, const double nearest_yaw_threshold) const = 0;

virtual boost::optional<TrajectoryPoints> applyLateralAccelerationFilter(
const TrajectoryPoints & input, [[maybe_unused]] const double v0 = 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using TrajectoryPoints = std::vector<TrajectoryPoint>;
using geometry_msgs::msg::Pose;

TrajectoryPoint calcInterpolatedTrajectoryPoint(
const TrajectoryPoints & trajectory, const Pose & target_pose);
const TrajectoryPoints & trajectory, const Pose & target_pose, const size_t seg_idx);

TrajectoryPoints extractPathAroundIndex(
const TrajectoryPoints & trajectory, const size_t index, const double & ahead_length,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<launch>
<!-- common param -->
<arg name="common_param_path" default="$(find-pkg-share motion_velocity_smoother)/config/default_common.param.yaml"/>
<arg name="nearest_search_param_path"/>

<!-- input/output -->
<arg name="input_trajectory" default="/planning/scenario_planning/scenario_selector/trajectory"/>
Expand All @@ -16,6 +17,7 @@

<node pkg="motion_velocity_smoother" exec="motion_velocity_smoother" name="motion_velocity_smoother" output="screen">
<param from="$(var common_param_path)"/>
<param from="$(var nearest_search_param_path)"/>
<param from="$(var param_path)"/>
<param from="$(var smoother_param_path)"/>
<param name="publish_debug_trajs" value="$(var publish_debug_trajs)"/>
Expand Down
Loading

0 comments on commit f1a8851

Please sign in to comment.