Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef LOCOMOVE_BASE_LOCOMOVE_BASE_H
00036 #define LOCOMOVE_BASE_LOCOMOVE_BASE_H
00037
00038 #include <actionlib/server/simple_action_server.h>
00039 #include <locomotor/locomotor.h>
00040 #include <move_base_msgs/MoveBaseAction.h>
00041 #include <nav_core/recovery_behavior.h>
00042 #include <string>
00043 #include <vector>
00044
00045 namespace locomove_base
00046 {
00047 enum RecoveryTrigger
00048 {
00049 PLANNING_R, CONTROLLING_R, OSCILLATION_R
00050 };
00051
00052 class LocoMoveBase
00053 {
00054 public:
00055 explicit LocoMoveBase(const ros::NodeHandle& nh);
00056 void setGoal(nav_2d_msgs::Pose2DStamped goal);
00057 void resetState();
00058 protected:
00059 void requestNavigationFailure(const locomotor_msgs::ResultCode& result);
00060
00061 void planLoopCallback(const ros::TimerEvent& event);
00062 void requestGlobalCostmapUpdate();
00063
00064 void onGlobalCostmapUpdate(const ros::Duration& planning_time);
00065 void onGlobalCostmapException(nav_core2::NavCore2ExceptionPtr e_ptr, const ros::Duration& planning_time);
00066
00067 void onNewGlobalPlan(nav_2d_msgs::Path2D new_global_plan, const ros::Duration& planning_time);
00068 void onGlobalPlanningException(nav_core2::NavCore2ExceptionPtr e_ptr, const ros::Duration& planning_time);
00069
00070 void controlLoopCallback(const ros::TimerEvent& event);
00071
00072 void onLocalCostmapUpdate(const ros::Duration& planning_time);
00073 void onLocalCostmapException(nav_core2::NavCore2ExceptionPtr e_ptr, const ros::Duration& planning_time);
00074
00075 void onNewLocalPlan(nav_2d_msgs::Twist2DStamped new_command, const ros::Duration& planning_time);
00076 void onLocalPlanningException(nav_core2::NavCore2ExceptionPtr e_ptr, const ros::Duration& planning_time);
00077
00078 void onNavigationCompleted();
00079 void onNavigationFailure(const locomotor_msgs::ResultCode result);
00080
00081 void publishZeroVelocity();
00082
00088 bool loadRecoveryBehaviors(ros::NodeHandle node);
00089
00093 void loadDefaultRecoveryBehaviors();
00094
00095 void recovery();
00096
00097 ros::NodeHandle private_nh_;
00098 locomotor::Locomotor locomotor_;
00099
00100
00101 void goalCB(const geometry_msgs::PoseStamped::ConstPtr& goal);
00102 ros::Subscriber goal_sub_;
00103
00104
00105 void executeCB();
00106 actionlib::SimpleActionServer<move_base_msgs::MoveBaseAction> server_;
00107
00108
00109 RecoveryTrigger recovery_trigger_;
00110 pluginlib::ClassLoader<nav_core::RecoveryBehavior> recovery_loader_;
00111 std::vector<boost::shared_ptr<nav_core::RecoveryBehavior> > recovery_behaviors_;
00112 unsigned int recovery_index_;
00113 bool recovery_behavior_enabled_ { true };
00114
00115
00116 double planner_frequency_ { 10.0 }, controller_frequency_ { 20.0 };
00117 ros::Duration desired_plan_duration_, desired_control_duration_;
00118 ros::Timer plan_loop_timer_, control_loop_timer_;
00119
00120
00121 locomotor::Executor local_planning_ex_, global_planning_ex_;
00122
00123
00124 bool has_global_plan_;
00125 double planner_patience_ { 5.0 }, controller_patience_ { 15.0 };
00126 ros::Time last_valid_plan_, last_valid_control_;
00127 int max_planning_retries_ {-1},
00128 planning_retries_;
00129
00130
00131 double oscillation_timeout_ {0.0}, oscillation_distance_{0.5};
00132 ros::Time last_oscillation_reset_;
00133 geometry_msgs::Pose2D oscillation_pose_;
00134
00135
00136 costmap_2d::Costmap2DROS* getCostmapPointer(const nav_core2::Costmap::Ptr& costmap);
00137 costmap_2d::Costmap2DROS* planner_costmap_ros_;
00138 costmap_2d::Costmap2DROS* controller_costmap_ros_;
00139
00140
00141 ros::Publisher goal_pub_;
00142 };
00143 }
00144
00145 #endif // LOCOMOVE_BASE_LOCOMOVE_BASE_H