Easy Navigation
Loading...
Searching...
No Matches
GoalManagerClient.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
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
17
18#ifndef EASYNAV_SYSTEM__GOALMANAGERCLIENT_HPP_
19#define EASYNAV_SYSTEM__GOALMANAGERCLIENT_HPP_
20
21#include <string>
22
23#include "rclcpp/rclcpp.hpp"
24#include "easynav_interfaces/msg/navigation_control.hpp"
25#include "geometry_msgs/msg/pose_stamped.hpp"
26#include "nav_msgs/msg/goals.hpp"
27
28namespace easynav
29{
30
38{
39public:
40 RCLCPP_SMART_PTR_DEFINITIONS(GoalManagerClient)
41
42
46 enum class State
47 {
48 IDLE,
49 SENT_GOAL,
50 SENT_PREEMPT,
51 ACCEPTED_AND_NAVIGATING,
52 NAVIGATION_FINISHED,
53 NAVIGATION_REJECTED,
54 NAVIGATION_FAILED,
55 NAVIGATION_CANCELLED,
56 ERROR
57 };
58
63 explicit GoalManagerClient(rclcpp::Node::SharedPtr node);
64
69 void send_goal(const geometry_msgs::msg::PoseStamped & goal);
70
75 void send_goals(const nav_msgs::msg::Goals & goals);
76
80 void cancel();
81
89 void pause();
90
94 void resume();
95
100 [[nodiscard]] bool is_paused() const {return paused_;}
101
105 void reset();
106
111 [[nodiscard]] State get_state() const {return state_;}
112
117 [[nodiscard]] bool is_connected() const
118 {
119 return control_pub_->get_subscription_count() > 1;
120 }
121
126 [[nodiscard]] const easynav_interfaces::msg::NavigationControl & get_last_control() const;
127
132 [[nodiscard]] const easynav_interfaces::msg::NavigationControl & get_feedback() const;
133
138 [[nodiscard]] const easynav_interfaces::msg::NavigationControl & get_result() const;
139
140private:
142 rclcpp::Node::SharedPtr node_;
143
145 rclcpp::Publisher<easynav_interfaces::msg::NavigationControl>::SharedPtr control_pub_;
146
148 rclcpp::Subscription<easynav_interfaces::msg::NavigationControl>::SharedPtr control_sub_;
149
151 easynav_interfaces::msg::NavigationControl::UniquePtr last_control_;
152
154 easynav_interfaces::msg::NavigationControl last_feedback_;
155
157 easynav_interfaces::msg::NavigationControl last_result_;
158
160 std::string id_;
161
163 State state_;
164
166 bool paused_ {false};
167
169 void control_callback(easynav_interfaces::msg::NavigationControl::UniquePtr msg);
170};
171
172} // namespace easynav
173
174#endif // EASYNAV_SYSTEM__GOALMANAGERCLIENT_HPP_
void cancel()
Cancel the current goal.
Definition GoalManagerClient.cpp:241
const easynav_interfaces::msg::NavigationControl & get_feedback() const
Get the most recent feedback received.
Definition GoalManagerClient.cpp:179
const easynav_interfaces::msg::NavigationControl & get_result() const
Get the last result message received.
Definition GoalManagerClient.cpp:185
void resume()
Resume a previously paused goal.
Definition GoalManagerClient.cpp:288
void send_goals(const nav_msgs::msg::Goals &goals)
Send a list of goals to the GoalManager.
Definition GoalManagerClient.cpp:203
void send_goal(const geometry_msgs::msg::PoseStamped &goal)
Send a single goal to the GoalManager.
Definition GoalManagerClient.cpp:191
State
Internal state of the client-side goal manager.
Definition GoalManagerClient.hpp:47
const easynav_interfaces::msg::NavigationControl & get_last_control() const
Get the last control message sent or received.
Definition GoalManagerClient.cpp:173
void pause()
Pause the currently active EasyNav navigation.
Definition GoalManagerClient.cpp:265
GoalManagerClient(rclcpp::Node::SharedPtr node)
Constructor.
Definition GoalManagerClient.cpp:31
bool is_paused() const
Whether the currently navigating goal is paused.
Definition GoalManagerClient.hpp:100
State get_state() const
Get the current internal state.
Definition GoalManagerClient.hpp:111
bool is_connected() const
Check whether another subscriber besides the client is present on the control topic.
Definition GoalManagerClient.hpp:117
void reset()
Reset internal client state.
Definition GoalManagerClient.cpp:307
Definition CircularBuffer.hpp:24