Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Off by one in getAverageSegmentDuration #1079

Merged
merged 8 commits into from
Mar 14, 2022
2 changes: 1 addition & 1 deletion moveit_core/robot_trajectory/src/robot_trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ double RobotTrajectory::getAverageSegmentDuration() const
if (duration_from_previous_.empty())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (duration_from_previous_.empty())
if (duration_from_previous_.empty() || (duration_from_previous_.size() == 1 && !has_initial_segment))

return 0.0;
else
return getDuration() / static_cast<double>(duration_from_previous_.size());
return getDuration() / static_cast<double>(duration_from_previous_.size() - 1);
}

void RobotTrajectory::swap(RobotTrajectory& other)
Expand Down