SMACC
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner Class Reference

#include <pure_spinning_local_planner.h>

Inheritance diagram for cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner:
Inheritance graph
Collaboration diagram for cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner:
Collaboration graph

Public Member Functions

 PureSpinningLocalPlanner ()
 
virtual ~PureSpinningLocalPlanner ()
 
virtual bool computeVelocityCommands (geometry_msgs::Twist &cmd_vel) override
 Given the current position, orientation, and velocity of the robot: compute velocity commands to send to the robot mobile base. More...
 
virtual bool isGoalReached () override
 Check if the goal pose has been achieved by the local planner. More...
 
virtual bool setPlan (const std::vector< geometry_msgs::PoseStamped > &plan) override
 Set the plan that the local planner is following. More...
 
void initialize (std::string name, tf::TransformListener *tf, costmap_2d::Costmap2DROS *costmapRos)
 Constructs the local planner. More...
 
void initialize (std::string name, tf2_ros::Buffer *tf, costmap_2d::Costmap2DROS *costmapRos)
 
void initialize ()
 

Private Member Functions

void reconfigCB (::pure_spinning_local_planner::PureSpinningLocalPlannerConfig &config, uint32_t level)
 
void publishGoalMarker (double x, double y, double phi)
 

Private Attributes

costmap_2d::Costmap2DROS * costmapRos_
 
std::vector< geometry_msgs::PoseStamped > plan_
 
dynamic_reconfigure::Server<::pure_spinning_local_planner::PureSpinningLocalPlannerConfig > paramServer_
 
double k_betta_
 
bool goalReached_
 
int currentPoseIndex_
 
rad yaw_goal_tolerance_
 
rad intermediate_goal_yaw_tolerance_
 
rad_s max_angular_z_speed_
 

Detailed Description

Definition at line 24 of file pure_spinning_local_planner.h.

Constructor & Destructor Documentation

◆ PureSpinningLocalPlanner()

cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::PureSpinningLocalPlanner ( )

Definition at line 32 of file pure_spinning_local_planner.cpp.

33 : paramServer_(ros::NodeHandle("~PureSpinningLocalPlanner"))
34{
35 ROS_INFO_STREAM("[PureSpinningLocalPlanner] pure spinning planner already created");
36}
dynamic_reconfigure::Server<::pure_spinning_local_planner::PureSpinningLocalPlannerConfig > paramServer_

◆ ~PureSpinningLocalPlanner()

cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::~PureSpinningLocalPlanner ( )
virtual

Definition at line 38 of file pure_spinning_local_planner.cpp.

39{
40}

Member Function Documentation

◆ computeVelocityCommands()

bool cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::computeVelocityCommands ( geometry_msgs::Twist &  cmd_vel)
overridevirtual

Given the current position, orientation, and velocity of the robot: compute velocity commands to send to the robot mobile base.

Parameters
cmd_velWill be filled with the velocity command to be passed to the robot base
Returns
True if a valid velocity command was found, false otherwise

Definition at line 74 of file pure_spinning_local_planner.cpp.

75{
76 goalReached_ = false;
77 // ROS_DEBUG("LOCAL PLANNER LOOP");
78
79 tf::Stamped<tf::Pose> tfpose = optionalRobotPose(costmapRos_);
80
81 geometry_msgs::PoseStamped currentPose;
82 tf::poseStampedTFToMsg(tfpose, currentPose);
83 // ROS_INFO_STREAM("[PureSpinningLocalPlanner] current robot pose " << currentPose);
84
85 tf::Quaternion q = tfpose.getRotation();
86 auto currentYaw = tf::getYaw(currentPose.pose.orientation);
87 double angular_error;
88 double targetYaw;
89
90 while (currentPoseIndex_ < plan_.size())
91 {
92 auto &goal = plan_[currentPoseIndex_];
93 targetYaw = tf::getYaw(goal.pose.orientation);
94
95 //double angular_error = angles::shortest_angular_distance( currentYaw , targetYaw) ;
96 angular_error = targetYaw - currentYaw ;
97
98 // all the points must be reached using the control rule, but the last one
99 // have an special condition
100 if ( (currentPoseIndex_ < plan_.size() -1 && fabs(angular_error) < this->intermediate_goal_yaw_tolerance_)
101 || (currentPoseIndex_ == plan_.size() -1 && fabs(angular_error) < this->intermediate_goal_yaw_tolerance_)
102 )
103 {
105 }
106 else
107 {
108 break;
109 }
110 }
111
112 auto omega = angular_error * k_betta_;
113 cmd_vel.angular.z = std::min(std::max(omega, -fabs(max_angular_z_speed_)), fabs(max_angular_z_speed_));
114
115 //ROS_DEBUG_STREAM("[PureSpinningLocalPlanner] current yaw: " << currentYaw);
116 //ROS_DEBUG_STREAM("[PureSpinningLocalPlanner] target yaw: " << targetYaw);
117 ROS_DEBUG_STREAM("[PureSpinningLocalPlanner] angular error: " << angular_error << "("<<yaw_goal_tolerance_<<")");
118 ROS_DEBUG_STREAM("[PureSpinningLocalPlanner] command angular speed: " << cmd_vel.angular.z);
119 ROS_DEBUG_STREAM("[PureSpinningLocalPlanner] completion " << currentPoseIndex_ << "/"<< plan_.size());
120
121 if (currentPoseIndex_ >= plan_.size() -1 && fabs(angular_error) < yaw_goal_tolerance_)
122 {
123 ROS_DEBUG_STREAM("[PureSpinningLocalPlanner] GOAL REACHED ");
124 goalReached_ = true;
125 }
126
127 return true;
128}
tf::Stamped< tf::Pose > optionalRobotPose(costmap_2d::Costmap2DROS *costmapRos)

