Skip to content

Commit

Permalink
check nullptr in smoothPlan() (#4544)
Browse files Browse the repository at this point in the history
* check nullptr in smoothPlan()

Signed-off-by: GoesM <goesm@buaa.edu.cn>

* code-style

Signed-off-by: GoesM <goesm@buaa.edu.cn>

* code-style

Signed-off-by: GoesM <goesm@buaa.edu.cn>

* simple change

Signed-off-by: GoesM <goesm@buaa.edu.cn>

---------

Signed-off-by: GoesM <goesm@buaa.edu.cn>
Co-authored-by: GoesM <goesm@buaa.edu.cn>
  • Loading branch information
2 people authored and SteveMacenski committed Aug 23, 2024
1 parent 9b27712 commit 11cad89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nav2_smoother/src/nav2_smoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ void SmootherServer::smoothPlan()

auto result = std::make_shared<Action::Result>();
try {
std::string c_name = action_server_->get_current_goal()->smoother_id;
auto goal = action_server_->get_current_goal();
if (!goal) {
return; // if action_server_ is inactivate, goal would be a nullptr
}

std::string c_name = goal->smoother_id;
std::string current_smoother;
if (findSmootherId(c_name, current_smoother)) {
current_smoother_ = current_smoother;
Expand All @@ -270,7 +275,6 @@ void SmootherServer::smoothPlan()
}

// Perform smoothing
auto goal = action_server_->get_current_goal();
result->path = goal->path;
result->was_completed = smoothers_[current_smoother_]->smooth(
result->path, goal->max_smoothing_duration);
Expand Down

0 comments on commit 11cad89

Please sign in to comment.