Skip to content

Commit

Permalink
Fix plan fetching printout and don't recache fetched plans
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed Sep 27, 2023
1 parent b3b5656 commit f6efd10
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions nexus_motion_planner/src/motion_planner_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ void MotionPlannerServer::plan_with_move_group(
else
{
MoveGroupInterface::Plan plan;
bool fetched_plan;
interface->constructMotionPlanRequest(plan_req_msg);

if (!_only_use_cached_plans)
Expand All @@ -648,7 +649,7 @@ void MotionPlannerServer::plan_with_move_group(
else
{
auto fetch_start = this->now();
auto fetched_plan = _motion_plan_cache->fetch_best_matching_plan(
fetched_plan = _motion_plan_cache->fetch_best_matching_plan(
*interface, robot_name, plan_req_msg,
_cache_start_match_tolerance, _cache_goal_match_tolerance);
auto fetch_end = this->now();
Expand All @@ -661,8 +662,8 @@ void MotionPlannerServer::plan_with_move_group(
moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
RCLCPP_INFO(
this->get_logger(),
"Cache fetch took %es, fetched plan planning time was: %es",
(fetch_end - fetch_start).seconds(), plan.planning_time);
"Cache fetch took %es, fetched plan's planning time was: %es",
(fetch_end - fetch_start).seconds(), fetched_plan.planning_time);
}
else
{
Expand Down Expand Up @@ -690,7 +691,9 @@ void MotionPlannerServer::plan_with_move_group(
return;
}

if (_use_motion_plan_cache)
// Make sure we check if the plan we have was fetched (so we don't have
// duplicate caches.)
if (_use_motion_plan_cache && !fetched_plan)
{
if (!_motion_plan_cache->put_plan(
*interface, robot_name,
Expand Down

0 comments on commit f6efd10

Please sign in to comment.