Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving behavior of the planner to follow peak points of the global plan strictly. #39

Open
wants to merge 9 commits into
base: kinetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/teb_local_planner/teb_local_planner_ros.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ class TebLocalPlannerROS : public nav_core::BaseLocalPlanner
*/
void validateFootprints(double opt_inscribed_radius, double costmap_inscribed_radius, double min_obst_dist);

void peakViaPoint(double robot_x, double robot_y, double localGoal_x, double localGoal_y,
std::vector<geometry_msgs::PoseStamped>& transformed_plan); //Edit @mudit

void configureBackupModes(std::vector<geometry_msgs::PoseStamped>& transformed_plan, int& goal_idx);

Expand Down
38 changes: 38 additions & 0 deletions src/teb_local_planner_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,41 @@ bool TebLocalPlannerROS::setPlan(const std::vector<geometry_msgs::PoseStamped>&
return true;
}

void TebLocalPlannerROS::peakViaPoint(double robot_x, double robot_y, double localGoal_x, double localGoal_y,
std::vector<geometry_msgs::PoseStamped>& transformed_plan) //@mudit
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the complete method:
Parameters: mix of camalCase and lowercase_underderscore style. Please use the latter one acording to ROS C++ styleguide ;-)
Please also check indentation and insert a new line after braces "{".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made changes according to ROS styleguide.

double planLineSlope= (localGoal_y-robot_y)/(localGoal_x-robot_x); // slope of the line connecting robot pose and local goal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably make sure that (localGoal_x-robot_x)!=0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 😄

double planLine_yIntercept= robot_y-(planLineSlope*robot_x); // y-intercept of the line connecting robot pose and local goal
double max_dist=0;
int viaIdx;
for (std::size_t i=1; i < transformed_plan.size(); ++i)
{double x_transformed= transformed_plan[i].pose.position.x; //x1
double y_transformed= transformed_plan[i].pose.position.y; //y1
double c_perpendicular= y_transformed+(1/planLineSlope)*x_transformed; // y-intercept of the line connecting (x1,y1) and the perpendicular point
// meeting the line connecting robot pose and local goal

double x2= (planLine_yIntercept-c_perpendicular)/((-1/planLineSlope)-planLineSlope); //x2 and y2 are the new points on the line connecting robot pose and local goal
double y2= (planLineSlope*x2)+planLine_yIntercept;

double sqDist= (x2-x_transformed)*(x2-x_transformed)+(y2-y_transformed)*(y2-y_transformed); //Calculating distance b/w the two points

if(max_dist<sqDist)
{max_dist=sqDist;
viaIdx=i;
}


}

if(max_dist>0.01) //move_base crashes for unknown reason if max_dist=0.000000
{via_points_.push_back( Eigen::Vector2d( transformed_plan[viaIdx].pose.position.x, transformed_plan[viaIdx].pose.position.y ) );
// ROS_INFO("The Distance is %f",max_dist);
cfg_.hcp.max_number_classes=1;
}
else

cfg_.hcp.max_number_classes=4; // ROS_INFO("Number : %d",cfg_.hcp.max_number_classes); // transformed_plan[i].pose.position.x, transformed_plan[i].pose.position.y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not intended to change the general config class inside the planner.
I would suggest to avoid accessing max_number_classes here generally.

}

bool TebLocalPlannerROS::computeVelocityCommands(geometry_msgs::Twist& cmd_vel)
{
Expand Down Expand Up @@ -311,6 +346,9 @@ bool TebLocalPlannerROS::computeVelocityCommands(geometry_msgs::Twist& cmd_vel)
// update via-points container
updateViaPointsContainer(transformed_plan, cfg_.trajectory.global_plan_viapoint_sep);

//@mudit edit : creating a via point for including peak points of the global plan in the robot's path
peakViaPoint(robot_pose_.x(),robot_pose_.y(),robot_goal_.x(),robot_goal_.y(),transformed_plan);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If viapoints are activated, your method peakViaPoint(...) is called after updateViaPointsContainer(...) has already collected viapoints from the global plan. Hence the final list of viapoints is not in a strict order anymore. However, for some efficiency improvements later, we would like to retain the strict order. Could you try to migrate the peak-point computation into updateViaPointsContainer? Or alternatively: we could switch between: "No viapoints, uniform viapoints and peak viapoints.


// Do not allow config changes during the following optimization step
boost::mutex::scoped_lock cfg_lock(cfg_.configMutex());

Expand Down