Robowflex  v0.1
Making MoveIt Easy
benchmarking.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef ROBOWFLEX_BENCHMARKING_
4 #define ROBOWFLEX_BENCHMARKING_
5 
6 #include <cstdint>
7 #include <string>
8 #include <vector>
9 #include <tuple>
10 #include <map>
11 #include <fstream>
12 
13 #include <boost/variant.hpp>
14 
15 #include <moveit_msgs/RobotTrajectory.h>
16 
17 #include <moveit/planning_interface/planning_response.h>
18 
22 
23 namespace robowflex
24 {
25  /** \cond IGNORE */
27  ROBOWFLEX_CLASS_FORWARD(Trajectory);
28  ROBOWFLEX_CLASS_FORWARD(MotionRequestBuilder);
29  /** \endcond */
30 
31  /** \brief Variant type of possible values a run metric could be.
32  */
33  using PlannerMetric = boost::variant<bool, double, int, std::size_t, std::string>;
34 
35  /** \brief Convert a planner metric into a string.
36  * \param[in] metric The metric to convert.
37  * \return The metric as a string.
38  */
40 
41  /** \brief A container structure for all elements needed in a planning query, plus an identifying name.
42  */
44  {
45  /** \brief Empty constructor.
46  */
47  PlanningQuery() = default;
48 
49  /** \brief Constructor. Fills in fields.
50  * \param[in] name Name of this query.
51  * \param[in] scene Scene to use.
52  * \param[in] planner Planner to use to evaluate query.
53  * \param[in] request Request to give planner.
54  */
55  PlanningQuery(const std::string &name, //
56  const SceneConstPtr &scene, //
57  const PlannerPtr &planner, //
59 
60  std::string name; ///< Name of this query.
61  SceneConstPtr scene; ///< Scene used for the query.
62  PlannerPtr planner; ///< Planner used for the query.
63  planning_interface::MotionPlanRequest request; ///< Request used for the query.
64  };
65 
66  /** \cond IGNORE */
68  /** \endcond */
69 
70  /** \class robowflex::PlanDataPtr
71  \brief A shared pointer wrapper for robowflex::PlanData. */
72 
73  /** \class robowflex::PlanDataConstPtr
74  \brief A const shared pointer wrapper for robowflex::PlanData. */
75 
76  /** \brief Detailed statistics and metrics computed from profiling a planner's motion planning.
77  */
78  class PlanData
79  {
80  public:
81  /** \name Planning Query and Response
82  \{ */
83 
84  PlanningQuery query; ///< Query evaluated to create this data.
86  bool success; ///< Was the plan successful?
87  TrajectoryPtr trajectory; ///< The resulting trajectory, if available.
88 
89  /** \} */
90 
91  /** \name Timing
92  \{ */
93 
94  double time; ///< Time that planning took in seconds.
95  boost::posix_time::ptime start; ///< Query start time.
96  boost::posix_time::ptime finish; ///< Query end time.
97 
98  /** \} */
99 
100  /** \name Host Metadata
101  \{ */
102 
103  std::string hostname; ///< Hostname of the machine the plan was run on.
104  std::size_t process_id; ///< Process ID of the process the profiler was run in.
105  std::size_t thread_id; ///< Thread ID of profiler execution.
106 
107  /** \} */
108 
109  /** \name Metrics and Progress Properties
110  \{ */
111 
112  std::vector<std::string> property_names; ///< Planner progress value names.
114  std::map<std::string, PlannerMetric> metrics; ///< Map of metric name to value.
115 
116  /** \brief Retrieves the time series data of a planner progress property for a given X-,Y- pair of
117  * progress properties. Will ignore a point if either value is non-finite.
118  * \param[in] xprop The property for the first coordinate.
119  * \param[in] yprop The property for the second coordinate.
120  * \return A vector of the points.
121  */
123  const std::string &yprop) const;
124 
125  /** \} */
126  };
127 
128  /** \cond IGNORE */
130  /** \endcond */
131 
132  /** \class robowflex::PlanDataSetPtr
133  \brief A shared pointer wrapper for robowflex::PlanDataSet. */
134 
135  /** \class robowflex::PlanDataSetConstPtr
136  \brief A const shared pointer wrapper for robowflex::PlanDataSet. */
137 
138  /** \brief Detailed statistics about a benchmark of multiple queries.
139  */
141  {
142  public:
143  /** \name Timing
144  \{ */
145 
146  double time; ///< Total computation time for entire dataset.
147  boost::posix_time::ptime start; ///< Start time of dataset computation.
148  boost::posix_time::ptime finish; ///< End time for dataset computation.
149 
150  /** \} */
151 
152  /** \name Experiment Parameters
153  \{ */
154 
155  double allowed_time; ///< Allowed planning time used per query.
156  std::size_t trials; ///< Requested trials for each query.
157  bool enforced_single_thread; ///< If true, all planners were asked to run in single-threaded mode.
158  bool run_till_timeout; ///< If true, planners were run to solve the problem as many times as possible
159  ///< until time ran out.
160  std::size_t threads; ///< Threads used for dataset computation.
161 
162  /** \} */
163 
164  /** \name Query Information
165  \{ */
166 
167  std::string name; ///< Name of this dataset.
168  std::vector<std::string> query_names; ///< All unique names used by planning queries.
169  std::vector<PlanningQuery> queries; ///< All planning queries. Note that planning queries can share
170  ///< the same name.
171 
172  /** \} */
173 
174  /** \name Data
175  \{ */
176 
177  std::map<std::string, std::vector<PlanDataPtr>> data; ///< Map of query name to collected data.
178 
179  /** \brief Add a computed plan data under a query as a data point.
180  * \param[in] query_name Name of query to store point under.
181  * \param[in] run Run data to add to query.
182  */
183  void addDataPoint(const std::string &query_name, const PlanDataPtr &run);
184 
185  /** \brief Get the full data set as a flat vector.
186  * \return All plan data as a vector.
187  */
189 
190  /** \} */
191  };
192 
193  /** \cond IGNORE */
195  /** \endcond */
196 
197  /** \class robowflex::ProfilerPtr
198  \brief A shared pointer wrapper for robowflex::Profiler. */
199 
200  /** \class robowflex::ProfilerConstPtr
201  \brief A const shared pointer wrapper for robowflex::Profiler. */
202 
203  class Profiler
204  {
205  public:
206  /** \brief Bitmask options to select what metrics to compute for each run.
207  */
208  enum Metrics
209  {
210  WAYPOINTS = 1 << 0, ///< Number of waypoints in path.
211  CORRECT = 1 << 1, ///< Is the path correct (no collisions?).
212  LENGTH = 1 << 2, ///< Length of the path.
213  CLEARANCE = 1 << 3, ///< Clearance of path from obstacles.
214  SMOOTHNESS = 1 << 4, ///< Smoothness of path.
215  };
216 
217  /** \brief Options for profiling.
218  */
219  struct Options
220  {
221  uint32_t metrics{0xffffffff}; ///< Bitmask of which metrics to compute after planning.
222  bool progress{true}; ///< If true, captures planner progress properties (if they exist).
223  bool progress_at_least_once{true}; ///< If true, will always run the progress loop at least once.
224  double progress_update_rate{0.1}; ///< Update rate for progress callbacks.
225  };
226 
227  /** \brief Type for callback function that returns a metric over the results of a planning query.
228  * \param[in] planner The planner being profiled.
229  * \param[in] scene The scene used for planning.
230  * \param[in] request The planning request.
231  * \param[in] run The results of the planning run, including prior computed metrics.
232  * \return The value of this metric. Will be stored in run data under associated name.
233  */
235  std::function<PlannerMetric(const PlannerPtr &planner, //
236  const SceneConstPtr &scene, //
237  const planning_interface::MotionPlanRequest &request, //
238  const PlanData &run)>;
239 
240  /** \brief Allocator function that returns a planner progress property function for the
241  * current planning request.
242  * \param[in] planner The planner being profiled.
243  * \param[in] scene The scene used for planning.
244  * \param[in] request The planning request.
245  * \return A planner progress property function.
246  */
249  const SceneConstPtr &scene, //
250  const planning_interface::MotionPlanRequest &request)>;
251 
252  /** \brief Type for callback function that is called in the planner progress property loop.
253  * \param[in] planner The planner being profiled.
254  * \param[in] scene The scene used for planning.
255  * \param[in] request The planning request.
256  * \param[in] run The results of the planning run, including prior computed metrics.
257  */
258  using ProgressCallback = std::function<void(const PlannerPtr &planner, //
259  const SceneConstPtr &scene, //
260  const planning_interface::MotionPlanRequest &request, //
261  const PlanData &result)>;
262 
263  /** \brief Allocator function that returns a progress property callback function for the
264  * current planning request.
265  * \param[in] planner The planner being profiled.
266  * \param[in] scene The scene used for planning.
267  * \param[in] request The planning request.
268  * \return A progress callback function.
269  */
271  std::function<ProgressCallback(const PlannerPtr &planner, //
272  const SceneConstPtr &scene, //
273  const planning_interface::MotionPlanRequest &request)>;
274 
275  /** \brief Profiling a single plan using a \a planner.
276  * \param[in] planner Planner to profile.
277  * \param[in] scene Scene to plan in.
278  * \param[in] request Planning request to profile.
279  * \param[in] options The options for profiling.
280  * \param[out] result The results of profiling.
281  * \return True if planning succeeded, false on failure.
282  */
283  bool profilePlan(const PlannerPtr &planner, //
284  const SceneConstPtr &scene, //
285  const planning_interface::MotionPlanRequest &request, //
286  const Options &options, //
287  PlanData &result) const;
288 
289  /** \brief Add a callback function to compute a metric at the end of planning.
290  * \param[in] name Name of the metric.
291  * \param[in] metric Function to use for callback.
292  */
293  void addMetricCallback(const std::string &name, const ComputeMetricCallback &metric);
294 
295  /** \brief Add a function that allocates a function that returns a planner progress property function.
296  * \param[in] name Name of the planner progress property.
297  * \param[in] allocator Allocator function.
298  */
299  void addProgressAllocator(const std::string &name, const ProgressPropertyAllocator &allocator);
300 
301  /** \brief Add a function that is called in the planner progress property loop.
302  * \param[in] callback Callback function to add.
303  */
305 
306  /** \brief Add a function that is called in the planner progress property loop.
307  * \param[in] callback Callback function to add.
308  */
310 
311  private:
312  /** \brief Compute the built-in metrics according to the provided bitmask \a options.
313  * \param[in] options Bitmask of which built-in metrics to compute.
314  * \param[in] scene Scene used for planning and metric computation.
315  * \param[out] run Metric results.
316  */
317  void computeBuiltinMetrics(uint32_t options, const SceneConstPtr &scene, PlanData &run) const;
318 
319  /** \brief Compute the custom user callback metrics.
320  * \param[in] planner Planner used.
321  * \param[in] scene Scene used for planning.
322  * \param[in] request Planning request.
323  * \param[out] run Metric results.
324  */
325  void computeCallbackMetrics(const PlannerPtr &planner, //
326  const SceneConstPtr &scene, //
327  const planning_interface::MotionPlanRequest &request, //
328  PlanData &run) const;
329 
332  std::vector<ProgressCallback> prog_callbacks_; ///< User progress callback functions.
334  ///< function allocators.
335  };
336 
337  /** \cond IGNORE */
339  /** \endcond */
340 
341  /** \class robowflex::ExperimentPtr
342  \brief A shared pointer wrapper for robowflex::Experiment. */
343 
344  /** \class robowflex::ExperimentConstPtr
345  \brief A const shared pointer wrapper for robowflex::Experiment. */
346 
347  /** \brief A helper class for benchmarking that controls running multiple queries*/
349  {
350  public:
351  /** \name Building Experiment
352  \{ */
353 
354  /** \brief Constructor.
355  * \param[in] name Name of this experiment.
356  * \param[in] options Options for the internal profiler.
357  * \param[in] allowed_time Total planning time allowed for each query.
358  * \param[in] trials Number of trials to run each query for.
359  * \param[in] timeout If true, will re-run each query until the total time taken has exceeded the
360  * allotted time.
361  */
362  Experiment(const std::string &name, //
363  const Profiler::Options &options, //
364  double allowed_time = 60.0, //
365  std::size_t trials = 100, //
366  bool timeout = false);
367 
368  /** \brief Add a query to the experiment for profiling.
369  * \param[in] planner_name Name to associate with this query. Does not need to be unique.
370  * \param[in] scene Scene to use for query.
371  * \param[in] planner Planner to use for query.
372  * \param[in] request Request to use for query.
373  */
374  void addQuery(const std::string &planner_name, //
375  const SceneConstPtr &scene, //
376  const PlannerPtr &planner, //
378 
379  /** \brief Add a query to the experiment for profiling.
380  * \param[in] planner_name Name to associate with this query. Does not need to be unique.
381  * \param[in] scene Scene to use for query.
382  * \param[in] planner Planner to use for query.
383  * \param[in] request Request to use for query.
384  */
385  void addQuery(const std::string &planner_name, //
386  const SceneConstPtr &scene, //
387  const PlannerPtr &planner, //
388  const MotionRequestBuilder &request);
389 
390  /** \brief Add a query to the experiment for profiling.
391  * \param[in] planner_name Name to associate with this query. Does not need to be unique.
392  * \param[in] scene Scene to use for query.
393  * \param[in] planner Planner to use for query.
394  * \param[in] request Request to use for query.
395  */
396  void addQuery(const std::string &planner_name, //
397  const SceneConstPtr &scene, //
398  const PlannerPtr &planner, //
399  const MotionRequestBuilderPtr &request);
400 
401  /** \} */
402 
403  /** \name Configuration, Getters, Setters
404  \{ */
405 
406  /** \brief Get the options used by the underlying profiler.
407  * \return A reference to the options used.
408  */
410 
411  /** \brief Get a reference to the profiler used by the experiment. Add callback functions to this
412  * profiler for custom metrics.
413  * \return The profiler.
414  */
416 
417  /** \brief Get a reference to the profiler used by the experiment.
418  * \return The profiler.
419  */
420  const Profiler &getProfilerConst() const;
421 
422  /** \brief Get the queries added to this experiment.
423  * \return The queries added to the experiment.
424  */
425  const std::vector<PlanningQuery> &getQueries() const;
426 
427  /** \brief If called, will enable planners to use multiple threads. By default, planners are requested
428  * to only use one thread.
429  */
430  void enableMultipleRequests();
431 
432  /** \brief If called, instead of using global allotted planning time (provided in the constructor),
433  * the benchmark will use the requested planning time in the planning request of the query.
434  */
435  void overridePlanningTime();
436 
437  /** \} */
438 
439  /** \name Callback Functions
440  \{ */
441 
442  /** \brief A callback function that is called before every query is profiled.
443  * \param[in] query The query to be profiled.
444  */
445  using PreRunCallback = std::function<void(const PlanningQuery &query)>;
446 
447  /** \brief A callback function that is called after every query is profiled.
448  * \param[in,out] result The result computed by the profiler.
449  * \param[in] query The query that was profiled.
450  */
451  using PostRunCallback = std::function<void(PlanData &result, const PlanningQuery &query)>;
452 
453  /** A callback function that is called after a result is added to the dataset.
454  * \param[in,out], dataset The dataset so far.
455  * \param[in] query The query that was just profiled.
456  */
457  using PostQueryCallback = std::function<void(PlanDataSetPtr dataset, const PlanningQuery &query)>;
458 
459  /** \brief Set the pre-query callback function.
460  * \param[in] callback Callback to use.
461  */
463 
464  /** \brief Set the post-query callback function.
465  * \param[in] callback Callback to use.
466  */
468 
469  /** \brief Set the post-dataset callback function.
470  * \param[in] callback Callback to use.
471  */
473 
474  /** \} */
475 
476  /** \brief Run benchmarking on this experiment.
477  * Note that, for some planners, multiple threads cannot be used without polluting the dataset, due
478  * to reuse of underlying datastructures between queries, e.g., the robowflex_ompl planner.
479  * \param[in] n_threads Number of threads to use for benchmarking.
480  * \return The computed dataset.
481  */
482  PlanDataSetPtr benchmark(std::size_t n_threads = 1) const;
483 
484  private:
485  const std::string name_; ///< Name of this experiment.
486  double allowed_time_; ///< Allotted time to use for each query.
487  std::size_t trials_; ///< Number of trials to run each query for.
488  bool timeout_; ///< If true, will re-run planners on queries until total time taken has exceeded the
489  ///< allotted time.
490  bool enforce_single_thread_{true}; ///< If true, will request each planner to only use a single
491  ///< thread.
492  bool override_planning_time_{true}; ///< If true, will override request planning time with global
493  ///< allowed time.
494 
495  Profiler::Options options_; ///< Options for profiler.
496  Profiler profiler_; ///< Profiler to use for extracting data.
497  std::vector<PlanningQuery> queries_; ///< Queries to test.
498 
499  PreRunCallback pre_callback_; ///< Pre-run callback.
500  PostRunCallback post_callback_; ///< Post-run callback.
501  PostQueryCallback complete_callback_; ///< Post-run callback with dataset.
502  };
503 
504  /** \brief An abstract class for outputting benchmark results.
505  */
507  {
508  public:
509  /** \brief Virtual destructor for cleaning up resources.
510  */
511  virtual ~PlanDataSetOutputter() = default;
512 
513  /** \brief Write the \a results of a benchmarking query out.
514  * Must be implemented by child classes.
515  * \param[in] results The results of one query of benchmarking.
516  */
517  virtual void dump(const PlanDataSet &results) = 0;
518  };
519 
520  /** \brief A benchmark outputter for storing data in a single JSON file.
521  */
523  {
524  public:
525  /** \brief Constructor.
526  * \param[in] file Filename to save results to.
527  */
529 
530  /** \brief Destructor. Closes \a outfile_.
531  */
532  ~JSONPlanDataSetOutputter() override;
533 
534  /** \brief Dumps \a results into \a outfile_, and opens \a outfile_ if not already done so.
535  * \param[in] results Results to dump to file.
536  */
537  void dump(const PlanDataSet &results) override;
538 
539  private:
540  bool is_init_{false}; ///< Have we initialized the outputter (on first result)?
541  const std::string file_; ///< Filename to open.
542  std::ofstream outfile_; ///< Output stream.
543  };
544 
545  /** \brief Benchmark outputter that saves each trajectory from each run to a rosbag file.
546  */
548  {
549  public:
550  /** \brief Constructor.
551  * \param[in] file Filename for rosbag.
552  */
554 
555  /** \brief Dumps all trajectories in \a results to rosbag file \a file_.
556  * The topic the trajectories are saved under is the \a name_ in \a results, or the name of the
557  * request.
558  * \param[in] results Results to dump to file.
559  */
560  void dump(const PlanDataSet &results) override;
561 
562  private:
563  const std::string file_; ///< Filename.
564  IO::Bag bag_; ///< Rosbag handler.
565  };
566 
567  /** \brief Benchmark outputter that saves results into OMPL benchmarking log files. If
568  * `ompl_benchmark_statistics.py` is available in your PATH variable, the results are also compiled into a
569  * database file.
570  */
572  {
573  public:
574  /** \brief Constructor.
575  * \param[in] prefix Prefix to place in front of all log files generated.
576  * \param[in] dumpScene If true, will output scene into log file.
577  */
578  OMPLPlanDataSetOutputter(const std::string &prefix);
579 
580  /** \brief Destructor, runs `ompl_benchmark_statistics.py` to generate benchmarking database.
581  */
582  ~OMPLPlanDataSetOutputter() override;
583 
584  /** \brief Dumps \a results into a OMPL benchmarking log file in \a prefix_ named after the request \a
585  * name_.
586  * \param[in] results Results to dump to file.
587  */
588  void dump(const PlanDataSet &results) override;
589 
590  private:
591  const std::string prefix_; ///< Log file prefix.
592  };
593 } // namespace robowflex
594 
595 #endif
#define ROBOWFLEX_CLASS_FORWARD(C)
Macro that forward declares a class and defines two shared ptrs types:
Definition: class_forward.h:16
A helper class for benchmarking that controls running multiple queries.
Definition: benchmarking.h:349
void setPostRunCallback(const PostRunCallback &callback)
Set the post-query callback function.
std::vector< PlanningQuery > queries_
Queries to test.
Definition: benchmarking.h:497
Profiler::Options & getOptions()
Get the options used by the underlying profiler.
void setPostQueryCallback(const PostQueryCallback &callback)
Set the post-dataset callback function.
const std::vector< PlanningQuery > & getQueries() const
Get the queries added to this experiment.
PreRunCallback pre_callback_
Pre-run callback.
Definition: benchmarking.h:499
std::size_t trials_
Number of trials to run each query for.
Definition: benchmarking.h:487
Profiler profiler_
Profiler to use for extracting data.
Definition: benchmarking.h:496
Profiler::Options options_
Options for profiler.
Definition: benchmarking.h:495
PostRunCallback post_callback_
Post-run callback.
Definition: benchmarking.h:500
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...
double allowed_time_
Allotted time to use for each query.
Definition: benchmarking.h:486
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.
void overridePlanningTime()
If called, instead of using global allotted planning time (provided in the constructor),...
void setPreRunCallback(const PreRunCallback &callback)
Set the pre-query callback function.
const Profiler & getProfilerConst() const
Get a reference to the profiler used by the experiment.
const std::string name_
Name of this experiment.
Definition: benchmarking.h:485
Experiment(const std::string &name, const Profiler::Options &options, double allowed_time=60.0, std::size_t trials=100, bool timeout=false)
Constructor.
Profiler & getProfiler()
Get a reference to the profiler used by the experiment. Add callback functions to this profiler for c...
PostQueryCallback complete_callback_
Post-run callback with dataset.
Definition: benchmarking.h:501
void enableMultipleRequests()
If called, will enable planners to use multiple threads. By default, planners are requested to only u...
rosbag management class to ease message saving and loading.
Definition: bag.h:23
A benchmark outputter for storing data in a single JSON file.
Definition: benchmarking.h:523
JSONPlanDataSetOutputter(const std::string &file)
Constructor.
bool is_init_
Have we initialized the outputter (on first result)?
Definition: benchmarking.h:540
~JSONPlanDataSetOutputter() override
Destructor. Closes outfile_.
const std::string file_
Filename to open.
Definition: benchmarking.h:541
std::ofstream outfile_
Output stream.
Definition: benchmarking.h:542
void dump(const PlanDataSet &results) override
Dumps results into outfile_, and opens outfile_ if not already done so.
A shared pointer wrapper for robowflex::MotionRequestBuilder.
A helper class to build motion planning requests for a robowflex::Planner.
Definition: builder.h:34
Benchmark outputter that saves results into OMPL benchmarking log files. If ompl_benchmark_statistics...
Definition: benchmarking.h:572
const std::string prefix_
Log file prefix.
Definition: benchmarking.h:591
OMPLPlanDataSetOutputter(const std::string &prefix)
Constructor.
~OMPLPlanDataSetOutputter() override
Destructor, runs ompl_benchmark_statistics.py to generate benchmarking database.
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::PlanData.
An abstract class for outputting benchmark results.
Definition: benchmarking.h:507
virtual void dump(const PlanDataSet &results)=0
Write the results of a benchmarking query out. Must be implemented by child classes.
virtual ~PlanDataSetOutputter()=default
Virtual destructor for cleaning up resources.
A shared pointer wrapper for robowflex::PlanDataSet.
Detailed statistics about a benchmark of multiple queries.
Definition: benchmarking.h:141
std::map< std::string, std::vector< PlanDataPtr > > data
Map of query name to collected data.
Definition: benchmarking.h:177
boost::posix_time::ptime start
Start time of dataset computation.
Definition: benchmarking.h:147
void addDataPoint(const std::string &query_name, const PlanDataPtr &run)
Add a computed plan data under a query as a data point.
std::size_t threads
Threads used for dataset computation.
Definition: benchmarking.h:160
std::vector< PlanDataPtr > getFlatData() const
Get the full data set as a flat vector.
boost::posix_time::ptime finish
End time for dataset computation.
Definition: benchmarking.h:148
std::vector< std::string > query_names
All unique names used by planning queries.
Definition: benchmarking.h:168
double allowed_time
Allowed planning time used per query.
Definition: benchmarking.h:155
std::size_t trials
Requested trials for each query.
Definition: benchmarking.h:156
std::vector< PlanningQuery > queries
Definition: benchmarking.h:169
std::string name
Name of this dataset.
Definition: benchmarking.h:167
double time
Total computation time for entire dataset.
Definition: benchmarking.h:146
bool enforced_single_thread
If true, all planners were asked to run in single-threaded mode.
Definition: benchmarking.h:157
Detailed statistics and metrics computed from profiling a planner's motion planning.
Definition: benchmarking.h:79
std::vector< std::pair< double, double > > getProgressPropertiesAsPoints(const std::string &xprop, const std::string &yprop) const
Retrieves the time series data of a planner progress property for a given X-,Y- pair of progress prop...
std::size_t process_id
Process ID of the process the profiler was run in.
Definition: benchmarking.h:104
boost::posix_time::ptime finish
Query end time.
Definition: benchmarking.h:96
std::vector< std::string > property_names
Planner progress value names.
Definition: benchmarking.h:112
planning_interface::MotionPlanResponse response
Planner response.
Definition: benchmarking.h:85
bool success
Was the plan successful?
Definition: benchmarking.h:86
PlanningQuery query
Query evaluated to create this data.
Definition: benchmarking.h:84
TrajectoryPtr trajectory
The resulting trajectory, if available.
Definition: benchmarking.h:87
std::map< std::string, PlannerMetric > metrics
Map of metric name to value.
Definition: benchmarking.h:114
std::vector< std::map< std::string, std::string > > progress
Planner progress data.
Definition: benchmarking.h:113
std::size_t thread_id
Thread ID of profiler execution.
Definition: benchmarking.h:105
boost::posix_time::ptime start
Query start time.
Definition: benchmarking.h:95
double time
Time that planning took in seconds.
Definition: benchmarking.h:94
std::string hostname
Hostname of the machine the plan was run on.
Definition: benchmarking.h:103
A shared pointer wrapper for robowflex::Planner.
std::function< std::string()> ProgressProperty
A function that returns the value of a planner property over the course of a run.
void addProgressCallbackAllocator(const ProgressCallbackAllocator &allocator)
Add a function that is called in the planner progress property loop.
std::map< std::string, ProgressPropertyAllocator > prog_allocators_
User progress properties.
Definition: benchmarking.h:331
void computeBuiltinMetrics(uint32_t options, const SceneConstPtr &scene, PlanData &run) const
Compute the built-in metrics according to the provided bitmask options.
void addProgressCallback(const ProgressCallback &callback)
Add a function that is called in the planner progress property loop.
std::function< void(const PlannerPtr &planner, const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request, const PlanData &result)> ProgressCallback
Type for callback function that is called in the planner progress property loop.
Definition: benchmarking.h:261
std::map< std::string, ComputeMetricCallback > callbacks_
User callback metrics.
Definition: benchmarking.h:330
std::vector< ProgressCallbackAllocator > prog_callback_allocators_
Definition: benchmarking.h:333
void addMetricCallback(const std::string &name, const ComputeMetricCallback &metric)
Add a callback function to compute a metric at the end of planning.
Metrics
Bitmask options to select what metrics to compute for each run.
Definition: benchmarking.h:209
@ CLEARANCE
Clearance of path from obstacles.
Definition: benchmarking.h:213
@ 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
void computeCallbackMetrics(const PlannerPtr &planner, const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request, PlanData &run) const
Compute the custom user callback metrics.
void addProgressAllocator(const std::string &name, const ProgressPropertyAllocator &allocator)
Add a function that allocates a function that returns a planner progress property function.
bool profilePlan(const PlannerPtr &planner, const SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request, const Options &options, PlanData &result) const
Profiling a single plan using a planner.
std::vector< ProgressCallback > prog_callbacks_
User progress callback functions.
Definition: benchmarking.h:332
A const shared pointer wrapper for robowflex::Scene.
Benchmark outputter that saves each trajectory from each run to a rosbag file.
Definition: benchmarking.h:548
TrajectoryPlanDataSetOutputter(const std::string &file)
Constructor.
void dump(const PlanDataSet &results) override
Dumps all trajectories in results to rosbag file file_. The topic the trajectories are saved under is...
const std::string file_
Filename.
Definition: benchmarking.h:563
A shared pointer wrapper for robowflex::Trajectory.
moveit_msgs::MotionPlanRequest MotionPlanRequest
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
std::string toMetricString(const PlannerMetric &metric)
Convert a planner metric into a string.
boost::variant< bool, double, int, std::size_t, std::string > PlannerMetric
Variant type of possible values a run metric could be.
Definition: benchmarking.h:33
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
planning_interface::MotionPlanRequest request
Request used for the query.
Definition: benchmarking.h:63
PlanningQuery()=default
Empty constructor.
SceneConstPtr scene
Scene used for the query.
Definition: benchmarking.h:61
std::string name
Name of this query.
Definition: benchmarking.h:60
PlannerPtr planner
Planner used for the query.
Definition: benchmarking.h:62
Options for profiling.
Definition: benchmarking.h:220
bool progress
If true, captures planner progress properties (if they exist).
Definition: benchmarking.h:222
bool progress_at_least_once
If true, will always run the progress loop at least once.
Definition: benchmarking.h:223
double progress_update_rate
Update rate for progress callbacks.
Definition: benchmarking.h:224
uint32_t metrics
Bitmask of which metrics to compute after planning.
Definition: benchmarking.h:221
void callback(movegroup::MoveGroupHelper::Action &action)
Definition: tapedeck.cpp:20