Robowflex  v0.1
Making MoveIt Easy
fetch_benchmark.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 /* Modified by: Juan D. Hernandez */
3 
9 
11 
12 using namespace robowflex;
13 
14 /* \file fetch_benchmark.cpp
15  * A basic script that demonstrates benchmarking with the Fetch robot.
16  * Benchmarking output is saved in the OMPL format. See
17  * https://ompl.kavrakilab.org/benchmark.html for more information on the
18  * benchmark data format and how to use. http://plannerarena.org/ can be used to
19  * visualize results.
20  * Note: This script requires GNUPlot for live visualization of timing data.
21  */
22 
23 static const std::string GROUP = "arm_with_torso";
24 
25 int main(int argc, char **argv)
26 {
27  // Startup ROS
28  ROS ros(argc, argv);
29 
30  // Create the default Fetch robot.
31  auto fetch = std::make_shared<FetchRobot>();
32  fetch->initialize();
33 
34  // Create an empty scene.
35  auto scene = std::make_shared<Scene>(fetch);
36 
37  // Create the default planner for the Fetch.
38  auto planner = std::make_shared<OMPL::FetchOMPLPipelinePlanner>(fetch, "default");
39  planner->initialize();
40 
41  // Setup a benchmarking request for the joint and pose motion plan requests.
42  Profiler::Options options;
44  Experiment experiment("unfurl", // Name of experiment
45  options, // Options for internal profiler
46  5.0, // Timeout allowed for ALL queries
47  100); // Number of trials
48 
49  // Create a motion planning request with a pose goal.
50  auto request = std::make_shared<MotionRequestBuilder>(planner, GROUP);
51  fetch->setGroupState(GROUP, {0.05, 1.32, 1.40, -0.2, 1.72, 0.0, 1.66, 0.0}); // Stow
52  request->setStartConfiguration(fetch->getScratchState());
53 
54  fetch->setGroupState(GROUP, {0.265, 0.501, 1.281, -2.272, 2.243, -2.774, 0.976, -2.007}); // Unfurl
55  request->setGoalConfiguration(fetch->getScratchState());
56 
57  request->setConfig("RRTConnect");
58  experiment.addQuery("rrtconnect", scene, planner, request->getRequest());
59 
60  request->setConfig("RRT");
61  experiment.addQuery("rrt", scene, planner, request->getRequest());
62 
63  request->setConfig("PRM");
64  experiment.addQuery("prm", scene, planner, request->getRequest());
65 
66  request->setConfig("KPIECE");
67  experiment.addQuery("kpiece", scene, planner, request->getRequest());
68 
69  request->setConfig("BKPIECE");
70  experiment.addQuery("bkpiece", scene, planner, request->getRequest());
71 
72  request->setConfig("LBKPIECE");
73  experiment.addQuery("lbkpiece", scene, planner, request->getRequest());
74 
75  request->setConfig("EST");
76  experiment.addQuery("est", scene, planner, request->getRequest());
77 
78  // Use the post-query callback to visualize the data live.
80  experiment.setPostQueryCallback(
81  [&](PlanDataSetPtr dataset, const PlanningQuery &) { plot.dump(*dataset); });
82 
83  auto dataset = experiment.benchmark(4);
84 
85  OMPLPlanDataSetOutputter output("robowflex_fetch_demo");
86  output.dump(*dataset);
87 
88  return 0;
89 }
A helper class for benchmarking that controls running multiple queries.
Definition: benchmarking.h:349
void setPostQueryCallback(const PostQueryCallback &callback)
Set the post-dataset callback function.
PlanDataSetPtr benchmark(std::size_t n_threads=1) const
Run benchmarking on this experiment. Note that, for some planners, multiple threads cannot be used wi...
void addQuery(const std::string &planner_name, const SceneConstPtr &scene, const PlannerPtr &planner, const planning_interface::MotionPlanRequest &request)
Add a query to the experiment for profiling.
Helper class to plot a real metric as a box plot using GNUPlot from benchmarking data.
Definition: gnuplot.h:129
void dump(const PlanDataSet &results) override
Visualize results.
Definition: gnuplot.cpp:181
Benchmark outputter that saves results into OMPL benchmarking log files. If ompl_benchmark_statistics...
Definition: benchmarking.h:572
void dump(const PlanDataSet &results) override
Dumps results into a OMPL benchmarking log file in prefix_ named after the request name_.
A shared pointer wrapper for robowflex::PlanDataSet.
@ WAYPOINTS
Number of waypoints in path.
Definition: benchmarking.h:210
@ SMOOTHNESS
Smoothness of path.
Definition: benchmarking.h:214
@ CORRECT
Is the path correct (no collisions?).
Definition: benchmarking.h:211
@ LENGTH
Length of the path.
Definition: benchmarking.h:212
RAII-pattern for starting up ROS.
Definition: util.h:52
int main(int argc, char **argv)
static const std::string GROUP
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
Functions for loading and animating scenes in Blender.
A container structure for all elements needed in a planning query, plus an identifying name.
Definition: benchmarking.h:44
Options for profiling.
Definition: benchmarking.h:220
uint32_t metrics
Bitmask of which metrics to compute after planning.
Definition: benchmarking.h:221