3 #ifndef ROBOWFLEX_BENCHMARKING_
4 #define ROBOWFLEX_BENCHMARKING_
13 #include <boost/variant.hpp>
15 #include <moveit_msgs/RobotTrajectory.h>
17 #include <moveit/planning_interface/planning_response.h>
33 using PlannerMetric = boost::variant<bool, double, int, std::size_t, std::string>;
364 double allowed_time = 60.0,
366 bool timeout =
false);
#define ROBOWFLEX_CLASS_FORWARD(C)
Macro that forward declares a class and defines two shared ptrs types:
A helper class for benchmarking that controls running multiple queries.
void setPostRunCallback(const PostRunCallback &callback)
Set the post-query callback function.
std::vector< PlanningQuery > queries_
Queries to test.
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.
std::size_t trials_
Number of trials to run each query for.
bool enforce_single_thread_
Profiler profiler_
Profiler to use for extracting data.
Profiler::Options options_
Options for profiler.
PostRunCallback post_callback_
Post-run callback.
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.
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.
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.
void enableMultipleRequests()
If called, will enable planners to use multiple threads. By default, planners are requested to only u...
bool override_planning_time_
rosbag management class to ease message saving and loading.
A benchmark outputter for storing data in a single JSON file.
JSONPlanDataSetOutputter(const std::string &file)
Constructor.
bool is_init_
Have we initialized the outputter (on first result)?
~JSONPlanDataSetOutputter() override
Destructor. Closes outfile_.
const std::string file_
Filename to open.
std::ofstream outfile_
Output stream.
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.
Benchmark outputter that saves results into OMPL benchmarking log files. If ompl_benchmark_statistics...
const std::string prefix_
Log file prefix.
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.
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.
std::map< std::string, std::vector< PlanDataPtr > > data
Map of query name to collected data.
boost::posix_time::ptime start
Start time of dataset computation.
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.
std::vector< PlanDataPtr > getFlatData() const
Get the full data set as a flat vector.
boost::posix_time::ptime finish
End time for dataset computation.
std::vector< std::string > query_names
All unique names used by planning queries.
double allowed_time
Allowed planning time used per query.
std::size_t trials
Requested trials for each query.
std::vector< PlanningQuery > queries
std::string name
Name of this dataset.
double time
Total computation time for entire dataset.
bool enforced_single_thread
If true, all planners were asked to run in single-threaded mode.
Detailed statistics and metrics computed from profiling a planner's motion planning.
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.
boost::posix_time::ptime finish
Query end time.
std::vector< std::string > property_names
Planner progress value names.
planning_interface::MotionPlanResponse response
Planner response.
bool success
Was the plan successful?
PlanningQuery query
Query evaluated to create this data.
TrajectoryPtr trajectory
The resulting trajectory, if available.
std::map< std::string, PlannerMetric > metrics
Map of metric name to value.
std::vector< std::map< std::string, std::string > > progress
Planner progress data.
std::size_t thread_id
Thread ID of profiler execution.
boost::posix_time::ptime start
Query start time.
double time
Time that planning took in seconds.
std::string hostname
Hostname of the machine the plan was run on.
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.
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.
std::map< std::string, ComputeMetricCallback > callbacks_
User callback metrics.
std::vector< ProgressCallbackAllocator > prog_callback_allocators_
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.
@ CLEARANCE
Clearance of path from obstacles.
@ WAYPOINTS
Number of waypoints in path.
@ SMOOTHNESS
Smoothness of path.
@ CORRECT
Is the path correct (no collisions?).
@ LENGTH
Length of the path.
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.
A const shared pointer wrapper for robowflex::Scene.
Benchmark outputter that saves each trajectory from each run to a rosbag file.
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...
IO::Bag bag_
Rosbag handler.
const std::string file_
Filename.
A shared pointer wrapper for robowflex::Trajectory.
moveit_msgs::MotionPlanRequest MotionPlanRequest
Main namespace. Contains all library classes and functions.
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.
Functions for loading and animating scenes in Blender.
A container structure for all elements needed in a planning query, plus an identifying name.
planning_interface::MotionPlanRequest request
Request used for the query.
PlanningQuery()=default
Empty constructor.
SceneConstPtr scene
Scene used for the query.
std::string name
Name of this query.
PlannerPtr planner
Planner used for the query.
bool progress
If true, captures planner progress properties (if they exist).
bool progress_at_least_once
If true, will always run the progress loop at least once.
double progress_update_rate
Update rate for progress callbacks.
uint32_t metrics
Bitmask of which metrics to compute after planning.
void callback(movegroup::MoveGroupHelper::Action &action)