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