15 #ifndef NAV2_WAYPOINT_FOLLOWER__WAYPOINT_FOLLOWER_HPP_
16 #define NAV2_WAYPOINT_FOLLOWER__WAYPOINT_FOLLOWER_HPP_
23 #include "rclcpp_action/rclcpp_action.hpp"
24 #include "pluginlib/class_loader.hpp"
25 #include "pluginlib/class_list_macros.hpp"
26 #include "geographic_msgs/msg/geo_pose.hpp"
27 #include "nav2_ros_common/lifecycle_node.hpp"
28 #include "nav2_msgs/action/navigate_to_pose.hpp"
29 #include "nav2_msgs/action/follow_waypoints.hpp"
30 #include "nav2_msgs/msg/waypoint_status.hpp"
31 #include "nav2_ros_common/simple_action_server.hpp"
32 #include "nav2_ros_common/node_utils.hpp"
33 #include "nav2_util/string_utils.hpp"
34 #include "nav2_msgs/action/follow_gps_waypoints.hpp"
35 #include "nav2_ros_common/service_client.hpp"
36 #include "nav2_core/waypoint_task_executor.hpp"
37 #include "nav2_waypoint_follower/parameter_handler.hpp"
39 #include "robot_localization/srv/from_ll.hpp"
41 namespace nav2_waypoint_follower
44 enum class ActionStatus
56 std::string error_msg;
67 using ActionT = nav2_msgs::action::FollowWaypoints;
68 using ClientT = nav2_msgs::action::NavigateToPose;
70 using ActionClient = nav2::ActionClient<ClientT>;
73 using ActionTGPS = nav2_msgs::action::FollowGPSWaypoints;
80 explicit WaypointFollower(
const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
94 nav2::CallbackReturn
on_configure(
const rclcpp_lifecycle::State & state)
override;
100 nav2::CallbackReturn
on_activate(
const rclcpp_lifecycle::State & state)
override;
106 nav2::CallbackReturn
on_deactivate(
const rclcpp_lifecycle::State & state)
override;
112 nav2::CallbackReturn
on_cleanup(
const rclcpp_lifecycle::State & state)
override;
118 nav2::CallbackReturn
on_shutdown(
const rclcpp_lifecycle::State & state)
override;
133 template<
typename T,
typename V,
typename Z>
143 bool goalReceived(std::shared_ptr<const typename T::Goal> goal);
163 void resultCallback(
const rclcpp_action::ClientGoalHandle<ClientT>::WrappedResult & result);
179 const std::vector<geographic_msgs::msg::GeoPose> & gps_poses);
191 std::vector<geometry_msgs::msg::PoseStamped>
getLatestGoalPoses(
const T & action_server);
194 std::vector<int> failed_ids_;
197 typename ActionServer::SharedPtr xyz_action_server_;
198 ActionClient::SharedPtr nav_to_pose_client_;
199 rclcpp::CallbackGroup::SharedPtr callback_group_;
200 rclcpp::executors::SingleThreadedExecutor callback_group_executor_;
201 std::shared_future<rclcpp_action::ClientGoalHandle<ClientT>::SharedPtr> future_goal_handle_;
204 typename ActionServerGPS::SharedPtr gps_action_server_;
205 nav2::ServiceClient<robot_localization::srv::FromLL>::SharedPtr from_ll_to_map_client_;
210 pluginlib::ClassLoader<nav2_core::WaypointTaskExecutor>
211 waypoint_task_executor_loader_;
212 pluginlib::UniquePtr<nav2_core::WaypointTaskExecutor>
213 waypoint_task_executor_;
216 std::unique_ptr<nav2_waypoint_follower::ParameterHandler> param_handler_;
A lifecycle node wrapper to enable common Nav2 needs such as manipulating parameters.
An action server wrapper to make applications simpler using Actions.
An action server that uses behavior tree for navigating a robot to its goal position.
nav2::CallbackReturn on_deactivate(const rclcpp_lifecycle::State &state) override
Deactivates action server.
bool goalReceived(std::shared_ptr< const typename T::Goal > goal)
Goal received callbacks to validate a new goal before acceptance. Rejects goals with empty waypoint l...
nav2::CallbackReturn on_shutdown(const rclcpp_lifecycle::State &state) override
Called when in shutdown state.
void resultCallback(const rclcpp_action::ClientGoalHandle< ClientT >::WrappedResult &result)
Action client result callback.
~WaypointFollower()
A destructor for nav2_waypoint_follower::WaypointFollower class.
WaypointFollower(const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
A constructor for nav2_waypoint_follower::WaypointFollower class.
void goalResponseCallback(const rclcpp_action::ClientGoalHandle< ClientT >::SharedPtr &goal)
Action client goal response callback.
nav2::CallbackReturn on_cleanup(const rclcpp_lifecycle::State &state) override
Resets member variables.
nav2::CallbackReturn on_configure(const rclcpp_lifecycle::State &state) override
Configures member variables.
void followGPSWaypointsCallback()
send robot through each of GPS point , which are converted to map frame first then using a client to ...
std::vector< geometry_msgs::msg::PoseStamped > convertGPSPosesToMapPoses(const std::vector< geographic_msgs::msg::GeoPose > &gps_poses)
given some gps_poses, converts them to map frame using robot_localization's service fromLL....
void followWaypointsHandler(const T &action_server, const V &feedback, const Z &result)
Templated function to perform internal logic behind waypoint following, Both GPS and non GPS waypoint...
void followWaypointsCallback()
Action server callbacks.
std::vector< geometry_msgs::msg::PoseStamped > getLatestGoalPoses(const T &action_server)
get the latest poses on the action server goal. If they are GPS poses, convert them to the global car...
nav2::CallbackReturn on_activate(const rclcpp_lifecycle::State &state) override
Activates action server.