Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
toggle_collision_monitor_service.hpp
1 // Copyright (c) 2025 David Grbac
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <string>
18 
19 #include "nav2_behavior_tree/bt_service_node.hpp"
20 #include "nav2_msgs/srv/toggle.hpp"
21 
22 namespace nav2_behavior_tree
23 {
24 
34 class ToggleCollisionMonitorService : public BtServiceNode<nav2_msgs::srv::Toggle>
35 {
36 public:
43  const std::string & service_node_name,
44  const BT::NodeConfiguration & conf);
45 
50  void on_tick() override;
51 
56  static BT::PortsList providedPorts()
57  {
58  return providedBasicPorts(
59  {
60  BT::InputPort<bool>(
61  "enable", true,
62  "Whether to enable or disable collision monitoring"),
63  });
64  }
65 };
66 
67 } // namespace nav2_behavior_tree
Abstract class representing a service based BT node.
static BT::PortsList providedBasicPorts(BT::PortsList addition)
Any subclass of BtServiceNode that accepts parameters must provide a providedPorts method and call pr...
A nav2_behavior_tree::BtServiceNode class that wraps nav2_msgs::srv::Toggle.
static BT::PortsList providedPorts()
Creates list of BT ports.
void on_tick() override
The main override required by a BT service.
ToggleCollisionMonitorService(const std::string &service_node_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::ToggleCollisionMonitorService.