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

Mitigate Ruckig overshoot #3376

Merged
merged 2 commits into from
Mar 24, 2023

Conversation

AndyZe
Copy link
Member

@AndyZe AndyZe commented Mar 17, 2023

Description

When smoothing a trajectory, sometimes it's not possible to avoid overshoot. An example is:

current state is (position = 0, velocity = 0), target state is (position = 1, velocity = -1)

However, the overshoot can be reduced by extending the segment duration, thereby reducing the velocity at the goal state. Here's a graphical explanation.

ruckig_duration_extension

@AndyZe AndyZe requested a review from mlautman as a code owner March 17, 2023 14:57
@AndyZe AndyZe changed the title One-liner example that doesn't compile Mitigate Ruckig overshoot Mar 17, 2023
@AndyZe AndyZe changed the title Mitigate Ruckig overshoot [WIP] Mitigate Ruckig overshoot Mar 17, 2023
@AndyZe AndyZe force-pushed the andyz/ruckig_overshoot_mitigation branch 3 times, most recently from fc3664a to b85dce2 Compare March 17, 2023 16:50
@AndyZe AndyZe changed the title [WIP] Mitigate Ruckig overshoot Mitigate Ruckig overshoot Mar 17, 2023
@moveit moveit deleted a comment from codecov bot Mar 17, 2023
{
duration_extension_factor *= DURATION_EXTENSION_FRACTION;
// Reset the trajectory
trajectory = robot_trajectory::RobotTrajectory(original_trajectory, true /* deep copy */);

const std::vector<int>& move_group_idx = group->getVariableIndexList();
extendTrajectoryDuration(duration_extension_factor, num_waypoints, num_dof, move_group_idx, trajectory,
original_trajectory);
extendTrajectoryDuration(duration_extension_factor, num_waypoints, num_dof, move_group_idx, original_trajectory,
Copy link
Member Author

Choose a reason for hiding this comment

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

This was a bug!

// re-calculate waypoint velocity and acceleration
auto target_state = trajectory.getWayPointPtr(time_stretch_idx);
const auto prev_state = trajectory.getWayPointPtr(time_stretch_idx - 1);
double timestep = trajectory.getAverageSegmentDuration();
Copy link
Member Author

Choose a reason for hiding this comment

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

Another bug

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Patch coverage: 28.58% and no project coverage change.

Comparison is base (9ee989d) 61.74% compared to head (eec82f7) 61.73%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3376      +/-   ##
==========================================
- Coverage   61.74%   61.73%   -0.00%     
==========================================
  Files         380      380              
  Lines       33595    33599       +4     
==========================================
  Hits        20740    20740              
- Misses      12855    12859       +4     
Impacted Files Coverage Δ
...rajectory_processing/src/ruckig_traj_smoothing.cpp 60.63% <28.58%> (-3.46%) ⬇️

... and 8 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@AndyZe AndyZe force-pushed the andyz/ruckig_overshoot_mitigation branch from 7af85af to 6f04a58 Compare March 17, 2023 20:04
@rhaschke
Copy link
Contributor

I don't get your initial example: Halving the velocity at the target state isn't what you want, do you? The target state velocity is an input parameter, isn't it?
The core goal of ruckig is to provide time-optimal trajectories considering velocity, acceleration, and jerk limits. Why would you want to extend the trajectory duration?

@AndyZe
Copy link
Member Author

AndyZe commented Mar 18, 2023

Good question! Some people want the time-optimal solution which passes through the given waypoints. Others want to limit jerk while avoiding overshoot. An example of a few groups I've worked with who want to avoid overshoot are:

  • A window-washing robot
  • Optics grinding

So that's why I intended to make the overshoot mitigation optional.

const double overshoot_threshold)
{
// For every timestep
for (double time_from_start = 0; time_from_start < ruckig_trajectory.get_duration();
Copy link
Member

Choose a reason for hiding this comment

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

Is there a feasible way to not start from 0 every time?

Copy link
Member Author

Choose a reason for hiding this comment

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

MoveIt2 has that feature already :) I guess I can backport it to MoveIt1

moveit/moveit2#1990

@AndyZe AndyZe force-pushed the andyz/ruckig_overshoot_mitigation branch from a93a53b to 9cf61c8 Compare March 23, 2023 20:55
@AndyZe AndyZe force-pushed the andyz/ruckig_overshoot_mitigation branch from 9cf61c8 to eec82f7 Compare March 23, 2023 21:07
@AndyZe AndyZe merged commit 2dd9091 into moveit:master Mar 24, 2023
@AndyZe AndyZe deleted the andyz/ruckig_overshoot_mitigation branch March 24, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants