|
| 1 | +/* Author: Constantinos Chamzas */ |
| 2 | + |
| 3 | +// Robowflex |
| 4 | +#include <robowflex_library/util.h> |
| 5 | +#include <robowflex_library/geometry.h> |
| 6 | +#include <robowflex_library/robot.h> |
| 7 | +#include <robowflex_library/scene.h> |
| 8 | +#include <robowflex_library/planning.h> |
| 9 | +#include <robowflex_library/builder.h> |
| 10 | +#include <robowflex_library/benchmarking.h> |
| 11 | +#include <robowflex_library/detail/fetch.h> |
| 12 | + |
| 13 | +using namespace robowflex; |
| 14 | + |
| 15 | +static const std::string GROUP = "arm_with_torso"; |
| 16 | + |
| 17 | +int main(int argc, char **argv) |
| 18 | +{ |
| 19 | + // Startup ROS |
| 20 | + ROS ros(argc, argv); |
| 21 | + |
| 22 | + // Create the default Fetch robot. |
| 23 | + auto fetch = std::make_shared<FetchRobot>(); |
| 24 | + fetch->initialize(); |
| 25 | + |
| 26 | + // Setup a benchmarking request for the joint and pose motion plan requests. |
| 27 | + Benchmarker benchmark; |
| 28 | + |
| 29 | + int start = 1; |
| 30 | + int end = 10; |
| 31 | + for (int i = start; i <= end; i++) |
| 32 | + { |
| 33 | + std::stringstream ss; |
| 34 | + // (pre-appending 4 leading zeros) |
| 35 | + ss << std::setw(4) << std::setfill('0') << i; |
| 36 | + std::string index = ss.str(); |
| 37 | + |
| 38 | + auto fscene = "package://robowflex_library/yaml/fetch_scenes/scene_vicon" + index + ".yaml"; |
| 39 | + |
| 40 | + // Create an empty Scene. |
| 41 | + auto scene = std::make_shared<Scene>(fetch); |
| 42 | + |
| 43 | + if (!scene->fromYAMLFile(fscene)) |
| 44 | + { |
| 45 | + ROS_ERROR("Failed to read file: %s for scene", fscene.c_str()); |
| 46 | + continue; |
| 47 | + } |
| 48 | + |
| 49 | + // Create the default planner for the Fetch. |
| 50 | + auto planner = std::make_shared<OMPL::FetchOMPLPipelinePlanner>(fetch, "default"); |
| 51 | + planner->initialize(); |
| 52 | + |
| 53 | + // Create an empty motion planning request. |
| 54 | + auto request = std::make_shared<robowflex::MotionRequestBuilder>(planner, GROUP); |
| 55 | + |
| 56 | + auto frequest = "package://robowflex_library/yaml/fetch_scenes/request" + index + ".yaml"; |
| 57 | + |
| 58 | + if (!request->fromYAMLFile(frequest)) |
| 59 | + { |
| 60 | + ROS_ERROR("Failed to read file: %s for request", frequest.c_str()); |
| 61 | + continue; |
| 62 | + } |
| 63 | + // modify the planning request here |
| 64 | + request->setNumPlanningAttempts(1); |
| 65 | + request->setAllowedPlanningTime(10); |
| 66 | + |
| 67 | + // Add benchmarking request |
| 68 | + benchmark.addBenchmarkingRequest("result" + index, scene, planner, request); |
| 69 | + } |
| 70 | + |
| 71 | + // How many times to solve each problem |
| 72 | + int reps = 2; |
| 73 | + // 0b001101 disables costly metrics(some crash if no plan is found) |
| 74 | + auto options = Benchmarker::Options(reps, 0b001101); |
| 75 | + std::string bpath = ros::package::getPath("robowflex_library") + "/yaml/benchmark/"; |
| 76 | + benchmark.benchmark({std::make_shared<OMPLBenchmarkOutputter>(bpath)}, options); |
| 77 | +} |
0 commit comments