Skip to content
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

check nullPtr in computeControl() #4548

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading