actionExecutorDetectDoorStateAngle.cpp
Go to the documentation of this file.
00001 #include "tidyup_actions/actionExecutorDetectDoorStateAngle.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_detect_door_state_angle,
00006         tidyup_actions::ActionExecutorDetectDoorStateAngle,
00007         continual_planning_executive::ActionExecutorInterface)
00008 
00009 double ANGLE_EPSILON = 10 / 180.0 * 3.1415;
00010 
00011 namespace tidyup_actions
00012 {
00013 
00014     void ActionExecutorDetectDoorStateAngle::initialize(const std::deque<std::string> & arguments)
00015     {
00016         ActionExecutorService<door_perception_msgs::DoorStateSrv>::initialize(arguments);
00017     }
00018 
00019     bool ActionExecutorDetectDoorStateAngle::fillGoal(door_perception_msgs::DoorStateSrv::Request & goal,
00020             const DurativeAction & a, const SymbolicState & current)
00021     {
00022         if(!PlanningSceneInterface::instance()->resetPlanningScene())   // FIXME try anyways?
00023             ROS_ERROR("%s: PlanningScene reset failed.", __PRETTY_FUNCTION__);
00024 
00025         return true;
00026     }
00027 
00028     void ActionExecutorDetectDoorStateAngle::updateState(bool success, door_perception_msgs::DoorStateSrv::Response & response,
00029             const DurativeAction & a, SymbolicState & current)
00030     {
00031         ROS_INFO("DetectDoorStateAngle returned result");
00032         if(success) {
00033             ROS_INFO("DetectDoorStateAngle succeeded, door_found is: %d, angle is: %f.", response.state.door_found, response.state.angle);
00034             ROS_ASSERT(a.parameters.size() == 2);
00035             string location = a.parameters[0];
00036             string door = a.parameters[1];
00037             bool open = false;
00038             if(!response.state.door_found) {
00039                 open = true;
00040                 ROS_INFO("No door found - assuming it is open.");
00041             } else {
00042                 if(response.state.angle >= response.state.DOOR_OPEN_ANGLE - ANGLE_EPSILON) {
00043                     open = true;
00044                     ROS_INFO("Angle was %f > %f - Door is open.", response.state.angle, response.state.DOOR_OPEN_ANGLE);
00045                 } else if(response.state.angle <= response.state.DOOR_CLOSED_ANGLE + ANGLE_EPSILON) {
00046                     open = false;
00047                     ROS_INFO("Angle was %f < %f - Door is closed.", response.state.angle, response.state.DOOR_CLOSED_ANGLE+ANGLE_EPSILON);
00048                 } else {
00049                     ROS_ERROR("Angle was %f - Unidentified door state - assuming it is closed!", response.state.angle);
00050                     open = false;
00051                 }
00052             }
00053             current.setBooleanPredicate("door-state-known", door, true);
00054             current.setBooleanPredicate("door-open", door, open);
00055         }
00056     }
00057 
00058 };
00059 
 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