19 ros::NodeHandle nh(client_->name_);
25 ROS_INFO(
"[PlannerSwitcher] Planner Switcher: Trying to set BackwardPlanner");
33 ROS_INFO(
"[PlannerSwitcher] Planner Switcher: Trying to set BackwardPlanner");
41 ROS_INFO(
"[PlannerSwitcher] Planner Switcher: Trying to set BackwardPlanner");
49 ROS_INFO(
"[PlannerSwitcher] Planner Switcher: Trying to set ForwardPlanner");
58 ROS_INFO(
"[PlannerSwitcher] Planner Switcher: Trying to set PureSpinningPlanner");
76 dynamic_reconfigure::ReconfigureRequest srv_req;
77 dynamic_reconfigure::ReconfigureResponse srv_resp;
78 dynamic_reconfigure::StrParameter local_planner, global_planner;
79 dynamic_reconfigure::Config conf;
81 local_planner.name =
"base_local_planner";
83 conf.strs.push_back(local_planner);
85 global_planner.name =
"base_global_planner";
87 conf.strs.push_back(global_planner);
89 srv_req.config = conf;
90 ROS_INFO(
"setting values of the dynamic reconfigure server");
94 bool res = ros::service::call(
"/move_base/set_parameters", srv_req, srv_resp);
96 ros::Duration(0.5).sleep();
99 auto baselocalPlannerIt = std::find_if(srv_resp.config.strs.begin(), srv_resp.config.strs.end(), [](
auto sp){return sp.name ==
"base_local_planner";});
100 auto baseglobalPlannerIt = std::find_if(srv_resp.config.strs.begin(), srv_resp.config.strs.end(), [](
auto sp){return sp.name ==
"base_global_planner";});
102 auto updatedLocalPlanner = baselocalPlannerIt->value;
103 auto updatedGlobalPlanner = baseglobalPlannerIt->value;
104 ROS_INFO_STREAM(
"[PlannerSwitcher] Selected base local planner: " << updatedLocalPlanner);
105 ROS_INFO_STREAM(
"[PlannerSwitcher] Selected base global planner: " << updatedGlobalPlanner);
109 ROS_WARN(
"[PlannerSwitcher] Planners not correctly configured. Waiting 1 second and retrying...");
110 ROS_INFO_STREAM(
"[PlannerSwitcher] Response: " << srv_resp);
120 auto gp = std::find_if(configuration_update->strs.begin(), configuration_update->strs.begin(),
121 [&](
const dynamic_reconfigure::StrParameter &p) {
122 return p.name ==
"base_global_planner" && p.value == desired_global_planner_;
125 auto lp = std::find_if(configuration_update->strs.begin(), configuration_update->strs.begin(),
126 [&](
const dynamic_reconfigure::StrParameter &p) {
127 return p.name ==
"base_local_planner" && p.value == desired_local_planner_;
130 if (gp == configuration_update->strs.end() || lp == configuration_update->strs.end())
132 ROS_INFO(
"[PlannerSwitcher] After planner update it is noticed an incorrect move_base planner configuration. Resending request.");
138 ROS_INFO(
"[PlannerSwitcher] Planners correctly configured according to parameter update callback");
void setPureSpinningPlanner()
void updatePlanners(bool subscribecallback=true)
virtual void onInitialize() override
void setUndoPathPureSpinningPlannerConfiguration()
void setBackwardPlanner()
bool set_planners_mode_flag
std::string desired_local_planner_
void setUndoPathBackwardsPlannerConfiguration()
void setDefaultPlanners()
void dynreconfCallback(const dynamic_reconfigure::Config::ConstPtr &configuration_update)
ros::Subscriber dynrecofSub_
std::string desired_global_planner_