References costmapRos_, currentPoseIndex_, goalReached_, intermediate_goal_yaw_tolerance_, k_betta_, max_angular_z_speed_, cl_move_base_z::pure_spinning_local_planner::optionalRobotPose(), plan_, and yaw_goal_tolerance_.

Here is the call graph for this function:

◆ initialize() [1/3]

void cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::initialize ( )

Definition at line 55 of file pure_spinning_local_planner.cpp.

56{
57 ros::NodeHandle nh("~/PureSpinningLocalPlanner");
58 nh.param("k_betta", k_betta_, 10.0);
59 nh.param("yaw_goal_tolerance", yaw_goal_tolerance_, 0.08);
60 nh.param("intermediate_goals_yaw_tolerance", intermediate_goal_yaw_tolerance_, 0.12);
61 nh.param("max_angular_z_speed", max_angular_z_speed_, 1.0);
62
63 dynamic_reconfigure::Server<::pure_spinning_local_planner::PureSpinningLocalPlannerConfig>::CallbackType f;
64 f = boost::bind(&PureSpinningLocalPlanner::reconfigCB, this, _1, _2);
65 paramServer_.setCallback(f);
66}
void reconfigCB(::pure_spinning_local_planner::PureSpinningLocalPlannerConfig &config, uint32_t level)

References intermediate_goal_yaw_tolerance_, k_betta_, max_angular_z_speed_, paramServer_, reconfigCB(), and yaw_goal_tolerance_.

Referenced by initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize() [2/3]

void cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::initialize ( std::string  name,
tf2_ros::Buffer *  tf,
costmap_2d::Costmap2DROS *  costmapRos 
)

Definition at line 42 of file pure_spinning_local_planner.cpp.

References costmapRos_, and initialize().

Here is the call graph for this function:

◆ initialize() [3/3]

void cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::initialize ( std::string  name,
tf::TransformListener *  tf,
costmap_2d::Costmap2DROS *  costmapRos 
)

Constructs the local planner.

Parameters
nameThe name to give this instance of the local planner
tfA pointer to a transform listener
costmap_rosThe cost map to use for assigning costs to local plans

Definition at line 48 of file pure_spinning_local_planner.cpp.

50{
51 costmapRos_ = costmapRos;
52 this->initialize();
53}

References costmapRos_, and initialize().

Here is the call graph for this function:

◆ isGoalReached()

bool cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::isGoalReached ( )
overridevirtual

Check if the goal pose has been achieved by the local planner.

Returns
True if achieved, false otherwise

Definition at line 130 of file pure_spinning_local_planner.cpp.

131{
132 return goalReached_;
133}

References goalReached_.

◆ publishGoalMarker()

void cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::publishGoalMarker ( double  x,
double  y,
double  phi 
)
private

◆ reconfigCB()

void cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::reconfigCB ( ::pure_spinning_local_planner::PureSpinningLocalPlannerConfig &  config,
uint32_t  level 
)
private

Definition at line 68 of file pure_spinning_local_planner.cpp.

69{
70 this->k_betta_ = config.k_betta;
71 this->yaw_goal_tolerance_ = config.yaw_goal_tolerance;
72 this->max_angular_z_speed_ = config.max_angular_z_speed;
73}

References k_betta_, max_angular_z_speed_, and yaw_goal_tolerance_.

Referenced by initialize().

Here is the caller graph for this function:

◆ setPlan()

bool cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::setPlan ( const std::vector< geometry_msgs::PoseStamped > &  plan)
overridevirtual

Set the plan that the local planner is following.

Parameters
planThe plan to pass to the local planner
Returns
True if the plan was updated successfully, false otherwise

Definition at line 135 of file pure_spinning_local_planner.cpp.

136{
137 ROS_DEBUG_STREAM("[PureSpinningLocalPlanner] setting global plan to follow");
138
139 plan_ = plan;
140 goalReached_ = false;
142 return true;
143}

References currentPoseIndex_, goalReached_, and plan_.

Member Data Documentation

◆ costmapRos_

costmap_2d::Costmap2DROS* cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::costmapRos_
private

Definition at line 69 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), and initialize().

◆ currentPoseIndex_

int cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::currentPoseIndex_
private

Definition at line 78 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), and setPlan().

◆ goalReached_

bool cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::goalReached_
private

Definition at line 77 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), isGoalReached(), and setPlan().

◆ intermediate_goal_yaw_tolerance_

rad cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::intermediate_goal_yaw_tolerance_
private

Definition at line 80 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), and initialize().

◆ k_betta_

double cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::k_betta_
private

Definition at line 76 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), initialize(), and reconfigCB().

◆ max_angular_z_speed_

rad_s cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::max_angular_z_speed_
private

Definition at line 81 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), initialize(), and reconfigCB().

◆ paramServer_

dynamic_reconfigure::Server<::pure_spinning_local_planner::PureSpinningLocalPlannerConfig> cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::paramServer_
private

Definition at line 73 of file pure_spinning_local_planner.h.

Referenced by initialize().

◆ plan_

std::vector<geometry_msgs::PoseStamped> cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::plan_
private

Definition at line 71 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), and setPlan().

◆ yaw_goal_tolerance_

rad cl_move_base_z::pure_spinning_local_planner::PureSpinningLocalPlanner::yaw_goal_tolerance_
private

Definition at line 79 of file pure_spinning_local_planner.h.

Referenced by computeVelocityCommands(), initialize(), and reconfigCB().


The documentation for this class was generated from the following files: