Skip to content

Commit

Permalink
adding support for rest of servers + review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Macenski <[email protected]>
  • Loading branch information
SteveMacenski committed Oct 4, 2024
1 parent 0ae7c08 commit 5e27266
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 38 deletions.
3 changes: 2 additions & 1 deletion nav2_behaviors/src/behavior_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ BehaviorServer::~BehaviorServer()
}

nav2_util::CallbackReturn
BehaviorServer::on_configure(const rclcpp_lifecycle::State & /*state*/)
BehaviorServer::on_configure(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Configuring");

Expand All @@ -91,6 +91,7 @@ BehaviorServer::on_configure(const rclcpp_lifecycle::State & /*state*/)

behavior_types_.resize(behavior_ids_.size());
if (!loadBehaviorPlugins()) {
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}
setupResourcesForBehaviorPlugins();
Expand Down
6 changes: 4 additions & 2 deletions nav2_bt_navigator/src/bt_navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ BtNavigator::~BtNavigator()
}

nav2_util::CallbackReturn
BtNavigator::on_configure(const rclcpp_lifecycle::State & /*state*/)
BtNavigator::on_configure(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Configuring");

Expand Down Expand Up @@ -133,6 +133,7 @@ BtNavigator::on_configure(const rclcpp_lifecycle::State & /*state*/)
RCLCPP_FATAL(
get_logger(), "Failed to create navigator id %s."
" Exception: %s", navigator_ids[i].c_str(), ex.what());
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}
}
Expand All @@ -141,11 +142,12 @@ BtNavigator::on_configure(const rclcpp_lifecycle::State & /*state*/)
}

nav2_util::CallbackReturn
BtNavigator::on_activate(const rclcpp_lifecycle::State & /*state*/)
BtNavigator::on_activate(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Activating");
for (size_t i = 0; i != navigators_.size(); i++) {
if (!navigators_[i]->on_activate()) {
on_deactivate(state);
return nav2_util::CallbackReturn::FAILURE;
}
}
Expand Down
3 changes: 2 additions & 1 deletion nav2_collision_monitor/src/collision_detector_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CollisionDetector::~CollisionDetector()
}

nav2_util::CallbackReturn
CollisionDetector::on_configure(const rclcpp_lifecycle::State & /*state*/)
CollisionDetector::on_configure(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Configuring");

Expand All @@ -60,6 +60,7 @@ CollisionDetector::on_configure(const rclcpp_lifecycle::State & /*state*/)

// Obtaining ROS parameters
if (!getParameters()) {
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}

Expand Down
4 changes: 3 additions & 1 deletion nav2_collision_monitor/src/collision_monitor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CollisionMonitor::~CollisionMonitor()
}

nav2_util::CallbackReturn
CollisionMonitor::on_configure(const rclcpp_lifecycle::State & /*state*/)
CollisionMonitor::on_configure(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Configuring");

Expand All @@ -60,6 +60,7 @@ CollisionMonitor::on_configure(const rclcpp_lifecycle::State & /*state*/)

// Obtaining ROS parameters
if (!getParameters(cmd_vel_in_topic, cmd_vel_out_topic, state_topic)) {
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}

Expand Down Expand Up @@ -90,6 +91,7 @@ CollisionMonitor::on_configure(const rclcpp_lifecycle::State & /*state*/)
nav2_util::setSoftRealTimePriority();
} catch (const std::runtime_error & e) {
RCLCPP_ERROR(get_logger(), "%s", e.what());
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}
}
Expand Down
12 changes: 2 additions & 10 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ ControllerServer::on_configure(const rclcpp_lifecycle::State & state)
true /*spin thread*/, server_options, use_realtime_priority_ /*soft realtime*/);
} catch (const std::runtime_error & e) {
RCLCPP_ERROR(get_logger(), "Error creating action server! %s", e.what());
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}

Expand All @@ -257,7 +258,7 @@ ControllerServer::on_configure(const rclcpp_lifecycle::State & state)
}

nav2_util::CallbackReturn
ControllerServer::on_activate(const rclcpp_lifecycle::State & state)
ControllerServer::on_activate(const rclcpp_lifecycle::State & /*state*/)
{
RCLCPP_INFO(get_logger(), "Activating");

Expand All @@ -268,15 +269,6 @@ ControllerServer::on_activate(const rclcpp_lifecycle::State & state)
ControllerMap::iterator it;
for (it = controllers_.begin(); it != controllers_.end(); ++it) {
it->second->activate();
try {
it->second->activate();
} catch (const std::exception & ex) {
RCLCPP_FATAL(
get_logger(), "Failed to activate controller. Exception: %s",
ex.what());
on_deactivate(state);
return nav2_util::CallbackReturn::FAILURE;
}
}
vel_publisher_->on_activate();
action_server_->activate();
Expand Down
3 changes: 2 additions & 1 deletion nav2_docking/opennav_docking/src/docking_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ DockingServer::DockingServer(const rclcpp::NodeOptions & options)
}

