Go to the documentation of this file.00001 #include "planner_navigation_actions/goalCreatorROSNavigation.h"
00002 #include <pluginlib/class_list_macros.h>
00003 #include "hardcoded_facts/geometryPoses.h"
00004 #include <ros/ros.h>
00005
00006 PLUGINLIB_DECLARE_CLASS(planner_navigation_actions, goal_creator_ros_navigation,
00007 planner_navigation_actions::GoalCreatorROSNavigation, continual_planning_executive::GoalCreator)
00008
00009 namespace planner_navigation_actions
00010 {
00011
00012 GoalCreatorROSNavigation::GoalCreatorROSNavigation()
00013 {
00014 }
00015
00016 GoalCreatorROSNavigation::~GoalCreatorROSNavigation()
00017 {
00018 }
00019
00020 bool GoalCreatorROSNavigation::fillStateAndGoal(SymbolicState & currentState, SymbolicState & goal)
00021 {
00022 ros::NodeHandle nhPriv("~");
00023
00024
00025 std::string goalLocationsFile;
00026 if(!nhPriv.getParam("goal_locations", goalLocationsFile)) {
00027 ROS_ERROR("Could not get ~goal_locations parameter.");
00028 return false;
00029 }
00030 GeometryPoses goalLocations;
00031 if(!goalLocations.load(goalLocationsFile)) {
00032 ROS_ERROR("Could not load goal locations from \"%s\".", goalLocationsFile.c_str());
00033 return false;
00034 }
00035
00036 const std::map<std::string, geometry_msgs::PoseStamped> & goalPoses = goalLocations.getPoses();
00037 forEach(const GeometryPoses::NamedPose & np, goalPoses) {
00038 currentState.addObject(np.first, "target");
00039 goal.addObject(np.first, "target");
00040
00041 currentState.setNumericalFluent("timestamp", np.first, np.second.header.stamp.toSec());
00042 currentState.addObject(np.second.header.frame_id, "frameid");
00043 currentState.setObjectFluent("frame-id", np.first, np.second.header.frame_id);
00044 currentState.setNumericalFluent("x", np.first, np.second.pose.position.x);
00045 currentState.setNumericalFluent("y", np.first, np.second.pose.position.y);
00046 currentState.setNumericalFluent("z", np.first, np.second.pose.position.z);
00047 currentState.setNumericalFluent("qx", np.first, np.second.pose.orientation.x);
00048 currentState.setNumericalFluent("qy", np.first, np.second.pose.orientation.y);
00049 currentState.setNumericalFluent("qz", np.first, np.second.pose.orientation.z);
00050 currentState.setNumericalFluent("qw", np.first, np.second.pose.orientation.w);
00051 currentState.setBooleanPredicate("explored", np.first.c_str(), false);
00052 goal.setBooleanPredicate("explored", np.first.c_str(), true);
00053 }
00054
00055 return true;
00056 }
00057
00058 };
00059