Robowflex  v0.1
Making MoveIt Easy
benchmarking.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston, Bryce Willey */
2 
3 #include <queue>
4 
5 #include <boost/lexical_cast.hpp>
6 #include <utility>
7 
8 #include <moveit/version.h>
9 
11 #include <robowflex_library/util.h>
14 #include <robowflex_library/io.h>
16 #include <robowflex_library/log.h>
20 
21 using namespace robowflex;
22 
23 ///
24 /// PlannerMetric
25 ///
26 
27 namespace
28 {
29  class toMetricStringVisitor : public boost::static_visitor<std::string>
30  {
31  public:
32  std::string operator()(int value) const
33  {
34  return std::to_string(boost::get<int>(value));
35  }
36 
37  std::string operator()(std::size_t value) const
38  {
39  return std::to_string(boost::get<std::size_t>(value));
40  }
41 
42  std::string operator()(double value) const
43  {
44  double v = boost::get<double>(value);
45 
46  // [Bad Pun] No NaNs, Infs, or buts about it.
47  return boost::lexical_cast<std::string>( //
49  }
50 
51  std::string operator()(bool value) const
52  {
53  return boost::lexical_cast<std::string>(boost::get<bool>(value));
54  }
55 
56  std::string operator()(std::string value) const
57  {
58  return boost::get<std::string>(value);
59  }
60  };
61 } // namespace
62 
64 {
65  return boost::apply_visitor(toMetricStringVisitor(), metric);
66 }
67 
68 ///
69 /// PlanningQuery
70 ///
71 
73  const SceneConstPtr &scene, //
74  const PlannerPtr &planner, //
76  : name(name), scene(scene), planner(planner), request(request)
77 {
78 }
79 
80 ///
81 /// PlanData
82 ///
83 
85  const std::string &yprop) const
86 {
88  for (const auto &point : progress)
89  {
90  auto xit = point.find(xprop);
91  if (xit == point.end())
92  break;
93 
94  const auto &xval = xit->second;
95  double xvald = boost::lexical_cast<double>(xval);
96 
97  const auto &yit = point.find(yprop);
98  if (yit == point.end())
99  break;
100 
101  const auto &yval = yit->second;
102  double yvald = boost::lexical_cast<double>(yval);
103 
104  if (std::isfinite(xvald) and std::isfinite(yvald))
105  ret.emplace_back(xvald, yvald);
106  }
107 
108  return ret;
109 }
110 
111 ///
112 /// PlanDataSet
113 ///
114 
115 void PlanDataSet::addDataPoint(const std::string &query_name, const PlanDataPtr &run)
116 {
117  auto it = data.find(query_name);
118  if (it == data.end())
119  data.emplace(query_name, std::vector<PlanDataPtr>{run});
120  else
121  it->second.emplace_back(run);
122 }
123 
125 {
127  for (const auto &query : data)
128  r.insert(r.end(), query.second.begin(), query.second.end());
129 
130  return r;
131 }
132 
133 ///
134 /// Profiler
135 ///
136 
137 bool Profiler::profilePlan(const PlannerPtr &planner, //
138  const SceneConstPtr &scene, //
139  const planning_interface::MotionPlanRequest &request, //
140  const Options &options, //
141  PlanData &result) const
142 {
143  bool complete = false;
144  std::mutex mutex;
145  std::shared_ptr<std::thread> progress_thread;
146 
147  result.query.scene = scene;
148  result.query.planner = planner;
149  result.query.request = request;
150 
151  result.start = IO::getDate();
152 
153  // Setup planner progress property thread
155  const auto &pp = planner->getProgressProperties(scene, request);
156  prog_props.insert(pp.begin(), pp.end());
157 
158  // Add custom progress properties
159  for (const auto &allocator : prog_allocators_)
160  prog_props.emplace(allocator.first, allocator.second(planner, scene, request));
161 
162  // Setup progress callbacks
164  prog_call.insert(prog_call.end(), prog_callbacks_.begin(), prog_callbacks_.end());
165 
166  for (const auto &allocator : prog_callback_allocators_)
167  prog_call.emplace_back(allocator(planner, scene, request));
168 
169  const bool have_prog = not prog_props.empty();
170  if (options.progress //
171  and (have_prog or not prog_call.empty()))
172  {
173  // Get names of progress properties
174  if (have_prog)
175  {
176  for (const auto &property : prog_props)
177  result.property_names.emplace_back(property.first);
178  result.property_names.emplace_back("time REAL");
179  }
180 
181  progress_thread.reset(new std::thread([&] {
182  bool at_least_once = options.progress_at_least_once;
183  while (true)
184  {
185  // Sleep until the next update
187 
188  std::unique_lock<std::mutex> lock(mutex);
189  if (not at_least_once and complete)
190  return;
191 
192  if (have_prog)
193  {
195 
196  // Add time stamp
197  double time = IO::getSeconds(result.start, IO::getDate());
198  data["time REAL"] = std::to_string(time);
199 
200  // Compute properties
201  for (const auto &property : prog_props)
202  data[property.first] = property.second();
203 
204  result.progress.emplace_back(data);
205  }
206 
207  for (const auto &callback : prog_call)
208  callback(planner, scene, request, result);
209 
210  at_least_once = false;
211  }
212  }));
213  }
214 
215  // Plan
216  result.response = planner->plan(scene, request);
217 
218  // Notify planner progress thread
219  {
220  std::unique_lock<std::mutex> lock(mutex);
221  complete = true;
222  }
223 
224  // Compute metrics and fill out results
225  result.finish = IO::getDate();
226  result.time = IO::getSeconds(result.start, result.finish);
227  result.success = result.response.error_code_.val == moveit_msgs::MoveItErrorCodes::SUCCESS;
228 
229  if (result.success)
230  result.trajectory = std::make_shared<Trajectory>(*result.response.trajectory_);
231 
232  result.hostname = IO::getHostname();
233  result.process_id = IO::getProcessID();
234  result.thread_id = IO::getThreadID();
235 
236  computeBuiltinMetrics(options.metrics, scene, result);
237  computeCallbackMetrics(planner, scene, request, result);
238 
239  if (progress_thread)
240  progress_thread->join();
241 
242  return result.success;
243 }
244 
246 {
247  callbacks_.emplace(name, metric);
248 }
249 
251 {
252  prog_allocators_.emplace(name, allocator);
253 }
254 
256 {
257  prog_callbacks_.emplace_back(callback);
258 }
259 
261 {
262  prog_callback_allocators_.emplace_back(allocator);
263 }
264 
265 void Profiler::computeBuiltinMetrics(uint32_t options, const SceneConstPtr &scene, PlanData &run) const
266 {
267  if (options & Metrics::WAYPOINTS)
268  run.metrics["waypoints"] = run.success ? int(run.trajectory->getNumWaypoints()) : int(0);
269 
270  if (options & Metrics::LENGTH)
271  run.metrics["length"] = run.success ? run.trajectory->getLength() : 0.0;
272 
273  if (options & Metrics::CORRECT)
274  run.metrics["correct"] = run.success ? run.trajectory->isCollisionFree(scene) : false;
275 
276  if (options & Metrics::CLEARANCE)
277  run.metrics["clearance"] = run.success ? std::get<0>(run.trajectory->getClearance(scene)) : 0.0;
278 
279  if (options & Metrics::SMOOTHNESS)
280  run.metrics["smoothness"] = run.success ? run.trajectory->getSmoothness() : 0.0;
281 
282  run.metrics["robowflex_planner_name"] = run.query.planner->getName();
283  run.metrics["robowflex_robot_name"] = run.query.planner->getRobot()->getName();
284 
285  run.metrics["request_planner_type"] = std::string(ROBOWFLEX_DEMANGLE(typeid(*run.query.planner).name()));
286  run.metrics["request_planner_id"] = run.query.request.planner_id;
287  run.metrics["request_group_name"] = run.query.request.group_name;
288  run.metrics["request_num_planning_attempts"] = run.query.request.num_planning_attempts;
289 
290  run.metrics["machine_hostname"] = run.hostname;
291  run.metrics["machine_thread_id"] = run.thread_id;
292  run.metrics["machine_process_id"] = run.process_id;
293 }
294 
296  const SceneConstPtr &scene, //
297  const planning_interface::MotionPlanRequest &request, //
298  PlanData &run) const
299 {
300  for (const auto &callback : callbacks_)
301  run.metrics[callback.first] = callback.second(planner, scene, request, run);
302 }
303 
304 ///
305 /// Experiment
306 ///
307 
308 Experiment::Experiment(const std::string &name, const Profiler::Options &options, //
309  double allowed_time, std::size_t trials, bool timeout)
310  : name_(name), allowed_time_(allowed_time), trials_(trials), timeout_(timeout), options_(options)
311 {
312 }
313 
314 void Experiment::addQuery(const std::string &planner_name, //
315  const SceneConstPtr &scene, //
316  const PlannerPtr &planner, //
318 {
319  queries_.emplace_back(planner_name, scene, planner, request);
320 }
321 
322 void Experiment::addQuery(const std::string &planner_name, //
323  const SceneConstPtr &scene, //
324  const PlannerPtr &planner, //
325  const MotionRequestBuilder &request)
326 {
327  addQuery(planner_name, scene, planner, request.getRequestConst());
328 }
329 
330 void Experiment::addQuery(const std::string &planner_name, //
331  const SceneConstPtr &scene, //
332  const PlannerPtr &planner, //
333  const MotionRequestBuilderPtr &request)
334 {
335  addQuery(planner_name, scene, planner, *request);
336 }
337 
339 {
340  return options_;
341 }
342 
344 {
345  return profiler_;
346 }
347 
349 {
350  return profiler_;
351 }
352 
354 {
355  return queries_;
356 }
357 
359 {
360  enforce_single_thread_ = false;
361 }
362 
364 {
365  override_planning_time_ = false;
366 }
367 
369 {
371 }
372 
374 {
376 }
377 
379 {
381 }
382 
384 {
385  // Setup dataset to return
386  auto dataset = std::make_shared<PlanDataSet>();
387  dataset->name = name_;
388  dataset->start = IO::getDate();
389  dataset->allowed_time = allowed_time_;
390  dataset->trials = trials_;
391  dataset->enforced_single_thread = enforce_single_thread_;
392  dataset->run_till_timeout = timeout_;
393  dataset->threads = n_threads;
394  dataset->queries = queries_;
395 
396  struct ThreadInfo
397  {
398  ThreadInfo() = default;
399  ThreadInfo(const PlanningQuery *query, std::size_t trial, std::size_t index)
400  : query(query), trial(trial), index(index)
401  {
402  }
403 
404  const PlanningQuery *query;
405  std::size_t trial;
406  std::size_t index;
407  };
408 
410  std::mutex mutex;
411 
412  for (std::size_t i = 0; i < queries_.size(); ++i)
413  {
414  const auto &query = queries_[i];
415 
416  // Check if this name is unique, if so, add it to dataset list.
417  const auto &it = std::find(dataset->query_names.begin(), dataset->query_names.end(), query.name);
418  if (it == dataset->query_names.end())
419  dataset->query_names.emplace_back(query.name);
420 
421  for (std::size_t j = 0; j < trials_; ++j)
422  todo.emplace(&query, j, i);
423  }
424 
426  std::size_t completed_queries = 0;
427  std::size_t total_queries = todo.size();
428 
429  for (std::size_t i = 0; i < n_threads; ++i)
430  threads.emplace_back(std::make_shared<std::thread>([&]() {
431  std::size_t id = IO::getThreadID();
432  while (true)
433  {
434  ThreadInfo info;
435 
436  {
437  std::unique_lock<std::mutex> lock(mutex);
438  if (todo.empty()) // All done, exit.
439  return;
440 
441  info = todo.front();
442  todo.pop();
443  }
444 
445  RBX_INFO("[Thread %1%] Running Query %3% `%2%` Trial [%4%/%5%]", //
446  id, info.query->name, info.index, info.trial + 1, trials_);
447 
448  // If override, use global time. Else use query time.
449  double time_remaining =
450  (override_planning_time_) ? allowed_time_ : info.query->request.allowed_planning_time;
451 
452  std::size_t timeout_trial = 0;
453  while (time_remaining > 0.)
454  {
455  planning_interface::MotionPlanRequest request = info.query->request;
456  request.allowed_planning_time = time_remaining;
457 
458  if (enforce_single_thread_)
459  request.num_planning_attempts = 1;
460 
461  // Call pre-run callbacks
462  info.query->planner->preRun(info.query->scene, request);
463 
464  if (pre_callback_)
465  pre_callback_(*info.query);
466 
467  // Profile query
468  auto data = std::make_shared<PlanData>();
469  profiler_.profilePlan(info.query->planner, //
470  info.query->scene, //
471  request, //
472  options_, //
473  *data);
474 
475  // Add experiment specific metrics
476  data->metrics.emplace("query_trial", (int)info.trial);
477  data->metrics.emplace("query_index", (int)info.index);
478  data->metrics.emplace("query_timeout_trial", (int)timeout_trial);
479  data->metrics.emplace("query_start_time", IO::getSeconds(dataset->start, data->start));
480  data->metrics.emplace("query_finish_time", IO::getSeconds(dataset->start, data->finish));
481 
482  data->query.name = log::format("%1%:%2%:%3%", info.query->name, info.trial, info.index);
483 
484  if (timeout_)
485  data->query.name = data->query.name + log::format(":%4%", timeout_trial);
486 
487  if (post_callback_)
488  post_callback_(*data, *info.query);
489 
490  {
491  std::unique_lock<std::mutex> lock(mutex);
492 
493  dataset->addDataPoint(info.query->name, data);
494  completed_queries++;
495 
496  if (complete_callback_)
497  complete_callback_(dataset, *info.query);
498  }
499 
500  if (timeout_)
501  {
502  time_remaining -= data->time;
503  RBX_INFO( //
504  "[Thread %1%] Running Query %3% `%2%` till timeout, %4% seconds remaining...", //
505  id, info.query->name, info.index, time_remaining);
506  timeout_trial++;
507  }
508  else
509  time_remaining = 0;
510  }
511 
512  RBX_INFO("[Thread %1%] Completed Query %3% `%2%` Trial [%4%/%5%] Total: [%6%/%7%]", //
513  id, info.query->name, info.index, //
514  info.trial + 1, trials_, //
515  completed_queries, total_queries);
516  }
517  }));
518 
519  for (const auto &thread : threads)
520  thread->join();
521 
522  dataset->finish = IO::getDate();
523  dataset->time = IO::getSeconds(dataset->start, dataset->finish);
524 
525  return dataset;
526 }
527 
528 ///
529 /// JSONPlanDataSetOutputter
530 ///
531 
532 JSONPlanDataSetOutputter::JSONPlanDataSetOutputter(const std::string &file) : file_(file)
533 {
534 }
535 
537 {
538  outfile_ << "}" << std::endl;
539  outfile_.close();
540 }
541 
543 {
544  if (not is_init_)
545  {
547  outfile_ << "{";
548  // TODO: output specific information about the scene and planner structs?
549 
550  is_init_ = true;
551  }
552  else
553  outfile_ << ",";
554 
555  outfile_ << "\"" << results.name << "\":[";
556 
557  const auto &data = results.getFlatData();
558 
559  for (size_t i = 0; i < data.size(); i++)
560  {
561  const auto &run = data[i];
562  outfile_ << "{";
563 
564  outfile_ << "\"name\": \"run_" << run->query.name << "\",";
565  outfile_ << "\"time\":" << run->time << ",";
566  outfile_ << "\"success\":" << run->success;
567 
568  for (const auto &metric : run->metrics)
569  outfile_ << ",\"" << metric.first << "\":" << toMetricString(metric.second);
570 
571  outfile_ << "}";
572 
573  // Write the command between each run.
574  if (i != data.size() - 1)
575  outfile_ << "," << std::endl;
576  }
577 
578  outfile_ << "]";
579 }
580 
581 ///
582 /// TrajectoryPlanDataSetOutputter
583 ///
584 
586  : file_(file), bag_(file_)
587 {
588 }
589 
591 {
592  const std::string &name = results.name;
593 
594  for (const auto &data : results.getFlatData())
595  if (data->trajectory)
596  bag_.addMessage(name, data->trajectory->getMessage());
597 }
598 
599 ///
600 /// OMPLPlanDataSetOutputter
601 ///
602 
604 {
605 }
606 
608 {
609 }
610 
612 {
613  std::ofstream out;
614  IO::createFile(out, log::format("%1%_%2%.log", prefix_, results.name));
615 
616  out << "MoveIt! version " << MOVEIT_VERSION << std::endl; // version
617  out << "Experiment " << results.name << std::endl; // experiment
618  out << "Running on " << IO::getHostname() << std::endl; // hostname
619  out << "Starting at " << results.start << std::endl; // date
620 
621  out << "<<<|" << std::endl;
622  out << "|>>>" << std::endl;
623 
624  // random seed (fake)
625  out << "0 is the random seed" << std::endl;
626 
627  // time limit
628  out << results.allowed_time << " seconds per run" << std::endl;
629 
630  // memory limit
631  out << "-1 MB per run" << std::endl;
632 
633  // num_runs
634  // out << results.data.size() << " runs per planner" << std::endl;
635 
636  // total_time
637  out << results.time << " seconds spent to collect the data" << std::endl;
638 
639  // num_enums / enums
640  out << "0 enum types" << std::endl;
641 
642  // num_planners
643  out << results.query_names.size() << " planners" << std::endl;
644 
645  // planners_data -> planner_data
646  for (const auto &name : results.query_names)
647  {
648  const auto &runs = results.data.find(name)->second;
649 
650  out << name << std::endl; // planner_name
651  out << "0 common properties" << std::endl;
652 
653  out << (runs[0]->metrics.size() + 2) << " properties for each run" << std::endl; // run_properties
654  out << "time REAL" << std::endl;
655  out << "success BOOLEAN" << std::endl;
656 
658  for (const auto &metric : runs[0]->metrics)
659  {
660  class ToString : public boost::static_visitor<const std::string>
661  {
662  public:
663  std::string operator()(int /* dummy */) const
664  {
665  return "INT";
666  }
667 
668  std::string operator()(std::size_t /* dummy */) const
669  {
670  return "BIGINT";
671  }
672 
673  std::string operator()(double /* dummy */) const
674  {
675  return "REAL";
676  }
677 
678  std::string operator()(bool /* dummy */) const
679  {
680  return "BOOLEAN";
681  }
682 
683  const std::string operator()(std::string /* dummy */) const
684  {
685  return "VARCHAR(128)";
686  }
687  };
688 
689  const auto &name = metric.first;
690  keys.emplace_back(name);
691 
692  out << name << " " << boost::apply_visitor(ToString(), metric.second) << std::endl;
693  }
694 
695  out << runs.size() << " runs" << std::endl;
696 
697  for (const auto &run : runs)
698  {
699  out << run->time << "; " //
700  << run->success << "; ";
701 
702  for (const auto &key : keys)
703  out << toMetricString(run->metrics.find(key)->second) << "; ";
704 
705  out << std::endl;
706  }
707 
708  const auto &progress_names = runs[0]->property_names;
709  if (not progress_names.empty())
710  {
711  out << progress_names.size() << " progress properties for each run" << std::endl;
712  for (const auto &name : progress_names)
713  out << name << std::endl;
714 
715  out << runs.size() << " runs" << std::endl;
716  for (const auto &run : runs)
717  {
718  for (const auto &point : run->progress)
719  {
720  for (const auto &name : progress_names)
721  {
722  auto it = point.find(name);
723  out << it->second << ",";
724  }
725 
726  out << ";";
727  }
728 
729  out << std::endl;
730  }
731  }
732 
733  out << "." << std::endl;
734  }
735 
736  out.close();
737 }
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...
bool addMessage(const std::string &topic, const T &msg)
Adds a message to the bag under topic.
Definition: bag.h:50
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
const planning_interface::MotionPlanRequest & getRequestConst() const
Get a const reference to the currently built motion planning request.
Definition: builder.cpp:538
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.
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::vector< PlanDataPtr > getFlatData() const
Get the full data set as a flat vector.
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::string name
Name of this dataset.
Definition: benchmarking.h:167
double time
Total computation time for entire dataset.
Definition: benchmarking.h:146
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.
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::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.
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.
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...
T close(T... args)
T emplace_back(T... args)
T emplace(T... args)
T empty(T... args)
T end(T... args)
T endl(T... args)
T find(T... args)
T insert(T... args)
T isfinite(T... args)
#define ROBOWFLEX_DEMANGLE(x)
Definition: macros.h:114
moveit_msgs::MotionPlanRequest MotionPlanRequest
double getSeconds(boost::posix_time::ptime start, boost::posix_time::ptime finish)
Get a duration in seconds from two times.
boost::posix_time::ptime getDate()
Get the current time (up to milliseconds)
std::size_t getProcessID()
Get the process ID of this process.
std::string getHostname()
Get the hostname of the system.
std::size_t getThreadID()
Get the thread ID of the current thread.
void createFile(std::ofstream &out, const std::string &file)
Creates a file and opens an output stream. Creates directories if they do not exist.
void threadSleep(double seconds)
Put the current thread to sleep for a desired amount of seconds.
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
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.
T reset(T... args)
T size(T... args)
moveit_msgs::MoveItErrorCodes error_code_
robot_trajectory::RobotTrajectoryPtr trajectory_
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
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
T to_string(T... args)