SMACC
Loading...
Searching...
No Matches
backward_local_planner.h
Go to the documentation of this file.
1/*****************************************************************************************************************
2 * ReelRobotix Inc. - Software License Agreement Copyright (c) 2018
3 * Authors: Pablo Inigo Blasco, Brett Aldrich
4 *
5 ******************************************************************************************************************/
6#pragma once
7#include <backward_local_planner/BackwardLocalPlannerConfig.h>
8#include <dynamic_reconfigure/server.h>
9#include <geometry_msgs/PoseStamped.h>
10#include <nav_core/base_local_planner.h>
11#include <tf/tf.h>
12#include <tf/transform_listener.h>
13#include <tf2_ros/buffer.h>
14#include <Eigen/Eigen>
15
16typedef double meter;
17typedef double rad;
18
19namespace cl_move_base_z
20{
21namespace backward_local_planner
22{
23class BackwardLocalPlanner : public nav_core::BaseLocalPlanner
24{
25public:
27
28 virtual ~BackwardLocalPlanner();
29
36 virtual bool computeVelocityCommands(geometry_msgs::Twist &cmd_vel) override;
37
42 virtual bool isGoalReached() override;
43
49 virtual bool setPlan(const std::vector<geometry_msgs::PoseStamped> &plan) override;
50
57 void initialize(std::string name, tf::TransformListener *tf, costmap_2d::Costmap2DROS *costmapRos_);
58
59 void initialize(std::string name, tf2_ros::Buffer *tf, costmap_2d::Costmap2DROS *costmapRos_);
60
61 void initialize();
62
63private:
64 void reconfigCB(::backward_local_planner::BackwardLocalPlannerConfig &config, uint32_t level);
65
66 // returns true if found
67 bool findInitialCarrotGoal(tf::Stamped<tf::Pose> &pose);
68
69 // returns true for a pure spining motion request
70 bool updateCarrotGoal(const tf::Stamped<tf::Pose> &tfpose);
71
73
74 void straightBackwardsAndPureSpinCmd(const tf::Stamped<tf::Pose> &tfpose, double vetta, double gamma,
75 double alpha_error, double betta_error, double rho_error,
76 geometry_msgs::Twist &cmd_vel);
77 void defaultBackwardCmd(const tf::Stamped<tf::Pose> &tfpose, double vetta, double gamma, double alpha_error,
78 double betta_error, geometry_msgs::Twist &cmd_vel);
79
80 void publishGoalMarker(double x, double y, double phi);
81
82 void computeCurrentEuclideanAndAngularErrorsToCarrotGoal(const tf::Stamped<tf::Pose> &tfpose, double &dist,
83 double &angular_error);
84
85 bool checkCurrentPoseInGoalRange(const tf::Stamped<tf::Pose> &tfpose, double angle_error, bool& inLinearGoal);
86
88
89 bool divergenceDetectionUpdate(const tf::Stamped<tf::Pose> &tfpose);
90
91 bool checkCarrotHalfPlainConstraint(const tf::Stamped<tf::Pose> &tfpose);
92
93 dynamic_reconfigure::Server<::backward_local_planner::BackwardLocalPlannerConfig> paramServer_;
94 dynamic_reconfigure::Server<::backward_local_planner::BackwardLocalPlannerConfig>::CallbackType f;
95
96 std::vector<geometry_msgs::PoseStamped> backwardsPlanPath_;
97 costmap_2d::Costmap2DROS *costmapRos_;
98
99 ros::Publisher goalMarkerPublisher_;
100
101 double k_rho_;
102 double k_alpha_;
103 double k_betta_;
106
112
113 const double alpha_offset_ = M_PI;
114 const double betta_offset_ = 0;
115
116 double yaw_goal_tolerance_; // radians
117 double xy_goal_tolerance_; // meters
118
122
123 double max_linear_x_speed_; // meters/sec
124 double max_angular_z_speed_; // rads/sec
125
126 // references the current point inside the backwardsPlanPath were the robot is located
128
129 void generateTrajectory(const Eigen::Vector3f &pos, const Eigen::Vector3f &vel, float maxdist, float maxangle,
130 float maxtime, float dt, std::vector<Eigen::Vector3f> &outtraj);
131 Eigen::Vector3f computeNewPositions(const Eigen::Vector3f &pos, const Eigen::Vector3f &vel, double dt);
132
134 ros::Duration waitingTimeout_;
135 ros::Time waitingStamp_;
136};
137} // namespace backward_local_planner
138} // namespace cl_move_base_z
double rad
double meter
virtual bool isGoalReached() override
Check if the goal pose has been achieved by the local planner.
Eigen::Vector3f computeNewPositions(const Eigen::Vector3f &pos, const Eigen::Vector3f &vel, double dt)
bool updateCarrotGoal(const tf::Stamped< tf::Pose > &tfpose)
void defaultBackwardCmd(const tf::Stamped< tf::Pose > &tfpose, double vetta, double gamma, double alpha_error, double betta_error, geometry_msgs::Twist &cmd_vel)
bool checkCarrotHalfPlainConstraint(const tf::Stamped< tf::Pose > &tfpose)
virtual bool computeVelocityCommands(geometry_msgs::Twist &cmd_vel) override
Given the current position, orientation, and velocity of the robot: compute velocity commands to send...
void straightBackwardsAndPureSpinCmd(const tf::Stamped< tf::Pose > &tfpose, double vetta, double gamma, double alpha_error, double betta_error, double rho_error, geometry_msgs::Twist &cmd_vel)
void reconfigCB(::backward_local_planner::BackwardLocalPlannerConfig &config, uint32_t level)
bool checkCurrentPoseInGoalRange(const tf::Stamped< tf::Pose > &tfpose, double angle_error, bool &inLinearGoal)
void generateTrajectory(const Eigen::Vector3f &pos, const Eigen::Vector3f &vel, float maxdist, float maxangle, float maxtime, float dt, std::vector< Eigen::Vector3f > &outtraj)
virtual bool setPlan(const std::vector< geometry_msgs::PoseStamped > &plan) override
Set the plan that the local planner is following.
bool divergenceDetectionUpdate(const tf::Stamped< tf::Pose > &tfpose)
void computeCurrentEuclideanAndAngularErrorsToCarrotGoal(const tf::Stamped< tf::Pose > &tfpose, double &dist, double &angular_error)
std::vector< geometry_msgs::PoseStamped > backwardsPlanPath_
dynamic_reconfigure::Server<::backward_local_planner::BackwardLocalPlannerConfig >::CallbackType f
dynamic_reconfigure::Server<::backward_local_planner::BackwardLocalPlannerConfig > paramServer_