Easy Navigation
Loading...
Searching...
No Matches
GoalManagerClient.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
2//
3// This file is part of the project Easy Navigation (EasyNav in short)
4// licensed under the GNU General Public License v3.0.
5// See <http://www.gnu.org/licenses/> for details.
6//
7// Easy Navigation program is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
22
23#ifndef EASYNAV_SYSTEM__GOALMANAGERCLIENT_HPP_
24#define EASYNAV_SYSTEM__GOALMANAGERCLIENT_HPP_
25
26#include "rclcpp/rclcpp.hpp"
27#include "rclcpp_lifecycle/lifecycle_node.hpp"
28
29#include "easynav_interfaces/msg/navigation_control.hpp"
30#include "geometry_msgs/msg/pose_stamped.hpp"
31#include "nav_msgs/msg/goals.hpp"
32
33namespace easynav
34{
35
36using namespace std::placeholders;
37
45{
46public:
47 RCLCPP_SMART_PTR_DEFINITIONS(GoalManagerClient)
48
49
65
70 GoalManagerClient(rclcpp::Node::SharedPtr node);
71
76 void send_goal(const geometry_msgs::msg::PoseStamped & goal);
77
82 void send_goals(const nav_msgs::msg::Goals & goals);
83
87 void cancel();
88
92 void reset();
93
98 [[nodiscard]] State get_state() const {return state_;}
99
104 [[nodiscard]] const easynav_interfaces::msg::NavigationControl & get_last_control() const;
105
110 [[nodiscard]] const easynav_interfaces::msg::NavigationControl & get_feedback() const;
111
116 [[nodiscard]] const easynav_interfaces::msg::NavigationControl & get_result() const;
117
118private:
120 rclcpp::Node::SharedPtr node_;
121
123 rclcpp::Publisher<easynav_interfaces::msg::NavigationControl>::SharedPtr control_pub_;
124
126 rclcpp::Subscription<easynav_interfaces::msg::NavigationControl>::SharedPtr control_sub_;
127
129 easynav_interfaces::msg::NavigationControl::UniquePtr last_control_;
130
132 easynav_interfaces::msg::NavigationControl last_feedback_;
133
135 easynav_interfaces::msg::NavigationControl last_result_;
136
138 std::string id_;
139
141 std::string current_client_id_;
142
144 State state_;
145
147 void control_callback(easynav_interfaces::msg::NavigationControl::UniquePtr msg);
148};
149
150} // namespace easynav
151
152#endif // EASYNAV_SYSTEM__GOALMANAGERCLIENT_HPP_
void cancel()
Cancel the current goal.
Definition GoalManagerClient.cpp:222
const easynav_interfaces::msg::NavigationControl & get_feedback() const
Get the most recent feedback received.
Definition GoalManagerClient.cpp:161
const easynav_interfaces::msg::NavigationControl & get_result() const
Get the last result message received.
Definition GoalManagerClient.cpp:167
void send_goals(const nav_msgs::msg::Goals &goals)
Send a list of goals to the GoalManager.
Definition GoalManagerClient.cpp:185
void send_goal(const geometry_msgs::msg::PoseStamped &goal)
Send a single goal to the GoalManager.
Definition GoalManagerClient.cpp:173
State
Internal state of the client-side goal manager.
Definition GoalManagerClient.hpp:54
@ SENT_GOAL
Definition GoalManagerClient.hpp:56
@ SENT_PREEMPT
Definition GoalManagerClient.hpp:57
@ NAVIGATION_FAILED
Definition GoalManagerClient.hpp:61
@ ACCEPTED_AND_NAVIGATING
Definition GoalManagerClient.hpp:58
@ IDLE
Definition GoalManagerClient.hpp:55
@ ERROR
Definition GoalManagerClient.hpp:63
@ NAVIGATION_CANCELLED
Definition GoalManagerClient.hpp:62
@ NAVIGATION_FINISHED
Definition GoalManagerClient.hpp:59
@ NAVIGATION_REJECTED
Definition GoalManagerClient.hpp:60
const easynav_interfaces::msg::NavigationControl & get_last_control() const
Get the last control message sent or received.
Definition GoalManagerClient.cpp:155
GoalManagerClient(rclcpp::Node::SharedPtr node)
Constructor.
Definition GoalManagerClient.cpp:36
State get_state() const
Get the current internal state.
Definition GoalManagerClient.hpp:98
void reset()
Reset internal client state.
Definition GoalManagerClient.cpp:246
Definition RTTFBuffer.hpp:30