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

Fix Cartesian interpolation #3020

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions moveit_core/robot_state/src/cartesian_interpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,22 @@ CartesianInterpolator::Percentage CartesianInterpolator::computeCartesianPath(
double wp_percentage_solved =
computeCartesianPath(start_state, group, waypoint_traj, link, waypoints[i], global_reference_frame, max_step,
precision, validCallback, options, cost_function, link_offset);

std::vector<RobotStatePtr>::iterator start = waypoint_traj.begin();
if (i > 0 && !waypoint_traj.empty())
std::advance(start, 1);
traj.insert(traj.end(), start, waypoint_traj.end());

if (fabs(wp_percentage_solved - 1.0) < std::numeric_limits<double>::epsilon())
{
percentage_solved = static_cast<double>(i + 1) / static_cast<double>(waypoints.size());
std::vector<RobotStatePtr>::iterator start = waypoint_traj.begin();
if (i > 0 && !waypoint_traj.empty())
std::advance(start, 1);
traj.insert(traj.end(), start, waypoint_traj.end());
}
else
{
percentage_solved += wp_percentage_solved / static_cast<double>(waypoints.size());
std::vector<RobotStatePtr>::iterator start = waypoint_traj.begin();
if (i > 0 && !waypoint_traj.empty())
std::advance(start, 1);
traj.insert(traj.end(), start, waypoint_traj.end());
break;
}
start_state = traj.back().get();
}

return percentage_solved;
Expand Down Expand Up @@ -490,21 +489,19 @@ CartesianInterpolator::Percentage CartesianInterpolator::computeCartesianPath(
computeCartesianPath(start_state, group, waypoint_path, link, waypoints[i], global_reference_frame, max_step,
NO_JOINT_SPACE_JUMP_TEST, validCallback, options, cost_function, link_offset);
#pragma GCC diagnostic pop

std::vector<RobotStatePtr>::iterator start = waypoint_path.begin();
if (i > 0 && !waypoint_path.empty())
std::advance(start, 1);
path.insert(path.end(), start, waypoint_path.end());

if (fabs(wp_percentage_solved - 1.0) < std::numeric_limits<double>::epsilon())
{
percentage_solved = static_cast<double>((i + 1)) / static_cast<double>(waypoints.size());
std::vector<RobotStatePtr>::iterator start = waypoint_path.begin();
if (i > 0 && !waypoint_path.empty())
std::advance(start, 1);
path.insert(path.end(), start, waypoint_path.end());
}
else
{
percentage_solved += wp_percentage_solved / static_cast<double>(waypoints.size());
std::vector<RobotStatePtr>::iterator start = waypoint_path.begin();
if (i > 0 && !waypoint_path.empty())
std::advance(start, 1);
path.insert(path.end(), start, waypoint_path.end());
break;
}
}
Expand Down
Loading