48 dsrv_ =
new dynamic_reconfigure::Server<FTCPlannerConfig>(private_nh);
50 dsrv_->setCallback(cb);
54 ROS_INFO(
"FTCPlanner: Version 2 Init.");
59 if (config.restore_defaults)
62 config.restore_defaults =
false;
72 bool first_use =
false;
91 ROS_DEBUG(
"FTCPlanner: Old Goal == new Goal.");
99 ROS_INFO(
"FTCPlanner: New Goal. Start new routine.");
113 geometry_msgs::PoseStamped msg;
117 tf::Vector3(msg.pose.position.x, msg.pose.position.y, msg.pose.position.z)));
143 ROS_INFO(
"FTCPlanner: Excessive deviation from global plan orientation. Start routine new.");
159 ROS_INFO(
"FTCPlanner: Stand at goal. Rotate to goal orientation.");
171 cmd_vel.linear.x = 0;
172 cmd_vel.linear.y = 0;
180 ROS_DEBUG(
"FTCPlanner: Calculation time: %f seconds", duration.
toSec());
192 double distance =
sqrt(
pow((x_pose.getOrigin().getX()-current_pose.getOrigin().getX()),2)+
pow((x_pose.getOrigin().getY()-current_pose.getOrigin().getY()),2));
197 geometry_msgs::PoseStamped pose;
217 int max_point = points;
219 for(
int i = max_point; i >= 0; i--)
235 if(point >= (
int)plan.size())
237 point = plan.size()-1;
240 double current_th =
tf::getYaw(current_pose.getRotation());
241 for(
int i = 0; i <= point; i++)
243 geometry_msgs::PoseStamped x_pose;
247 double angle_to_goal =
atan2(x_pose.pose.position.y - current_pose.getOrigin().getY(),
248 x_pose.pose.position.x - current_pose.getOrigin().getX());
249 angle += angle_to_goal;
253 angle = angle/(point+1);
265 if(fabs(angle) > accuracy)
333 ROS_DEBUG(
"FTCPlanner: cmd_vel.z: %f, angle: %f", cmd_vel.angular.z, angle);
339 cmd_vel.angular.z = 0;
358 geometry_msgs::PoseStamped x_pose;
361 distance =
sqrt(
pow((x_pose.pose.position.x-current_pose.getOrigin().getX()),2)+
pow((x_pose.pose.position.y-current_pose.getOrigin().getY()),2));
414 if(cmd_vel_angular_z_ < 0 && cmd_vel_angular_z_old > 0)
447 ROS_DEBUG(
"FTCPlanner: max_point: %d, distance: %f, x_vel: %f, rot_vel: %f, angle: %f", max_point, distance, cmd_vel.linear.x, cmd_vel.angular.z, angle);
457 ROS_INFO(
"FTCPlanner: Goal reached.");
465 unsigned char previous_cost = 255;
467 for (
int i = 0; i <= max_points; i++)
469 geometry_msgs::PoseStamped x_pose;
481 ROS_INFO(
"FTCPlanner: Obstacel detected. Start routine new.");
486 if(costs > 127 && costs > previous_cost)
488 ROS_WARN(
"FTCPlanner: Possible collision. Stop local planner.");
492 previous_cost = costs;
499 std::vector<geometry_msgs::PoseStamped> path;
507 nav_msgs::Path gui_path;
508 gui_path.poses.resize(path.size());
509 gui_path.header.frame_id = path[0].header.frame_id;
510 gui_path.header.stamp = path[0].header.stamp;
513 for(
unsigned int i=0; i < path.size(); i++)
515 gui_path.poses[i] = path[i];
bool setPlan(const std::vector< geometry_msgs::PoseStamped > &plan)
Set the plan that the local planner is following.
int checkMaxAngle(int points, tf::Stamped< tf::Pose > current_pose)
Goes backward along global plan the max angle whith sim_time and max_rotation_vel allow...
tf::Stamped< tf::Pose > goal_pose_
void reconfigureCB(FTCPlannerConfig &config, uint32_t level)
Reconfigure config_.
JoinCostmap * joinCostmap_
int checkMaxDistance(tf::Stamped< tf::Pose > current_pose)
Goes along global plan the max distance whith sim_time and max_x_vel allow.
void setData(const T &input)
double cmd_vel_angular_z_
tf::Stamped< tf::Pose > old_goal_pose_
static void poseStampedTFToMsg(const Stamped< Pose > &bt, geometry_msgs::PoseStamped &msg)
static double getYaw(const Quaternion &bt_q)
void joinMaps()
joinMaps join the local costmap in the global costmap.
std::string getGlobalFrameID()
std::vector< geometry_msgs::PoseStamped > transformed_global_plan_
std::vector< geometry_msgs::PoseStamped > global_plan_
bool rotateToOrientation(double angle, geometry_msgs::Twist &cmd_vel, double accuracy)
Rotation at place.
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
bool isGoalReached()
Check if the goal pose has been achieved by the local planner.
void initialize(costmap_2d::Costmap2DROS *local_costmap_ros, costmap_2d::Costmap2DROS *global_costmap_ros)
initialize the two costmaps and check if resolution global costmap > resolution local costmap...
dynamic_reconfigure::Server< FTCPlannerConfig > * dsrv_
bool checkCollision(int max_points)
Check if the considerd points are in local collision.
void publish(const boost::shared_ptr< M > &message) const
double distance(double x0, double y0, double x1, double y1)
ros::Publisher local_plan_publisher_
double calculateGlobalPlanAngle(tf::Stamped< tf::Pose > current_pose, const std::vector< geometry_msgs::PoseStamped > &plan, int points)
Calculate the orientation of the global plan.
bool rotate_to_global_plan_
void publishPlan(int max_point)
Publish the global plan for visulatation.
bool getRobotPose(geometry_msgs::PoseStamped &global_pose) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool computeVelocityCommands(geometry_msgs::Twist &cmd_vel)
Given the current position, orientation, and velocity of the robot, compute velocity commands to send...
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
ftc_local_planner::FTCPlannerConfig config_
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
void initialize(std::string name, tf2_ros::Buffer *tf, costmap_2d::Costmap2DROS *costmap_ros)
Constructs the local planner.
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
ftc_local_planner::FTCPlannerConfig default_config_
INLINE Rall1d< T, V, S > atan2(const Rall1d< T, V, S > &y, const Rall1d< T, V, S > &x)
int driveToward(tf::Stamped< tf::Pose > current_pose, geometry_msgs::Twist &cmd_vel)
Drive along the global plan and calculate the velocity.
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
double cmd_vel_angular_z_rotate_
bool getXPose(const tf2_ros::Buffer &tf, const std::vector< geometry_msgs::PoseStamped > &global_plan, const std::string &global_frame, tf::Stamped< tf::Pose > &goal_pose, int plan_point)
Returns X pose in plan.
def shortest_angular_distance(from_angle, to_angle)
unsigned char getCost(unsigned int mx, unsigned int my) const
costmap_2d::Costmap2DROS * costmap_ros_