SMACC2
Loading...
Searching...
No Matches
forward_local_planner.hpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft Inc.
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/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20#pragma once
21
22#include <eigen3/Eigen/Eigen>
23
24#include <tf2/transform_datatypes.h>
26#include <visualization_msgs/msg/marker_array.hpp>
27
28#include <tf2/utils.h>
29#include <nav2_core/controller.hpp>
30
31typedef double meter;
32typedef double rad;
33
34namespace cl_nav2z
35{
36namespace forward_local_planner
37{
38class ForwardLocalPlanner : public nav2_core::Controller
39{
40public:
42
43 virtual ~ForwardLocalPlanner();
44
45 void configure(
46 const rclcpp_lifecycle::LifecycleNode::WeakPtr & parent, std::string name,
47 const std::shared_ptr<tf2_ros::Buffer> tf,
48 const std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
49
50 void activate() override;
51 void deactivate() override;
52 void cleanup() override;
53
58 void setPlan(const nav_msgs::msg::Path & path) override;
59
72 virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(
73 const geometry_msgs::msg::PoseStamped & pose, const geometry_msgs::msg::Twist & velocity,
74 nav2_core::GoalChecker * goal_checker) override;
75
76 /*deprecated in navigation2*/
77 bool isGoalReached();
78
79 virtual void setSpeedLimit(const double & speed_limit, const bool & percentage) override;
80
81private:
82 void updateParameters();
83 nav2_util::LifecycleNode::SharedPtr nh_;
84
85 void publishGoalMarker(double x, double y, double phi);
86 void cleanMarkers();
87
89 const Eigen::Vector3f & pos, const Eigen::Vector3f & vel, float maxdist, float maxangle,
90 float maxtime, float dt, std::vector<Eigen::Vector3f> & outtraj);
91 Eigen::Vector3f computeNewPositions(
92 const Eigen::Vector3f & pos, const Eigen::Vector3f & vel, double dt);
93
94 std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmapRos_;
95 std::string name_;
96
97 rclcpp_lifecycle::LifecyclePublisher<visualization_msgs::msg::MarkerArray>::SharedPtr
99
100 double k_rho_;
101 double k_alpha_;
102 double k_betta_;
104
105 const double alpha_offset_ = 0;
106 const double betta_offset_ = 0;
107
110
111 double yaw_goal_tolerance_; // radians
112 double xy_goal_tolerance_; // meters
113
117
118 // references the current point inside the backwardsPlanPath were the robot is located
120
121 std::vector<geometry_msgs::msg::PoseStamped> plan_;
122
124 rclcpp::Duration waitingTimeout_;
125 rclcpp::Time waitingStamp_;
126 std::shared_ptr<tf2_ros::Buffer> tf_;
127};
128} // namespace forward_local_planner
129} // namespace cl_nav2z
double meter
std::vector< geometry_msgs::msg::PoseStamped > plan_
std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmapRos_
Eigen::Vector3f computeNewPositions(const Eigen::Vector3f &pos, const Eigen::Vector3f &vel, double dt)
void configure(const rclcpp_lifecycle::LifecycleNode::WeakPtr &parent, std::string name, const std::shared_ptr< tf2_ros::Buffer > tf, const std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmap_ros) override
void generateTrajectory(const Eigen::Vector3f &pos, const Eigen::Vector3f &vel, float maxdist, float maxangle, float maxtime, float dt, std::vector< Eigen::Vector3f > &outtraj)
virtual void setSpeedLimit(const double &speed_limit, const bool &percentage) override
virtual geometry_msgs::msg::TwistStamped computeVelocityCommands(const geometry_msgs::msg::PoseStamped &pose, const geometry_msgs::msg::Twist &velocity, nav2_core::GoalChecker *goal_checker) override
nav2_core computeVelocityCommands - calculates the best command given the current pose and velocity
void setPlan(const nav_msgs::msg::Path &path) override
nav2_core setPlan - Sets the global plan
rclcpp_lifecycle::LifecyclePublisher< visualization_msgs::msg::MarkerArray >::SharedPtr goalMarkerPublisher_