Skip to content

Commit

Permalink
Refactor to avoid calling .at(0) twice
Browse files Browse the repository at this point in the history
  • Loading branch information
sjahr committed Apr 20, 2023
1 parent 4238dc3 commit d095f7f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/src/solvers/pipeline_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,13 @@ bool PipelinePlanner::plan(const planning_scene::PlanningSceneConstPtr& planning
requests, planning_scene, planning_pipelines_, stopping_criterion_callback_, solution_selection_function_);

// If solutions exist and the first one is successful
if (!responses.empty() && responses.at(0)) {
// Choose the first solution trajectory as response
result = responses.at(0).trajectory;
return bool(result);
if (!responses.empty()) {
auto const solution = responses.at(0);
if (solution) {
// Choose the first solution trajectory as response
result = solution.trajectory;
return bool(result);
}
}
return false;
}
Expand Down

0 comments on commit d095f7f

Please sign in to comment.