Go to the documentation of this file.00001 #include "tidyup_actions/actionExecutorDriveThroughDoor.h"
00002 #include <pluginlib/class_list_macros.h>
00003 #include "tidyup_utils/planning_scene_interface.h"
00004
00005 PLUGINLIB_DECLARE_CLASS(tidyup_actions, action_executor_drive_through_door,
00006 tidyup_actions::ActionExecutorDriveThroughDoor,
00007 continual_planning_executive::ActionExecutorInterface)
00008
00009 namespace tidyup_actions
00010 {
00011
00012 bool ActionExecutorDriveThroughDoor::fillGoal(move_base_msgs::MoveBaseGoal & goal,
00013 const DurativeAction & a, const SymbolicState & current)
00014 {
00015 if(!PlanningSceneInterface::instance()->resetPlanningScene())
00016 ROS_ERROR("%s: PlanningScene reset failed.", __PRETTY_FUNCTION__);
00017
00018 goal.target_pose.header.stamp = ros::Time::now();
00019
00020 ROS_ASSERT(a.parameters.size() == 3);
00021 string door = a.parameters[0];
00022 string start_location = a.parameters[1];
00023 string goal_location = a.parameters[2];
00024
00025
00026 Predicate p;
00027 p.parameters.push_back(goal_location);
00028 p.name = "frame-id";
00029 if(!current.hasObjectFluent(p, &goal.target_pose.header.frame_id))
00030 return false;
00031 p.name = "x";
00032 if(!current.hasNumericalFluent(p, &goal.target_pose.pose.position.x))
00033 return false;
00034 p.name = "y";
00035 if(!current.hasNumericalFluent(p, &goal.target_pose.pose.position.y))
00036 return false;
00037 p.name = "z";
00038 if(!current.hasNumericalFluent(p, &goal.target_pose.pose.position.z))
00039 return false;
00040 p.name = "qx";
00041 if(!current.hasNumericalFluent(p, &goal.target_pose.pose.orientation.x))
00042 return false;
00043 p.name = "qy";
00044 if(!current.hasNumericalFluent(p, &goal.target_pose.pose.orientation.y))
00045 return false;
00046 p.name = "qz";
00047 if(!current.hasNumericalFluent(p, &goal.target_pose.pose.orientation.z))
00048 return false;
00049 p.name = "qw";
00050 if(!current.hasNumericalFluent(p, &goal.target_pose.pose.orientation.w))
00051 return false;
00052
00053 ROS_INFO_STREAM("Created goal for ActionExecutorROSNavigation as: " << goal);
00054
00055 return true;
00056 }
00057
00058 void ActionExecutorDriveThroughDoor::updateState(const actionlib::SimpleClientGoalState & actionReturnState,
00059 const move_base_msgs::MoveBaseResult & result,
00060 const DurativeAction & a, SymbolicState & current)
00061 {
00062 ROS_INFO("MoveBase returned result");
00063 ROS_ASSERT(a.parameters.size() == 3);
00064 string door = a.parameters[0];
00065 string start_location = a.parameters[1];
00066 string goal_location = a.parameters[2];
00067 if(actionReturnState == actionlib::SimpleClientGoalState::SUCCEEDED) {
00068 ROS_INFO("MoveBase succeeded.");
00069 current.setBooleanPredicate("at-base", start_location, false);
00070 current.setBooleanPredicate("at-base", goal_location, true);
00071 string goal_room = "unknown_room";
00072 Predicate p;
00073 p.name = "location-in-room";
00074 p.parameters.push_back(goal_location);
00075 if(current.hasObjectFluent(p, &goal_room))
00076 current.setObjectFluent("location-in-room", "robot_location", goal_room);
00077 }
00078 current.setBooleanPredicate("door-state-known", door, false);
00079 }
00080
00081 };
00082