Skip to content

Commit

Permalink
check nullPtr in computeControl()
Browse files Browse the repository at this point in the history
Signed-off-by: goes <[email protected]>
  • Loading branch information
goes authored and goes committed Jul 21, 2024
1 parent a7c5b71 commit e70920d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,31 +424,36 @@ void ControllerServer::computeControl()
RCLCPP_INFO(get_logger(), "Received a goal, begin computing control effort.");

try {
std::string c_name = action_server_->get_current_goal()->controller_id;
auto goal = action_server_->get_current_goal();
if (!goal) {
return; // goal would be nullptr if action_server_ is inactivate.
}

std::string c_name = goal->controller_id;
std::string current_controller;
if (findControllerId(c_name, current_controller)) {
current_controller_ = current_controller;
} else {
throw nav2_core::InvalidController("Failed to find controller name: " + c_name);
}

std::string gc_name = action_server_->get_current_goal()->goal_checker_id;
std::string gc_name = goal->goal_checker_id;
std::string current_goal_checker;
if (findGoalCheckerId(gc_name, current_goal_checker)) {
current_goal_checker_ = current_goal_checker;
} else {
throw nav2_core::ControllerException("Failed to find goal checker name: " + gc_name);
}

std::string pc_name = action_server_->get_current_goal()->progress_checker_id;
std::string pc_name = goal->progress_checker_id;
std::string current_progress_checker;
if (findProgressCheckerId(pc_name, current_progress_checker)) {
current_progress_checker_ = current_progress_checker;
} else {
throw nav2_core::ControllerException("Failed to find progress checker name: " + pc_name);
}

setPlannerPath(action_server_->get_current_goal()->path);
setPlannerPath(goal->path);
progress_checkers_[current_progress_checker_]->reset();

last_valid_cmd_time_ = now();
Expand Down

0 comments on commit e70920d

Please sign in to comment.