Skip to content

Commit

Permalink
PipelinePlanner: Truncate trajectory to valid part
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Mar 12, 2024
1 parent e7f8a82 commit ebed17f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ class RobotTrajectory
RobotTrajectory& append(const RobotTrajectory& source, double dt, size_t start_index = 0,
size_t end_index = std::numeric_limits<std::size_t>::max());

/** Truncate trajectory to given size */
void truncate(size_t size);

void swap(robot_trajectory::RobotTrajectory& other);

RobotTrajectory& clear()
Expand Down
7 changes: 7 additions & 0 deletions moveit_core/robot_trajectory/src/robot_trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ RobotTrajectory& RobotTrajectory::append(const RobotTrajectory& source, double d
return *this;
}

void RobotTrajectory::truncate(size_t size)
{
size = std::min(size, waypoints_.size());
waypoints_.resize(size);
duration_from_previous_.resize(size);
}

RobotTrajectory& RobotTrajectory::reverse()
{
std::reverse(waypoints_.begin(), waypoints_.end());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ bool planning_pipeline::PlanningPipeline::generatePlan(const planning_scene::Pla
}
}
ROS_ERROR_STREAM("Completed listing of explanations for invalid states.");
res.trajectory_->truncate(index[0]); // truncate returned trajectory to valid part
}
}
else
Expand Down

0 comments on commit ebed17f

Please sign in to comment.