collvoid_local_planner.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Daniel Claes, Maastricht University
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Maastricht University nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 
00031 #ifndef COLLVOID_LOCAL_PLANNER_H_
00032 #define COLLVOID_LOCAL_PLANNER_H_
00033 
00034 
00035 #include <tf/transform_listener.h>
00036 #include <nav_core/base_local_planner.h>
00037 #include <angles/angles.h>
00038 #include <nav_msgs/Odometry.h>
00039 #include <nav_msgs/GridCells.h>
00040 #include <ros/ros.h>
00041 #include <dynamic_reconfigure/server.h>
00042 
00043 #include "collvoid_local_planner/ROSAgent.h"
00044 #include "collvoid_local_planner/CollvoidConfig.h"
00045 
00046 
00047 using namespace collvoid;
00048 
00049 namespace collvoid_local_planner {
00050   /* typedef boost::shared_ptr<ROSAgent> ROSAgentPtr; */
00051 
00052   class CollvoidLocalPlanner: public nav_core::BaseLocalPlanner {
00053   public:
00054     CollvoidLocalPlanner();
00055     CollvoidLocalPlanner(std::string name, tf::TransformListener* tf, costmap_2d::Costmap2DROS* costmap_ros);
00056     ~CollvoidLocalPlanner();
00057     void initialize(std::string name, tf::TransformListener* tf, costmap_2d::Costmap2DROS* costmap_ros);
00058     bool isGoalReached();
00059     bool setPlan(const std::vector<geometry_msgs::PoseStamped>& global_plan);
00060     void odomCallback(const nav_msgs::Odometry::ConstPtr& msg);
00061     bool computeVelocityCommands(geometry_msgs::Twist& cmd_vel);
00062 
00063   private:
00064     bool rotateToGoal(const tf::Stamped<tf::Pose>& global_pose, const tf::Stamped<tf::Pose>& robot_vel, double goal_th, geometry_msgs::Twist& cmd_vel);
00065     bool stopWithAccLimits(const tf::Stamped<tf::Pose>& global_pose, const tf::Stamped<tf::Pose>& robot_vel, geometry_msgs::Twist& cmd_vel);
00066 
00067 
00068     bool transformGlobalPlan(const tf::TransformListener& tf, const std::vector<geometry_msgs::PoseStamped>& global_plan, const costmap_2d::Costmap2DROS& costmap, const std::string& global_frame, std::vector<geometry_msgs::PoseStamped>& transformed_plan);
00069     void findBestWaypoint(geometry_msgs::PoseStamped& target_pose, const tf::Stamped<tf::Pose>& global_pose);
00070 
00071     void obstaclesCallback(const nav_msgs::GridCells::ConstPtr& msg);
00072 
00073     //Dyn reconfigure
00074     boost::recursive_mutex configuration_mutex_;
00075     dynamic_reconfigure::Server<collvoid_local_planner::CollvoidConfig> *dsrv_;
00076     void reconfigureCB(collvoid_local_planner::CollvoidConfig &config, uint32_t level);
00077     collvoid_local_planner::CollvoidConfig last_config_;
00078     collvoid_local_planner::CollvoidConfig default_config_;
00079 
00080 
00081 
00082     //Datatypes:
00083     costmap_2d::Costmap2DROS* costmap_ros_; 
00084     tf::TransformListener* tf_; 
00085     
00086     bool initialized_, skip_next_, setup_;
00087 
00088     //Agent stuff
00089     double sim_period_;
00090     double max_vel_x_, min_vel_x_;
00091     double max_vel_y_, min_vel_y_;
00092     double max_vel_th_, min_vel_th_, min_vel_th_inplace_;
00093     double acc_lim_x_, acc_lim_y_, acc_lim_th_;
00094     double wheel_base_, radius_;
00095     double max_vel_with_obstacles_;
00096 
00097     bool holo_robot_;
00098 
00099     double trunc_time_, left_pref_; 
00100     
00101     double xy_goal_tolerance_, yaw_goal_tolerance_;
00102     double rot_stopped_velocity_, trans_stopped_velocity_;
00103 
00104     double publish_me_period_, publish_positions_period_;
00105     double threshold_last_seen_;
00106     
00107 
00108     bool latch_xy_goal_tolerance_, xy_tolerance_latch_, rotating_to_goal_, ignore_goal_yaw_, delete_observations_;
00109     
00110     unsigned int current_waypoint_;
00111     //params ORCA
00112     double  time_horizon_obst_;
00113     double eps_;
00114 
00115     ROSAgentPtr me_;
00116     //boost::unordered_map<std::string,ROSAgent> neighbors_;
00117     //base_local_planner::TrajectoryPlanner collision_planner_;
00118      
00119     
00120     double time_to_holo_, min_error_holo_, max_error_holo_;
00121 
00122     std::string global_frame_; 
00123     std::string robot_base_frame_; 
00124     std::vector<geometry_msgs::PoseStamped> global_plan_, transformed_plan_;
00125     ros::Publisher g_plan_pub_, l_plan_pub_;
00126     ros::Subscriber obstacles_sub_;
00127 
00128   };//end class
00129 
00130   //  Vector2 rotateVectorByAngle(double x, double y, double ang);
00131 
00132 
00133 }; //end namespace
00134 
00135 #endif //end guard catch
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


collvoid_local_planner
Author(s): Daniel Claes
autogenerated on Sun Aug 25 2013 10:10:23