Robowflex  v0.1
Making MoveIt Easy
fetch_scenes_benchmark.cpp
Go to the documentation of this file.
1 /* Author: Constantinos Chamzas */
2 
3 // Robowflex
10 #include <robowflex_library/util.h>
11 
12 using namespace robowflex;
13 
14 /* \file fetch_scenes_benchmark.cpp
15  * A script that demonstrates benchmarking over a number of scenes and planning
16  * requests for the Fetch robot. A number of example scene and planning request
17  * pairs are included in 'package://robowflex_library/yaml/fetch_scenes'. This
18  * script sets up benchmarking for all of these pairs. See
19  * `fetch_scenes_visualize.cpp` to visualize these scenes.
20  *
21  * Benchmarking output is saved in the OMPL format. See
22  * https://ompl.kavrakilab.org/benchmark.html for more information on the
23  * benchmark data format and how to use. http://plannerarena.org/ can be used to
24  * visualize results.
25  */
26 
27 static const std::string GROUP = "arm_with_torso";
28 
29 int main(int argc, char **argv)
30 {
31  // Startup ROS
32  ROS ros(argc, argv);
33 
34  // Create the default Fetch robot.
35  auto fetch = std::make_shared<FetchRobot>();
36 
37  // Do not add the virtual joint since the real robot does not have one.
38  fetch->initialize(false);
39 
40  // Setup a benchmarking request for the joint and pose motion plan requests.
41  Profiler::Options options;
43  Experiment experiment("fetch_scenes", options, 10.0, 10);
44 
45  const std::size_t start = 1;
46  const std::size_t end = 10;
47  for (std::size_t i = start; i <= end; i++)
48  {
49  const auto &scene_file =
50  log::format("package://robowflex_library/yaml/fetch_scenes/scene_vicon%1$04d.yaml", i);
51  const auto &request_file =
52  log::format("package://robowflex_library/yaml/fetch_scenes/request%1$04d.yaml", i);
53 
54  // Create an empty Scene.
55  auto scene = std::make_shared<Scene>(fetch);
56  if (not scene->fromYAMLFile(scene_file))
57  {
58  RBX_ERROR("Failed to read file: %s for scene", scene_file);
59  continue;
60  }
61 
62  // Create the default planner for the Fetch.
63  auto planner = std::make_shared<OMPL::FetchOMPLPipelinePlanner>(fetch);
64 
65  // Disable simplification
66  auto settings = OMPL::Settings();
67  settings.simplify_solutions = false;
68 
69  planner->initialize(settings);
70 
71  // Create an empty motion planning request.
72  auto request = std::make_shared<robowflex::MotionRequestBuilder>(planner, GROUP);
73  if (not request->fromYAMLFile(request_file))
74  {
75  RBX_ERROR("Failed to read file: %s for request", request_file);
76  continue;
77  }
78 
79  // Add request
80  experiment.addQuery("vicon", scene, planner, request);
81  }
82 
83  auto dataset = experiment.benchmark(4);
84 
85  OMPLPlanDataSetOutputter output("robowflex");
86  output.dump(*dataset);
87 
88  return 0;
89 }
A helper class for benchmarking that controls running multiple queries.
Definition: benchmarking.h:349
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.
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_.
Settings descriptor for settings provided by the default MoveIt! OMPL planning pipeline.
@ WAYPOINTS
Number of waypoints in path.
Definition: benchmarking.h:210
@ 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
#define RBX_ERROR(fmt,...)
Output a error logging message.
Definition: log.h:102
std::string format(const std::string &fmt, Args &&... args)
Recursion base case, return string form of formatted arguments.
Definition: log.h:60
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
Functions for loading and animating scenes in Blender.
Options for profiling.
Definition: benchmarking.h:220
uint32_t metrics
Bitmask of which metrics to compute after planning.
Definition: benchmarking.h:221