Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include <planner_modules_pr2/navstack_planning_scene_module.h>
00009 #include <planner_modules_pr2/navstack_module.h>
00010 #include <planner_modules_pr2/module_param_cache.h>
00011 #include "tidyup_utils/planning_scene_interface.h"
00012 #include "tidyup_utils/stringutil.h"
00013 #include <nav_msgs/GetPlan.h>
00014 #include <geometry_msgs/PoseStamped.h>
00015 #include <map>
00016 #include <utility>
00017 using std::pair; using std::make_pair;
00018 #include <boost/foreach.hpp>
00019 #ifdef __CDT_PARSER__
00020 #define forEach(a, b) for(a : b)
00021 #else
00022 #define forEach BOOST_FOREACH
00023 #endif
00024 #include <sys/times.h>
00025 #include <ios>
00026 #include <string>
00027 #include <hardcoded_facts/geometryPoses.h>
00028
00029 using std::map;
00030 using namespace std;
00031
00032 int main(int argc, char* argv[])
00033 {
00034 if(argc != 3)
00035 {
00036 ROS_WARN("usage: plan_to_location_planning_scene <location_file> <location_name>");
00037 exit(0);
00038 }
00039
00040
00041 ros::init(argc, argv, "test_nav_planning_scene", ros::init_options::AnonymousName);
00042
00043 char* fake_argv[4];
00044 fake_argv[0] = "bla";
00045 fake_argv[1] = "/map";
00046 fake_argv[2] = "0.05";
00047 fake_argv[3] = "1";
00048 ROS_ASSERT_MSG(ros::param::has("/continual_planning_executive/door_location_file"), "Door location parameter missing: /continual_planning_executive/door_location_file");
00049
00050 planning_scene_navstack_init(4, fake_argv);
00051
00052
00053 string locationsFile = argv[1];
00054 string goalLocationName = argv[2];
00055 GeometryPoses locations = GeometryPoses();
00056 if (!locations.load(locationsFile))
00057 {
00058 ROS_ERROR("Could not load locations from \"%s\".", locationsFile.c_str());
00059 return -1;
00060 }
00061 const geometry_msgs::PoseStamped* poseStampedPtr = NULL;
00062 forEach(const GeometryPoses::NamedPose & np, locations.getPoses())
00063 {
00064 if(np.first == goalLocationName)
00065 {
00066 poseStampedPtr = &(np.second);
00067 break;
00068 }
00069 }
00070 if (poseStampedPtr == NULL)
00071 {
00072 ROS_ERROR("specified location \"%s\" not found in location file.", goalLocationName.c_str());
00073 return -1;
00074 }
00075
00076
00077 PlanningSceneInterface::instance()->resetPlanningScene();
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 double cost = 0;
00093
00094
00095 {
00096
00097 nav_msgs::GetPlan srv;
00098 srv.request.goal = *poseStampedPtr;
00099 bool serviceCallSuccessful = false;
00100 cost = callPlanningService(srv, "current_location", goalLocationName, serviceCallSuccessful);
00101 if (serviceCallSuccessful)
00102 {
00103
00104 }
00105 }
00106 if (cost < INFINITE_COST)
00107 ROS_INFO("Test SUCCESSFUL: found plan to location \"%s\". length: %0.2f", goalLocationName.c_str(), cost);
00108 else
00109 ROS_ERROR("Test FAILED: no plan to location \"%s\".", goalLocationName.c_str());
00110 }
00111