nav2_util::CallbackReturn
DockingServer::on_configure(const rclcpp_lifecycle::State & /*state*/)
DockingServer::on_configure(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Configuring %s", get_name());
auto node = shared_from_this();
Expand Down Expand Up @@ -90,6 +90,7 @@ DockingServer::on_configure(const rclcpp_lifecycle::State & /*state*/)
navigator_ = std::make_unique<Navigator>(node);
dock_db_ = std::make_unique<DockDatabase>(mutex_);
if (!dock_db_->initialize(node, tf2_buffer_)) {
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}

Expand Down
12 changes: 2 additions & 10 deletions nav2_planner/src/planner_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ PlannerServer::on_configure(const rclcpp_lifecycle::State & state)
}

nav2_util::CallbackReturn
PlannerServer::on_activate(const rclcpp_lifecycle::State & state)
PlannerServer::on_activate(const rclcpp_lifecycle::State & /*state*/)
{
RCLCPP_INFO(get_logger(), "Activating");

Expand All @@ -192,15 +192,7 @@ PlannerServer::on_activate(const rclcpp_lifecycle::State & state)

PlannerMap::iterator it;
for (it = planners_.begin(); it != planners_.end(); ++it) {
try {
it->second->activate();
} catch (const std::exception & ex) {
RCLCPP_FATAL(
get_logger(), "Failed to activate global planner. Exception: %s",
ex.what());
on_deactivate(state);
return nav2_util::CallbackReturn::FAILURE;
}
it->second->activate();
}

auto node = shared_from_this();
Expand Down
12 changes: 2 additions & 10 deletions nav2_smoother/src/nav2_smoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,14 @@ bool SmootherServer::loadSmootherPlugins()
}

nav2_util::CallbackReturn
SmootherServer::on_activate(const rclcpp_lifecycle::State & state)
SmootherServer::on_activate(const rclcpp_lifecycle::State & /*state*/)
{
RCLCPP_INFO(get_logger(), "Activating");

plan_publisher_->on_activate();
SmootherMap::iterator it;
for (it = smoothers_.begin(); it != smoothers_.end(); ++it) {
try {
it->second->activate();
} catch (const std::exception & ex) {
RCLCPP_FATAL(
get_logger(), "Failed to activate smoother. Exception: %s",
ex.what());
on_deactivate(state);
return nav2_util::CallbackReturn::FAILURE;
}
it->second->activate();
}
action_server_->activate();

Expand Down
3 changes: 2 additions & 1 deletion nav2_velocity_smoother/src/velocity_smoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ VelocitySmoother::~VelocitySmoother()
}

nav2_util::CallbackReturn
VelocitySmoother::on_configure(const rclcpp_lifecycle::State &)
VelocitySmoother::on_configure(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Configuring velocity smoother");
auto node = shared_from_this();
Expand Down Expand Up @@ -144,6 +144,7 @@ VelocitySmoother::on_configure(const rclcpp_lifecycle::State &)
nav2_util::setSoftRealTimePriority();
} catch (const std::runtime_error & e) {
RCLCPP_ERROR(get_logger(), "%s", e.what());
on_cleanup(state);
return nav2_util::CallbackReturn::FAILURE;
}
}
Expand Down
3 changes: 2 additions & 1 deletion nav2_waypoint_follower/src/waypoint_follower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ WaypointFollower::~WaypointFollower()
}

nav2_util::CallbackReturn
WaypointFollower::on_configure(const rclcpp_lifecycle::State & /*state*/)
WaypointFollower::on_configure(const rclcpp_lifecycle::State & state)
{
RCLCPP_INFO(get_logger(), "Configuring");

Expand Down Expand Up @@ -123,6 +123,7 @@ WaypointFollower::on_configure(const rclcpp_lifecycle::State & /*state*/)
RCLCPP_FATAL(
get_logger(),
"Failed to create waypoint_task_executor. Exception: %s", e.what());
on_cleanup(state);
}

return nav2_util::CallbackReturn::SUCCESS;
Expand Down

0 comments on commit 5e27266

Please sign in to comment.