3 #include <vigir_footstep_planning_lib/helper.h> 4 #include <vigir_footstep_planning_lib/visualization/footstep_planning_vis.h> 6 #include <vigir_footstep_planning_plugins/plugins/state_generator_plugin.h> 7 #include <vigir_footstep_planning_plugins/plugins/robot_model_plugin.h> 8 #include <vigir_footstep_planning_plugins/plugins/step_plan_msg_plugin.h> 9 #include <vigir_footstep_planning_plugins/plugins/collision_check_plugin.h> 10 #include <vigir_footstep_planning_plugins/plugins/terrain_model_plugin.h> 22 vigir_pluginlib::PluginManager::addPluginClassLoader<StateGeneratorPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::StateGeneratorPlugin");
23 vigir_pluginlib::PluginManager::addPluginClassLoader<StepPlanMsgPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::StepPlanMsgPlugin");
24 vigir_pluginlib::PluginManager::addPluginClassLoader<ReachabilityPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::ReachabilityPlugin");
25 vigir_pluginlib::PluginManager::addPluginClassLoader<StepCostEstimatorPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::StepCostEstimatorPlugin");
26 vigir_pluginlib::PluginManager::addPluginClassLoader<HeuristicPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::HeuristicPlugin");
27 vigir_pluginlib::PluginManager::addPluginClassLoader<PostProcessPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::PostProcessPlugin");
28 vigir_pluginlib::PluginManager::addPluginClassLoader<CollisionCheckPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::CollisionCheckPlugin");
29 vigir_pluginlib::PluginManager::addPluginClassLoader<TerrainModelPlugin>(
"vigir_footstep_planning_plugins",
"vigir_footstep_planning::TerrainModelPlugin");
83 if (hasError(resp.status))
85 ROS_ERROR(
"[FootstepPlannerNode] Error while planning steps:\n%s", toString(resp.status).c_str());
88 else if (hasWarning(resp.status))
89 ROS_WARN(
"[FootstepPlannerNode] Warning occured:\n%s", toString(resp.status).c_str());
103 msgs::StepPlanRequestResult result;
105 result.step_plan = resp.step_plan;
106 result.status = resp.status;
107 result.final_eps = resp.final_eps;
108 result.planning_time = resp.planning_time;
113 if (hasError(resp.status))
115 ROS_ERROR(
"[FootstepPlannerNode] Error while planning steps:\n%s", toString(resp.status).c_str());
118 else if (hasWarning(resp.status))
119 ROS_WARN(
"[FootstepPlannerNode] Warning occured:\n%s", toString(resp.status).c_str());
136 msgs::StepPlanRequestFeedback fb;
137 fb.feedback = feedback;
138 as->publishFeedback(fb);
153 vigir_generic_params::ParameterSet params;
155 if (!ParameterManager::getParameterSet(params_name->data, params))
156 ROS_ERROR(
"[FootstepPlannerNode] setParams: Unknown parameter set '%s'!", params_name->data.c_str());
158 ROS_ERROR(
"[FootstepPlannerNode] setParams: Couldn't set parameter set '%s'!", params_name->data.c_str());
160 ParameterManager::setActive(params_name->data);
165 msgs::ErrorStatus status;
166 msgs::StepPlanRequestService::Request step_plan_request;
167 step_plan_request.plan_request = *plan_request;
170 if (step_plan_request.plan_request.start.header.frame_id.empty())
172 status += ErrorStatusWarning(msgs::ErrorStatus::WARN_UNKNOWN,
"FootstepPlannerNode",
"stepPlanRequest: No valid frame_id was given as start pose. Try to use current robot pose as start.");
173 status += determineStartFeetPose(step_plan_request.plan_request.start,
generate_feet_pose_client, step_plan_request.plan_request.header);
175 if (hasError(status))
177 ROS_WARN(
"[FootstepPlannerNode] Can't obtain start feet pose:\n%s", toString(status).c_str());
180 else if (hasWarning(status))
181 ROS_WARN(
"[FootstepPlannerNode] Warning occured while obtaining start feet pose:\n%s", toString(status).c_str());
191 ROS_INFO(
"[FootstepPlannerNode] stepPlanRequest:\n%s", toString(status).c_str());
197 msgs::Feet start_feet_pose;
203 if (hasError(status))
205 ROS_WARN(
"[FootstepPlannerNode] Can't obtain start feet pose:\n%s", toString(status).c_str());
208 else if (hasWarning(status))
209 ROS_WARN(
"[FootstepPlannerNode] Warning occured while obtaining start feet pose:\n%s", toString(status).c_str());
212 msgs::Feet goal_feet_pose;
213 goal_feet_pose.left.pose.position.z = goal_feet_pose.right.pose.position.z = start_feet_pose.left.pose.position.z;
216 if (hasError(status))
218 ROS_WARN(
"[FootstepPlannerNode] Can't obtain goal feet pose:\n%s", toString(status).c_str());
221 else if (hasWarning(status))
222 ROS_WARN(
"[FootstepPlannerNode] Warning occured while obtaining goal feet pose:\n%s", toString(status).c_str());
224 footstep_planner->updateFeet(goal_feet_pose, msgs::UpdateMode::UPDATE_MODE_MOVE_TO_VALID);
227 msgs::StepPlanRequestService::Request step_plan_request;
228 step_plan_request.plan_request.header = goal_pose->header;
229 step_plan_request.plan_request.start = start_feet_pose;
230 step_plan_request.plan_request.goal = goal_feet_pose;
231 step_plan_request.plan_request.start_step_index = 0;
232 step_plan_request.plan_request.start_foot_selection = msgs::StepPlanRequest::AUTO;
233 step_plan_request.plan_request.planning_mode = WorldModel::instance().isTerrainModelAvailable() ?
static_cast<uint8_t
>(msgs::StepPlanRequest::PLANNING_MODE_3D)
234 : static_cast<uint8_t>(msgs::StepPlanRequest::PLANNING_MODE_2D);
235 step_plan_request.plan_request.max_planning_time = 0.0;
236 step_plan_request.plan_request.max_number_steps = 0.0;
237 step_plan_request.plan_request.max_path_length_ratio = 0.0;
238 step_plan_request.plan_request.parameter_set_name.data = std::string();
248 ROS_INFO(
"[FootstepPlannerNode] goalPoseCallback:\n%s", toString(status).c_str());
256 if (req.plan_request.start.header.frame_id.empty())
258 resp.status += ErrorStatusWarning(msgs::ErrorStatus::WARN_UNKNOWN,
"FootstepPlannerNode",
"stepPlanRequestService: No valid frame_id was given as start pose. Try to use current robot pose as start.");
266 resp.status += ErrorStatusError(msgs::ErrorStatus::ERR_UNKNOWN,
"FootstepPlannerNode",
"stepPlanRequestService: Can't call footstep planner service!");
277 resp.foot = req.foot;
278 resp.status =
footstep_planner->updateFoot(resp.foot, req.update_mode.mode);
284 resp.feet = req.feet;
285 resp.status =
footstep_planner->updateFeet(resp.feet, req.update_mode.mode);
291 resp.step_plan = req.step_plan;
292 resp.status =
footstep_planner->updateStepPlan(resp.step_plan, req.update_mode.mode, req.parameter_set_name.data);
307 const msgs::StepPlanRequestGoalConstPtr&
goal(as->acceptNewGoal());
310 if (as->isPreemptRequested())
316 msgs::ErrorStatus status;
317 msgs::StepPlanRequestService::Request step_plan_request;
318 step_plan_request.plan_request =
goal->plan_request;
321 if (step_plan_request.plan_request.start.header.frame_id.empty())
323 status += ErrorStatusWarning(msgs::ErrorStatus::WARN_UNKNOWN,
"FootstepPlannerNode",
"stepPlanRequestAction: No valid frame_id was given as start pose. Try to use current robot pose as start.");
324 status += determineStartFeetPose(step_plan_request.plan_request.start,
generate_feet_pose_client, step_plan_request.plan_request.header);
335 ROS_INFO(
"[FootstepPlannerNode] stepPlanRequest:\n%s", toString(status).c_str());
351 const msgs::UpdateFootGoalConstPtr&
goal(as->acceptNewGoal());
354 if (as->isPreemptRequested())
360 msgs::UpdateFootResult result;
361 result.foot =
goal->foot;
369 const msgs::UpdateFeetGoalConstPtr&
goal(as->acceptNewGoal());
372 if (as->isPreemptRequested())
378 msgs::UpdateFeetResult result;
379 result.feet =
goal->feet;
387 const msgs::UpdateStepPlanGoalConstPtr&
goal(as->acceptNewGoal());
390 if (as->isPreemptRequested())
396 msgs::UpdateStepPlanResult result;
398 result.step_plan =
goal->step_plan;
399 result.status =
footstep_planner->updateStepPlan(result.step_plan,
goal->update_mode.mode,
goal->parameter_set_name.data);
406 int main(
int argc,
char** argv)
408 ros::init(argc, argv,
"vigir_footstep_planner");
417 vigir_generic_params::ParameterManager::initialize(nh);
418 vigir_pluginlib::PluginManager::initialize(nh);
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ROSCPP_DECL void spin(Spinner &spinner)
const std::string & getNamespace() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)