Repository navigation
Description
Description
See the code at
moveit2/moveit_core/robot_trajectory/src/robot_trajectory.cpp
Lines 509 to 542 in ca2bb1b
| void RobotTrajectory::findWayPointIndicesForDurationAfterStart(double duration, int& before, int& after, | |
| double& blend) const | |
| { | |
| if (duration < 0.0) | |
| { | |
| before = 0; | |
| after = 0; | |
| blend = 0; | |
| return; | |
| } | |
| // Find indices | |
| std::size_t index = 0, num_points = waypoints_.size(); | |
| double running_duration = 0.0; | |
| for (; index < num_points; ++index) | |
| { | |
| running_duration += duration_from_previous_[index]; | |
| if (running_duration >= duration) | |
| break; | |
| } | |
| before = std::max<int>(index - 1, 0); | |
| after = std::min<int>(index, num_points - 1); | |
| // Compute duration blend | |
| double before_time = running_duration - duration_from_previous_[index]; | |
| if (after == before) | |
| { | |
| blend = 1.0; | |
| } | |
| else | |
| { | |
| blend = (duration - before_time) / duration_from_previous_[index]; | |
| } | |
| } |
If the duration is bigger than the duration of the trajectory, the index will be index==num_points making this line double before_time = running_duration - duration_from_previous_[index]; invalid and also output a double blend not in the [0, 1] inclusive according to
moveit2/moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.hpp
Line 312 in ca2bb1b
| * @param The progress (0 to 1) between the two waypoints, based on time (not based on joint distances). |
ROS Distro
Rolling
OS and version
Ubuntu 24.04
Source or binary build?
Source
If binary, which release version?
No response
If source, which branch?
main, jazzy, humble
Which RMW are you using?
None
Steps to Reproduce
Just give a duration bigger than the trajectory duration to the findWayPointIndicesForDurationAfterStart().
Expected behavior
It should be [0, 1] and no error.
Actual behavior
Error and also blend is not in [0, 1]`
Backtrace or Console output
No response
Activity
XingxinHE commentedon Nov 18, 2025
I propose the following fix and I am happy to open a PR to support OSS.
nbbrooks commentedon Nov 26, 2025
I agree - I think a shorter adjustment is to just move the
double before_time = running_duration - duration_from_previous_[index];to inside the else statement (the only place where it is used anyway).Could you make the PR and ideally add a unit test to https://github.com/moveit/moveit2/blob/main/moveit_core/robot_trajectory/test/test_robot_trajectory.cpp ?
XingxinHE commentedon Nov 27, 2025
Oh. Good one. Will do the PR with a unit test!
nbbrooks commentedon Sep 22, 2026
Closed by #3626