EasyFleet
A simple-by-default framework for multi-robot, multi-capability fleets built on ROS 2
Loading...
Searching...
No Matches
easynav_navigation_capability.hpp
1// Copyright 2026 Intelligent Robotics Lab
2//
3// This file is part of the project EasyFleet
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef EASYFLEET_EASYNAV_DEPLOYMENT__EASYNAV_NAVIGATION_CAPABILITY_HPP_
17#define EASYFLEET_EASYNAV_DEPLOYMENT__EASYNAV_NAVIGATION_CAPABILITY_HPP_
18
19#include <map>
20#include <memory>
21#include <string>
22#include <thread>
23
24#include "behaviortree_cpp/bt_factory.h"
25#include "easynav_system/GoalManagerClient.hpp"
26#include "geometry_msgs/msg/pose_stamped.hpp"
27#include "rclcpp/rclcpp.hpp"
28#include "rclcpp_action/rclcpp_action.hpp"
29#include "rclcpp_lifecycle/lifecycle_node.hpp"
30
31#include "easyfleet_core/capability.hpp"
32#include "easyfleet_core/navigation_action_server_base.hpp"
33
34namespace easyfleet_easynav_deployment
35{
36
53{
54public:
59 rclcpp_lifecycle::LifecycleNode & node,
60 const std::string & action_name);
62
63protected:
69 rclcpp_action::GoalResponse on_goal_received(
70 const rclcpp_action::GoalUUID & uuid,
71 std::shared_ptr<const Goal> goal) override;
72
77 void on_execute(const GoalHandleSharedPtr goal_handle) override;
78
79private:
80 // const so its type matches exactly what Navigate (see
81 // bt_nodes/navigate.hpp) reads back off the blackboard -- built into a
82 // non-const local map during construction, then assigned here once.
83 std::shared_ptr<const std::map<std::string, geometry_msgs::msg::PoseStamped>> waypoints_;
84 std::string behavior_tree_xml_;
85 double tick_rate_hz_;
86
87 // GoalManagerClient needs a plain rclcpp::Node::SharedPtr, but this
88 // capability is an rclcpp_lifecycle::LifecycleNode -- so, same pattern as
89 // easyfleet_core::ActionClient, it owns a small internal node dedicated
90 // to talking to EasyNav, spun on its own background thread for the
91 // capability's whole lifetime.
92 rclcpp::Node::SharedPtr internal_node_;
93 rclcpp::executors::SingleThreadedExecutor::SharedPtr executor_;
94 std::thread spin_thread_;
95
96 // One instance for the capability's entire lifetime (not per ROS goal):
97 // this is what lets a new goal preempt an in-flight one at the EasyNav
98 // level (see bt_nodes/navigate.hpp for why).
99 easynav::GoalManagerClient::SharedPtr gm_client_;
100
101 BT::BehaviorTreeFactory factory_;
102};
103
108 : public easyfleet_core::Capability<EasynavNavigationActionServer>
109{
110public:
114 const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
115};
116
117} // namespace easyfleet_easynav_deployment
118
119#endif // EASYFLEET_EASYNAV_DEPLOYMENT__EASYNAV_NAVIGATION_CAPABILITY_HPP_
std::shared_ptr< GoalHandle > GoalHandleSharedPtr
Definition action_server_base.hpp:79
Lifecycle node that advertises a single action as a "capability".
Definition capability.hpp:65
Fixes ActionServerBase's action type to easyfleet_interfaces/Navigation, so a concrete navigation bac...
Definition navigation_action_server_base.hpp:31
EasynavNavigationActionServer(rclcpp_lifecycle::LifecycleNode &node, const std::string &action_name)
Constructs the action server.
Definition easynav_navigation_capability.cpp:85
void on_execute(const GoalHandleSharedPtr goal_handle) override
Builds and ticks the BT tree named by behavior_tree_xml_, driving gm_client_ through the Navigate nod...
Definition easynav_navigation_capability.cpp:173
rclcpp_action::GoalResponse on_goal_received(const rclcpp_action::GoalUUID &uuid, std::shared_ptr< const Goal > goal) override
Accepts only goals whose parameters_json names a known goal_id.
Definition easynav_navigation_capability.cpp:162
EasynavNavigationCapability(const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
Constructs the capability node.
Definition easynav_navigation_capability.cpp:256