BenchmarkOptions.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015, Rice University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Rice University nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Ryan Luna */
36 
38 
39 using namespace moveit_ros_benchmarks;
40 
42 {
43 }
44 
45 BenchmarkOptions::BenchmarkOptions(const std::string& ros_namespace)
46 {
47  readBenchmarkOptions(ros_namespace);
48 }
49 
51 
52 void BenchmarkOptions::setNamespace(const std::string& ros_namespace)
53 {
54  readBenchmarkOptions(ros_namespace);
55 }
56 
57 void BenchmarkOptions::readBenchmarkOptions(const std::string& ros_namespace)
58 {
59  ros::NodeHandle nh(ros_namespace);
60 
61  XmlRpc::XmlRpcValue benchmark_config;
62  if (nh.getParam("benchmark_config", benchmark_config))
63  {
67  }
68  else
69  {
70  ROS_WARN("No benchmark_config found on param server");
71  }
72 }
73 
74 const std::string& BenchmarkOptions::getHostName() const
75 {
76  return hostname_;
77 }
78 
80 {
81  return port_;
82 }
83 
84 const std::string& BenchmarkOptions::getSceneName() const
85 {
86  return scene_name_;
87 }
88 
90 {
91  return runs_;
92 }
93 
95 {
96  return timeout_;
97 }
98 
99 const std::string& BenchmarkOptions::getBenchmarkName() const
100 {
101  return benchmark_name_;
102 }
103 
104 const std::string& BenchmarkOptions::getGroupName() const
105 {
106  return group_name_;
107 }
108 
109 const std::string& BenchmarkOptions::getOutputDirectory() const
110 {
111  return output_directory_;
112 }
113 
114 const std::string& BenchmarkOptions::getQueryRegex() const
115 {
116  return query_regex_;
117 }
118 
119 const std::string& BenchmarkOptions::getStartStateRegex() const
120 {
121  return start_state_regex_;
122 }
123 
125 {
126  return goal_constraint_regex_;
127 }
128 
130 {
131  return path_constraint_regex_;
132 }
133 
135 {
137 }
138 
139 const std::vector<std::string>& BenchmarkOptions::getPredefinedPoses() const
140 {
141  return predefined_poses_;
142 }
143 
145 {
147 }
148 
149 void BenchmarkOptions::getGoalOffsets(std::vector<double>& offsets) const
150 {
151  offsets.resize(6);
152  memcpy(&offsets[0], goal_offsets, 6 * sizeof(double));
153 }
154 
155 const std::map<std::string, std::vector<std::string>>& BenchmarkOptions::getPlanningPipelineConfigurations() const
156 {
157  return planning_pipelines_;
158 }
159 
160 void BenchmarkOptions::getPlanningPipelineNames(std::vector<std::string>& planning_pipeline_names) const
161 {
162  planning_pipeline_names.clear();
163  for (const std::pair<const std::string, std::vector<std::string>>& planning_pipeline : planning_pipelines_)
164  planning_pipeline_names.push_back(planning_pipeline.first);
165 }
166 
167 const std::string& BenchmarkOptions::getWorkspaceFrameID() const
168 {
169  return workspace_.header.frame_id;
170 }
171 
172 const moveit_msgs::WorkspaceParameters& BenchmarkOptions::getWorkspaceParameters() const
173 {
174  return workspace_;
175 }
176 
178 {
179  nh.param(std::string("benchmark_config/warehouse/host"), hostname_, std::string("127.0.0.1"));
180  nh.param(std::string("benchmark_config/warehouse/port"), port_, 33829);
181 
182  if (!nh.getParam("benchmark_config/warehouse/scene_name", scene_name_))
183  ROS_WARN("Benchmark scene_name NOT specified");
184 
185  ROS_INFO("Benchmark host: %s", hostname_.c_str());
186  ROS_INFO("Benchmark port: %d", port_);
187  ROS_INFO("Benchmark scene: %s", scene_name_.c_str());
188 }
189 
191 {
192  nh.param(std::string("benchmark_config/parameters/name"), benchmark_name_, std::string(""));
193  nh.param(std::string("benchmark_config/parameters/runs"), runs_, 10);
194  nh.param(std::string("benchmark_config/parameters/timeout"), timeout_, 10.0);
195  nh.param(std::string("benchmark_config/parameters/output_directory"), output_directory_, std::string(""));
196  nh.param(std::string("benchmark_config/parameters/queries"), query_regex_, std::string(".*"));
197  nh.param(std::string("benchmark_config/parameters/start_states"), start_state_regex_, std::string(""));
198  nh.param(std::string("benchmark_config/parameters/goal_constraints"), goal_constraint_regex_, std::string(""));
199  nh.param(std::string("benchmark_config/parameters/path_constraints"), path_constraint_regex_, std::string(""));
200  nh.param(std::string("benchmark_config/parameters/trajectory_constraints"), trajectory_constraint_regex_,
201  std::string(""));
202  nh.param(std::string("benchmark_config/parameters/predefined_poses"), predefined_poses_, {});
203  nh.param(std::string("benchmark_config/parameters/predefined_poses_group"), predefined_poses_group_, std::string(""));
204 
205  if (!nh.getParam(std::string("benchmark_config/parameters/group"), group_name_))
206  ROS_WARN("Benchmark group NOT specified");
207 
208  if (nh.hasParam("benchmark_config/parameters/workspace"))
210 
211  // Reading in goal_offset (or defaulting to zero)
212  nh.param(std::string("benchmark_config/parameters/goal_offset/x"), goal_offsets[0], 0.0);
213  nh.param(std::string("benchmark_config/parameters/goal_offset/y"), goal_offsets[1], 0.0);
214  nh.param(std::string("benchmark_config/parameters/goal_offset/z"), goal_offsets[2], 0.0);
215  nh.param(std::string("benchmark_config/parameters/goal_offset/roll"), goal_offsets[3], 0.0);
216  nh.param(std::string("benchmark_config/parameters/goal_offset/pitch"), goal_offsets[4], 0.0);
217  nh.param(std::string("benchmark_config/parameters/goal_offset/yaw"), goal_offsets[5], 0.0);
218 
219  ROS_INFO("Benchmark name: '%s'", benchmark_name_.c_str());
220  ROS_INFO("Benchmark #runs: %d", runs_);
221  ROS_INFO("Benchmark timeout: %f secs", timeout_);
222  ROS_INFO("Benchmark group: %s", group_name_.c_str());
223  ROS_INFO("Benchmark query regex: '%s'", query_regex_.c_str());
224  ROS_INFO("Benchmark start state regex: '%s':", start_state_regex_.c_str());
225  ROS_INFO("Benchmark goal constraint regex: '%s':", goal_constraint_regex_.c_str());
226  ROS_INFO("Benchmark path constraint regex: '%s':", path_constraint_regex_.c_str());
227  ROS_INFO("Benchmark goal offsets (%f %f %f, %f %f %f)", goal_offsets[0], goal_offsets[1], goal_offsets[2],
229  ROS_INFO("Benchmark output directory: %s", output_directory_.c_str());
230  ROS_INFO_STREAM("Benchmark workspace: " << workspace_);
231 }
232 
234 {
235  // Make sure all params exist
236  if (!nh.getParam("benchmark_config/parameters/workspace/frame_id", workspace_.header.frame_id))
237  ROS_WARN("Workspace frame_id not specified in benchmark config");
238 
239  nh.param(std::string("benchmark_config/parameters/workspace/min_corner/x"), workspace_.min_corner.x, 0.0);
240  nh.param(std::string("benchmark_config/parameters/workspace/min_corner/y"), workspace_.min_corner.y, 0.0);
241  nh.param(std::string("benchmark_config/parameters/workspace/min_corner/z"), workspace_.min_corner.z, 0.0);
242 
243  nh.param(std::string("benchmark_config/parameters/workspace/max_corner/x"), workspace_.max_corner.x, 0.0);
244  nh.param(std::string("benchmark_config/parameters/workspace/max_corner/y"), workspace_.max_corner.y, 0.0);
245  nh.param(std::string("benchmark_config/parameters/workspace/max_corner/z"), workspace_.max_corner.z, 0.0);
246 
247  workspace_.header.stamp = ros::Time::now();
248 }
249 
251 {
252  planning_pipelines_.clear();
253 
254  XmlRpc::XmlRpcValue pipeline_configs;
255  if (nh.getParam("benchmark_config/planning_pipelines", pipeline_configs))
256  {
257  if (pipeline_configs.getType() != XmlRpc::XmlRpcValue::TypeArray)
258  {
259  ROS_ERROR("Expected a list of planning pipeline configurations to benchmark");
260  return;
261  }
262 
263  for (int i = 0; i < pipeline_configs.size(); ++i) // NOLINT(modernize-loop-convert)
264  {
265  if (pipeline_configs[i].getType() != XmlRpc::XmlRpcValue::TypeStruct)
266  {
267  ROS_WARN("Improper YAML type for planning pipeline configurations");
268  continue;
269  }
270  if (!pipeline_configs[i].hasMember("name") || !pipeline_configs[i].hasMember("planners"))
271  {
272  ROS_WARN("Malformed YAML for planner configurations");
273  continue;
274  }
275 
276  if (pipeline_configs[i]["planners"].getType() != XmlRpc::XmlRpcValue::TypeArray)
277  {
278  ROS_WARN("Expected a list of planners to benchmark");
279  continue;
280  }
281 
282  const std::string pipeline_name = pipeline_configs[i]["name"];
283  ROS_INFO("Reading in planner names for planning pipeline '%s'", pipeline_name.c_str());
284 
285  std::vector<std::string> planners;
286  planners.reserve(pipeline_configs[i]["planners"].size());
287  for (int j = 0; j < pipeline_configs[i]["planners"].size(); ++j)
288  planners.emplace_back(pipeline_configs[i]["planners"][j]);
289 
290  for (std::size_t j = 0; j < planners.size(); ++j)
291  ROS_INFO(" [%lu]: %s", j, planners[j].c_str());
292 
293  planning_pipelines_[pipeline_name] = planners;
294  }
295  }
296 }
XmlRpc::XmlRpcValue::size
int size() const
BenchmarkOptions.h
moveit_ros_benchmarks::BenchmarkOptions::readWorkspaceParameters
void readWorkspaceParameters(ros::NodeHandle &nh)
Definition: BenchmarkOptions.cpp:233
moveit_ros_benchmarks::BenchmarkOptions::trajectory_constraint_regex_
std::string trajectory_constraint_regex_
Definition: BenchmarkOptions.h:192
moveit_ros_benchmarks::BenchmarkOptions::getStartStateRegex
const std::string & getStartStateRegex() const
Get the regex expression for matching the names of all start states to plan from.
Definition: BenchmarkOptions.cpp:119
moveit_ros_benchmarks::BenchmarkOptions::getGroupName
const std::string & getGroupName() const
Get the name of the planning group to run the benchmark with.
Definition: BenchmarkOptions.cpp:104
moveit_ros_benchmarks::BenchmarkOptions::workspace_
moveit_msgs::WorkspaceParameters workspace_
Definition: BenchmarkOptions.h:200
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
moveit_ros_benchmarks::BenchmarkOptions::query_regex_
std::string query_regex_
Definition: BenchmarkOptions.h:188
moveit_ros_benchmarks::BenchmarkOptions::output_directory_
std::string output_directory_
Definition: BenchmarkOptions.h:187
moveit_ros_benchmarks::BenchmarkOptions::getHostName
const std::string & getHostName() const
Get the name of the warehouse database host server.
Definition: BenchmarkOptions.cpp:74
moveit_ros_benchmarks::BenchmarkOptions::benchmark_name_
std::string benchmark_name_
Definition: BenchmarkOptions.h:185
moveit_ros_benchmarks::BenchmarkOptions::start_state_regex_
std::string start_state_regex_
Definition: BenchmarkOptions.h:189
moveit_ros_benchmarks::BenchmarkOptions::goal_offsets
double goal_offsets[6]
Definition: BenchmarkOptions.h:195
moveit_ros_benchmarks::BenchmarkOptions::readBenchmarkParameters
void readBenchmarkParameters(ros::NodeHandle &nh)
Definition: BenchmarkOptions.cpp:190
XmlRpc::XmlRpcValue::TypeStruct
TypeStruct
moveit_ros_benchmarks::BenchmarkOptions::getNumRuns
int getNumRuns() const
Get the specified number of benchmark query runs.
Definition: BenchmarkOptions.cpp:89
moveit_ros_benchmarks::BenchmarkOptions::hostname_
std::string hostname_
warehouse parameters
Definition: BenchmarkOptions.h:178
moveit_ros_benchmarks::BenchmarkOptions::path_constraint_regex_
std::string path_constraint_regex_
Definition: BenchmarkOptions.h:191
moveit_ros_benchmarks::BenchmarkOptions::getWorkspaceFrameID
const std::string & getWorkspaceFrameID() const
Definition: BenchmarkOptions.cpp:167
moveit_ros_benchmarks::BenchmarkOptions::getWorkspaceParameters
const moveit_msgs::WorkspaceParameters & getWorkspaceParameters() const
Definition: BenchmarkOptions.cpp:172
moveit_ros_benchmarks::BenchmarkOptions::scene_name_
std::string scene_name_
Definition: BenchmarkOptions.h:180
moveit_ros_benchmarks::BenchmarkOptions::group_name_
std::string group_name_
Definition: BenchmarkOptions.h:186
moveit_ros_benchmarks::BenchmarkOptions::getOutputDirectory
const std::string & getOutputDirectory() const
Get the target directory for the generated benchmark result data.
Definition: BenchmarkOptions.cpp:109
ROS_ERROR
#define ROS_ERROR(...)
moveit_ros_benchmarks::BenchmarkOptions::getTimeout
double getTimeout() const
Get the maximum timeout per planning attempt.
Definition: BenchmarkOptions.cpp:94
ros::NodeHandle::hasParam
bool hasParam(const std::string &key) const
ROS_WARN
#define ROS_WARN(...)
moveit_ros_benchmarks::BenchmarkOptions::readPlannerConfigs
void readPlannerConfigs(ros::NodeHandle &nh)
Definition: BenchmarkOptions.cpp:250
moveit_ros_benchmarks::BenchmarkOptions::goal_constraint_regex_
std::string goal_constraint_regex_
Definition: BenchmarkOptions.h:190
moveit_ros_benchmarks::BenchmarkOptions::getPlanningPipelineConfigurations
const std::map< std::string, std::vector< std::string > > & getPlanningPipelineConfigurations() const
Get all planning pipeline names mapped to their parameter configuration.
Definition: BenchmarkOptions.cpp:155
ROS_INFO_STREAM
#define ROS_INFO_STREAM(args)
moveit_ros_benchmarks::BenchmarkOptions::getGoalOffsets
void getGoalOffsets(std::vector< double > &offsets) const
Get the constant position/orientation offset to be used for shifting all goal constraints.
Definition: BenchmarkOptions.cpp:149
moveit_ros_benchmarks::BenchmarkOptions::setNamespace
void setNamespace(const std::string &ros_namespace)
Set the ROS namespace the node handle should use for parameter lookup.
Definition: BenchmarkOptions.cpp:52
XmlRpc::XmlRpcValue::getType
const Type & getType() const
XmlRpc::XmlRpcValue::TypeArray
TypeArray
planning_pipeline
moveit_ros_benchmarks::BenchmarkOptions::runs_
int runs_
benchmark parameters
Definition: BenchmarkOptions.h:183
moveit_ros_benchmarks::BenchmarkOptions::planning_pipelines_
std::map< std::string, std::vector< std::string > > planning_pipelines_
planner configurations
Definition: BenchmarkOptions.h:198
moveit_ros_benchmarks::BenchmarkOptions::BenchmarkOptions
BenchmarkOptions()
Constructor.
Definition: BenchmarkOptions.cpp:41
moveit_ros_benchmarks::BenchmarkOptions::timeout_
double timeout_
Definition: BenchmarkOptions.h:184
moveit_ros_benchmarks::BenchmarkOptions::readWarehouseOptions
void readWarehouseOptions(ros::NodeHandle &nh)
Definition: BenchmarkOptions.cpp:177
moveit_ros_benchmarks::BenchmarkOptions::predefined_poses_group_
std::string predefined_poses_group_
Definition: BenchmarkOptions.h:194
moveit_ros_benchmarks::BenchmarkOptions::getPredefinedPoses
const std::vector< std::string > & getPredefinedPoses() const
Get the names of all predefined poses to consider for planning.
Definition: BenchmarkOptions.cpp:139
moveit_ros_benchmarks::BenchmarkOptions::getPathConstraintRegex
const std::string & getPathConstraintRegex() const
Get the regex expression for matching the names of all path constraints to plan with.
Definition: BenchmarkOptions.cpp:129
ros::NodeHandle::param
T param(const std::string &param_name, const T &default_val) const
moveit_ros_benchmarks::BenchmarkOptions::readBenchmarkOptions
void readBenchmarkOptions(const std::string &ros_namespace)
Definition: BenchmarkOptions.cpp:57
moveit_ros_benchmarks::BenchmarkOptions::getPort
int getPort() const
Get the port of the warehouse database host server.
Definition: BenchmarkOptions.cpp:79
ROS_INFO
#define ROS_INFO(...)
moveit_ros_benchmarks::BenchmarkOptions::port_
int port_
Definition: BenchmarkOptions.h:179
moveit_ros_benchmarks::BenchmarkOptions::getTrajectoryConstraintRegex
const std::string & getTrajectoryConstraintRegex() const
Get the regex expression for matching the names of all trajectory constraints to plan with.
Definition: BenchmarkOptions.cpp:134
moveit_ros_benchmarks::BenchmarkOptions::getGoalConstraintRegex
const std::string & getGoalConstraintRegex() const
Get the regex expression for matching the names of all goal constraints to plan to.
Definition: BenchmarkOptions.cpp:124
moveit_ros_benchmarks::BenchmarkOptions::getPlanningPipelineNames
void getPlanningPipelineNames(std::vector< std::string > &planning_pipeline_names) const
Get all planning pipeline names.
Definition: BenchmarkOptions.cpp:160
moveit_ros_benchmarks::BenchmarkOptions::getPredefinedPosesGroup
const std::string & getPredefinedPosesGroup() const
Get the name of the planning group for which the predefined poses are defined.
Definition: BenchmarkOptions.cpp:144
moveit_ros_benchmarks::BenchmarkOptions::predefined_poses_
std::vector< std::string > predefined_poses_
Definition: BenchmarkOptions.h:193
XmlRpc::XmlRpcValue
moveit_ros_benchmarks::BenchmarkOptions::~BenchmarkOptions
virtual ~BenchmarkOptions()
Destructor.
moveit_ros_benchmarks::BenchmarkOptions::getBenchmarkName
const std::string & getBenchmarkName() const
Get the reference name of the benchmark.
Definition: BenchmarkOptions.cpp:99
ros::NodeHandle
moveit_ros_benchmarks::BenchmarkOptions::getQueryRegex
const std::string & getQueryRegex() const
Get the regex expression for matching the names of all queries to run.
Definition: BenchmarkOptions.cpp:114
moveit_ros_benchmarks
Definition: BenchmarkExecutor.h:57
moveit_ros_benchmarks::BenchmarkOptions::getSceneName
const std::string & getSceneName() const
Get the reference name of the planning scene stored inside the warehouse database.
Definition: BenchmarkOptions.cpp:84
ros::Time::now
static Time now()


benchmarks
Author(s): Ryan Luna
autogenerated on Sat May 3 2025 02:27:17