@@ -186,5 +186,32 @@ geometry_msgs::msg::Pose findTrajectoryPoseAfterDistance(
186
186
}
187
187
return p;
188
188
}
189
+
190
+ TrajectoryPoint getExtendedTrajectoryPoint (
191
+ const double extend_distance, const Trajectory & trajectory)
192
+ {
193
+ const auto extend_pose =
194
+ tier4_autoware_utils::calcOffsetPose (trajectory.points .back ().pose , extend_distance, 0.0 , 0.0 );
195
+
196
+
197
+ // To avoid 0 slope, extend the point with the same slope as the last two points
198
+ const double z_change_ratio =
199
+ (trajectory.points .at (trajectory.points .size () - 2 ).pose .position .z -
200
+ trajectory.points .back ().pose .position .z ) /
201
+ tier4_autoware_utils::calcDistance3d (
202
+ trajectory.points .at (trajectory.points .size () - 2 ).pose .position ,
203
+ trajectory.points .back ().pose .position );
204
+ TrajectoryPoint extend_trajectory_point;
205
+ extend_trajectory_point.pose = extend_pose;
206
+
207
+ extend_trajectory_point.pose .position .z =
208
+ trajectory.points .back ().pose .position .z - extend_distance * z_change_ratio;
209
+ extend_trajectory_point.longitudinal_velocity_mps =
210
+ trajectory.points .back ().longitudinal_velocity_mps ;
211
+ extend_trajectory_point.lateral_velocity_mps = trajectory.points .back ().lateral_velocity_mps ;
212
+ extend_trajectory_point.acceleration_mps2 = trajectory.points .back ().acceleration_mps2 ;
213
+ return extend_trajectory_point;
214
+ }
215
+
189
216
} // namespace longitudinal_utils
190
217
} // namespace autoware::motion::control::pid_longitudinal_controller
0 commit comments