actionExecutorWipe.cpp
Go to the documentation of this file.
00001 #include "tidyup_actions/actionExecutorWipe.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_wipe,
00006         tidyup_actions::ActionExecutorWipe,
00007         continual_planning_executive::ActionExecutorInterface)
00008 
00009 namespace tidyup_actions
00010 {
00011 
00012     void ActionExecutorWipe::initialize(const std::deque<std::string> & arguments)
00013     {
00014         ActionExecutorService<coverage_3d_srvs::CleanSpot>::initialize(arguments);
00015     }
00016 
00017     bool ActionExecutorWipe::fillGoal(coverage_3d_srvs::CleanSpot::Request & goal,
00018             const DurativeAction & a, const SymbolicState & current)
00019     {
00020         if(!PlanningSceneInterface::instance()->resetPlanningScene())   // FIXME try anyways?
00021             ROS_ERROR("%s: PlanningScene reset failed.", __PRETTY_FUNCTION__);
00022 
00023         goal.box_size = 0.2;
00024 
00025         // get spot from state
00026         ROS_ASSERT(a.parameters.size() == 4);
00027         string location = a.parameters[0];
00028         string wipe_point = a.parameters[1];
00029         string static_object = a.parameters[2];
00030         string arm = a.parameters[3];
00031 
00032         Predicate p;
00033         p.parameters.push_back(wipe_point);
00034         p.name = "frame-id";
00035         if(!current.hasObjectFluent(p, &goal.spot.header.frame_id))
00036             return false;
00037         p.name = "x";
00038         if(!current.hasNumericalFluent(p, &goal.spot.point.x))
00039             return false;
00040         p.name = "y";
00041         if(!current.hasNumericalFluent(p, &goal.spot.point.y))
00042             return false;
00043         p.name = "z";
00044         if(!current.hasNumericalFluent(p, &goal.spot.point.z))
00045             return false;
00046 
00047         ROS_INFO_STREAM("Created goal for ActionExecutorWipe at: " << goal.spot);
00048 
00049         return true;
00050     }
00051 
00052     void ActionExecutorWipe::updateState(bool success, coverage_3d_srvs::CleanSpot::Response & response,
00053             const DurativeAction & a, SymbolicState & current)
00054     {
00055         ROS_INFO("Wipe returned result");
00056 
00057         ROS_ASSERT(a.parameters.size() == 4);
00058         string location = a.parameters[0];
00059         string wipe_point = a.parameters[1];
00060         string static_object = a.parameters[2];
00061         string arm = a.parameters[3];
00062 
00063         if(success) {
00064             ROS_INFO("wiping %s on %s with %s succeeded.", wipe_point.c_str(), static_object.c_str(), arm.c_str());
00065             current.setBooleanPredicate("wiped", wipe_point, true);
00066         } else {
00067             ROS_ERROR("wiping %s on %s with %s FAILED.", wipe_point.c_str(), static_object.c_str(), arm.c_str());
00068         }
00069         current.setObjectFluent("arm-state", arm, "arm_unknown");
00070     }
00071 
00072 };
00073 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


tidyup_actions
Author(s): Christian Dornhege, Andreas Hertle
autogenerated on Wed Dec 26 2012 16:11:46