From b98ca87365d93a933acd1cb5a3a2fbfd330b6214 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:17:31 +0100 Subject: [PATCH] Fix Pilz blending times (backport #2961) (#3001) Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> --- .../src/plan_components_builder.cpp | 13 +++++++++---- .../src/trajectory_blender_transition_window.cpp | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/moveit_planners/pilz_industrial_motion_planner/src/plan_components_builder.cpp b/moveit_planners/pilz_industrial_motion_planner/src/plan_components_builder.cpp index 39c9d1e06c..0513d22b49 100644 --- a/moveit_planners/pilz_industrial_motion_planner/src/plan_components_builder.cpp +++ b/moveit_planners/pilz_industrial_motion_planner/src/plan_components_builder.cpp @@ -54,13 +54,17 @@ std::vector PlanComponentsBuilder::build() void PlanComponentsBuilder::appendWithStrictTimeIncrease(robot_trajectory::RobotTrajectory& result, const robot_trajectory::RobotTrajectory& source) { - if (result.empty() || - !pilz_industrial_motion_planner::isRobotStateEqual(result.getLastWayPoint(), source.getFirstWayPoint(), - result.getGroupName(), ROBOT_STATE_EQUALITY_EPSILON)) + if (result.empty()) { result.append(source, 0.0); return; } + if (!pilz_industrial_motion_planner::isRobotStateEqual(result.getLastWayPoint(), source.getFirstWayPoint(), + result.getGroupName(), ROBOT_STATE_EQUALITY_EPSILON)) + { + result.append(source, source.getWayPointDurationFromStart(0)); + return; + } for (size_t i = 1; i < source.getWayPointCount(); ++i) { @@ -94,7 +98,8 @@ void PlanComponentsBuilder::blend(const planning_scene::PlanningSceneConstPtr& p // Append the new trajectory elements appendWithStrictTimeIncrease(*(traj_cont_.back()), *blend_response.first_trajectory); - traj_cont_.back()->append(*blend_response.blend_trajectory, 0.0); + appendWithStrictTimeIncrease(*(traj_cont_.back()), *blend_response.blend_trajectory); + // Store the last new trajectory element for future processing traj_tail_ = blend_response.second_trajectory; // first for next blending segment } diff --git a/moveit_planners/pilz_industrial_motion_planner/src/trajectory_blender_transition_window.cpp b/moveit_planners/pilz_industrial_motion_planner/src/trajectory_blender_transition_window.cpp index 920c43530a..0fa35a84ef 100644 --- a/moveit_planners/pilz_industrial_motion_planner/src/trajectory_blender_transition_window.cpp +++ b/moveit_planners/pilz_industrial_motion_planner/src/trajectory_blender_transition_window.cpp @@ -67,7 +67,7 @@ bool pilz_industrial_motion_planner::TrajectoryBlenderTransitionWindow::blend( std::size_t second_intersection_index; if (!searchIntersectionPoints(req, first_intersection_index, second_intersection_index)) { - RCLCPP_ERROR(LOGGER, "Blend radius to large."); + RCLCPP_ERROR(LOGGER, "Blend radius too large."); res.error_code.val = moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN; return false; } @@ -124,6 +124,7 @@ bool pilz_industrial_motion_planner::TrajectoryBlenderTransitionWindow::blend( // append the blend trajectory res.blend_trajectory->setRobotTrajectoryMsg(req.first_trajectory->getFirstWayPoint(), blend_joint_trajectory); + // copy the points [second_intersection_index, len] from the second trajectory for (size_t i = second_intersection_index + 1; i < req.second_trajectory->getWayPointCount(); ++i) {