-
Notifications
You must be signed in to change notification settings - Fork 531
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
Make planning pipeline respect the allowed_planning_time #2692
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thank you!
Regarding your comments:
Modified allowed_planning_time directly to change the timeout of each planner
That's fine 👍
Currently the timeout for each planner is naively evenly distributed as discussed in the issue.
👍 Sounds good for now
Haven't thoroughly tested the modification. I wonder if is there an easy way to do this. I saw a tutorial here but it seems outdated.
You could extend the existing unit tests
moveit_ros/planning/planning_pipeline/src/planning_pipeline.cpp
Outdated
Show resolved
Hide resolved
@@ -288,11 +295,24 @@ bool PlanningPipeline::generatePlan(const planning_scene::PlanningSceneConstPtr& | |||
req_adapter->getDescription().c_str(), status.message.c_str()); | |||
break; | |||
} | |||
|
|||
// check for timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a note here that it is assumed that the request adapters only consume a very small fraction of the allowed planning time and thus they don't get a budget assigned. The timeout check is mainly a sanity check
|
||
// TODO: should this be optional since the plugins already checked for timeout? | ||
// check for timeout | ||
if (std::chrono::duration<double>(clock::now() - planner_start_time).count() >= max_single_planner_time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I would even make sense to use the same check here as for the adapters
if (std::chrono::duration<double>(clock::now() - plan_start_time).count() >= allowed_planning_time)
I think we might not care too much about the individual elements exceeding their allocated individual budget (for now) but for the overall planning process to not exceed the allowed_planning_time
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Especially because some planners will take longer, so splitting the timeout evenly seems risky.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2692 +/- ##
==========================================
- Coverage 50.74% 43.03% -7.71%
==========================================
Files 392 692 +300
Lines 32553 56351 +23798
Branches 0 7277 +7277
==========================================
+ Hits 16517 24247 +7730
- Misses 16036 31941 +15905
- Partials 0 163 +163 ☔ View full report in Codecov by Sentry. |
Thanks for the review! Based on your feedback I would propose that we don't enforce and check for timeout after each step but only modify the corresponding remaining time to guide the planners and adapters to follow the time limit. We can do a single check after response adapters finished and modify the error code accordingly. In this way even if the timeout is reached the function will also finish so that users can still get the planning result. Does that sound good? |
The check in every iteration makes sense to me, so I wouldn't change that. If the first out of ten pipeline elements uses the full time budget, there is no point in running the other elements before reporting the error. I think we should always check if the full time budget is exhausted but we don't care so much if a planner uses the allocated fraction of the budget or a bit more as long as the overall planning time remains within the budget |
@sjahr sorry for the late update. I revised my implementation based on your feedback. Here's the update:
I think if you are good with the current time distribution strategy this pull request is ready for review and merge! |
std::string message = status.message; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string message = status.message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I reviewed your changes
moveit_ros/planning/planning_pipeline/src/planning_pipeline.cpp
Outdated
Show resolved
Hide resolved
const auto& planner = planner_map_.at(planner_name); | ||
// modify planner request to notice plugins of their corresponding max_allowed_time | ||
// NOTE: currently just evenly distributing the remaining time among the remaining planners | ||
double max_single_planner_time = std::chrono::duration<double>(clock::now() - plan_start_time).count() / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this time calculation. Can you explain it? Why are we giving the planner the time since the planning started as time budget? Maybe I am missing something. Also can you make this const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry made a mistake, I changed it to
mutable_request.allowed_planning_time =
(allowed_planning_time - std::chrono::duration<double>(clock::now() - plan_start_time).count()) /
(pipeline_parameters_.planning_plugins.size() - i);
moveit_ros/planning/planning_pipeline/src/planning_pipeline.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/planning/planning_pipeline/src/planning_pipeline.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/planning/planning_pipeline/test/planning_pipeline_test_plugins.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/planning/planning_pipeline/test/planning_pipeline_tests.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/planning/planning_pipeline/test/planning_pipeline_tests.cpp
Outdated
Show resolved
Hide resolved
@@ -119,7 +119,7 @@ TEST_F(TestPlanningPipeline, NoPlannerPluginConfigured) | |||
|
|||
TEST_F(TestPlanningPipeline, TestTimeout) | |||
{ | |||
// construct pipline | |||
// construct pipeline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know that checker also checks for spelling lol
hi @sjahr, just checking in, is there anything else I need to do on this PR? |
@@ -335,6 +363,13 @@ bool PlanningPipeline::generatePlan(const planning_scene::PlanningSceneConstPtr& | |||
RCLCPP_INFO(node_->get_logger(), "Calling PlanningResponseAdapter '%s'", res_adapter->getDescription().c_str()); | |||
res_adapter->adapt(planning_scene, mutable_request, res); | |||
publishPipelineState(mutable_request, res, res_adapter->getDescription()); | |||
|
|||
// check for timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing it, but it looks like we will hit a timeout here if the planners use up the allowed planning time. Optimizing planners usually do that, so I think we should either ignore response adapters or use a separate budget
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think the ultimate solution to this is to give user more control over the timeout. Maybe let them decide timeout of each section (and each planner) separately? But that would require changing the MotionPlanRequest
message so I'm not sure. What's your suggestion on this? Should we make the PR more complex or just ignore the response adapters for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we ensure for now that a fraction of the time will be reserved for the planners? Something like 100ms in any case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in that case the planner might still use up all the reserved time. Or are you saying that giving the request adapter at least 100ms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the response adapter should have a reserved time budget which is deducted from the planner's allowed planning time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, I add an extra check to ensure that the response adapter has 10ms left in the latest commit
@TomCC7, I apologize for the delay, we've been pretty absorbed with bugfixes for multi-arm and mobile manipulator configurations lately. @sjahr @henningkayser is there anything else we need changed on this PR before we give it a last round of testing and merge it? |
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
Description
@sjahr WIP PR to solve #2581. Several notes:
allowed_planning_time
directly to change the timeout of each plannerChecklist