Skip to content

Commit eb933e5

Browse files
committed
fix: removes last trajectory segment with different sampling time.
this ensures that the new sample time will be lowered, thus not violating precomputed distance interpolation constraints at the same time avoids the issue on the last point generating small displacement interpolation
1 parent 3511d7c commit eb933e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

moveit_planners/pilz_industrial_motion_planner/src/trajectory_functions.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,12 @@ bool pilz_industrial_motion_planner::generateJointTrajectory(
217217
rclcpp::Time generation_begin = clock.now();
218218

219219
// generate the time samples
220-
const double epsilon = 10e-06; // avoid adding the last time sample twice
221220
std::vector<double> time_samples;
222-
for (double t_sample = 0.0; t_sample < trajectory.Duration() - epsilon; t_sample += sampling_time)
221+
int num_samples = std::floor(trajectory.Duration() / sampling_time);
222+
sampling_time = trajectory.Duration() / num_samples;
223+
for (int i = 0; i < num_samples; ++i)
223224
{
224-
time_samples.push_back(t_sample);
225+
time_samples.push_back(i * sampling_time);
225226
}
226227
time_samples.push_back(trajectory.Duration());
227228

0 commit comments

Comments
 (0)