diff --git a/moveit_core/trajectory_processing/src/trajectory_tools.cpp b/moveit_core/trajectory_processing/src/trajectory_tools.cpp index d260a06438..cca3586187 100644 --- a/moveit_core/trajectory_processing/src/trajectory_tools.cpp +++ b/moveit_core/trajectory_processing/src/trajectory_tools.cpp @@ -87,9 +87,9 @@ trajectory_msgs::msg::JointTrajectory createTrajectoryMessage(const std::vector< } trajectory_msg.joint_names = joint_names; const double time_step = 1.0 / static_cast(sampling_rate); - const int n_samples = static_cast(trajectory.getDuration() / time_step) + 1; + const int n_samples = static_cast(std::ceil(trajectory.getDuration() / time_step)) + 1; trajectory_msg.points.reserve(n_samples); - for (int sample = 0; sample <= n_samples; ++sample) + for (int sample = 0; sample < n_samples; ++sample) { const double t = sample * time_step; trajectory_msgs::msg::JointTrajectoryPoint point;