environment_clone_benchmarks.cpp
Go to the documentation of this file.
3 #include <benchmark/benchmark.h>
4 #include <algorithm>
15 
16 using namespace tesseract_scene_graph;
17 using namespace tesseract_collision;
18 using namespace tesseract_environment;
19 using namespace tesseract_kinematics;
20 
22 {
23  std::string path = "package://tesseract_support/urdf/lbr_iiwa_14_r820.urdf";
24 
25  return tesseract_urdf::parseURDFFile(locator.locateResource(path)->getFilePath(), locator);
26 }
27 
29  const tesseract_common::ResourceLocator& locator)
30 {
31  std::string path = "package://tesseract_support/urdf/lbr_iiwa_14_r820.srdf";
32 
33  auto srdf = std::make_shared<tesseract_srdf::SRDFModel>();
34  srdf->initFile(scene_graph, locator.locateResource(path)->getFilePath(), locator);
35 
36  return srdf;
37 }
38 
40 static void BM_ENVIRONMENT_CLONE(benchmark::State& state, Environment::Ptr env)
41 {
42  Environment::Ptr clone;
43  for (auto _ : state)
44  {
45  benchmark::DoNotOptimize(clone = env->clone());
46  }
47 }
48 
50 static void BM_STATE_SOLVER_CLONE(benchmark::State& state, StateSolver::Ptr state_solver)
51 {
52  StateSolver::Ptr clone;
53  for (auto _ : state)
54  {
55  benchmark::DoNotOptimize(clone = state_solver->clone());
56  }
57 }
58 
60 static void BM_SCENE_GRAPH_CLONE(benchmark::State& state, SceneGraph::Ptr sg)
61 {
62  SceneGraph::Ptr clone;
63  for (auto _ : state)
64  {
65  benchmark::DoNotOptimize(clone = sg->clone());
66  }
67 }
68 
70 static void BM_JOINT_GROUP_COPY(benchmark::State& state, JointGroup::ConstPtr jg)
71 {
72  JointGroup::Ptr clone;
73  for (auto _ : state)
74  {
75  benchmark::DoNotOptimize(clone = std::make_unique<JointGroup>(*jg));
76  }
77 }
78 
79 static void BM_KINEMATIC_GROUP_COPY(benchmark::State& state, KinematicGroup::ConstPtr kg)
80 {
81  KinematicGroup::Ptr clone;
82  for (auto _ : state)
83  {
84  benchmark::DoNotOptimize(clone = std::make_unique<KinematicGroup>(*kg));
85  }
86 }
87 
88 int main(int argc, char** argv)
89 {
91  SceneGraph::Ptr scene_graph = getSceneGraph(locator);
92  auto srdf = getSRDFModel(*scene_graph, locator);
93  Environment::Ptr env = std::make_shared<Environment>();
94  env->init(*scene_graph, srdf);
95  StateSolver::Ptr state_solver = env->getStateSolver();
96  JointGroup::ConstPtr joint_group = env->getJointGroup("manipulator");
97  KinematicGroup::ConstPtr kinematic_group = env->getKinematicGroup("manipulator");
99  // Clone
101 
102  {
103  std::function<void(benchmark::State&, Environment::Ptr)> BM_CLONE_FUNC = BM_ENVIRONMENT_CLONE;
104  std::string name = "BM_ENVIRONMENT_CLONE";
105  benchmark::RegisterBenchmark(name.c_str(), BM_CLONE_FUNC, env)
106  ->UseRealTime()
107  ->Unit(benchmark::TimeUnit::kMicrosecond);
108  }
109 
110  {
111  std::function<void(benchmark::State&, StateSolver::Ptr)> BM_CLONE_FUNC = BM_STATE_SOLVER_CLONE;
112  std::string name = "BM_STATE_SOLVER_CLONE";
113  benchmark::RegisterBenchmark(name.c_str(), BM_CLONE_FUNC, state_solver)
114  ->UseRealTime()
115  ->Unit(benchmark::TimeUnit::kMicrosecond);
116  }
117 
118  {
119  std::function<void(benchmark::State&, SceneGraph::Ptr)> BM_CLONE_FUNC = BM_SCENE_GRAPH_CLONE;
120  std::string name = "BM_SCENE_GRAPH_CLONE";
121  benchmark::RegisterBenchmark(name.c_str(), BM_CLONE_FUNC, scene_graph)
122  ->UseRealTime()
123  ->Unit(benchmark::TimeUnit::kMicrosecond);
124  }
125 
126  {
127  std::function<void(benchmark::State&, JointGroup::ConstPtr)> BM_CLONE_FUNC = BM_JOINT_GROUP_COPY;
128  std::string name = "BM_JOINT_GROUP_COPY";
129  benchmark::RegisterBenchmark(name.c_str(), BM_CLONE_FUNC, joint_group)
130  ->UseRealTime()
131  ->Unit(benchmark::TimeUnit::kMicrosecond);
132  }
133 
134  {
135  std::function<void(benchmark::State&, KinematicGroup::ConstPtr)> BM_CLONE_FUNC = BM_KINEMATIC_GROUP_COPY;
136  std::string name = "BM_KINEMATIC_GROUP_COPY";
137  benchmark::RegisterBenchmark(name.c_str(), BM_CLONE_FUNC, kinematic_group)
138  ->UseRealTime()
139  ->Unit(benchmark::TimeUnit::kMicrosecond);
140  }
141 
142  benchmark::Initialize(&argc, argv);
143  benchmark::RunSpecifiedBenchmarks();
144 }
graph.h
tesseract_srdf::SRDFModel::Ptr
std::shared_ptr< SRDFModel > Ptr
tesseract_environment
Definition: command.h:45
tesseract_environment::Environment::Ptr
std::shared_ptr< Environment > Ptr
Definition: environment.h:78
resource_locator.h
getSRDFModel
tesseract_srdf::SRDFModel::Ptr getSRDFModel(const SceneGraph &scene_graph, const tesseract_common::ResourceLocator &locator)
Definition: environment_clone_benchmarks.cpp:28
tesseract_kinematics::KinematicGroup::ConstPtr
std::shared_ptr< const KinematicGroup > ConstPtr
tesseract_common::ResourceLocator::locateResource
virtual std::shared_ptr< Resource > locateResource(const std::string &url) const=0
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_scene_graph::SceneGraph
BM_SCENE_GRAPH_CLONE
static void BM_SCENE_GRAPH_CLONE(benchmark::State &state, SceneGraph::Ptr sg)
Benchmark that checks the Tesseract clone method.
Definition: environment_clone_benchmarks.cpp:60
urdf_parser.h
name
std::string name
tesseract_urdf::parseURDFFile
std::unique_ptr< tesseract_scene_graph::SceneGraph > parseURDFFile(const std::string &path, const tesseract_common::ResourceLocator &locator)
BM_ENVIRONMENT_CLONE
static void BM_ENVIRONMENT_CLONE(benchmark::State &state, Environment::Ptr env)
Benchmark that checks the Tesseract clone method.
Definition: environment_clone_benchmarks.cpp:40
tesseract_common::ResourceLocator
kinematic_group.h
main
int main(int argc, char **argv)
Definition: environment_clone_benchmarks.cpp:88
TESSERACT_COMMON_IGNORE_WARNINGS_POP
state_solver.h
tesseract_kinematics::KinematicGroup::Ptr
std::shared_ptr< KinematicGroup > Ptr
BM_KINEMATIC_GROUP_COPY
static void BM_KINEMATIC_GROUP_COPY(benchmark::State &state, KinematicGroup::ConstPtr kg)
Definition: environment_clone_benchmarks.cpp:79
srdf_model.h
tesseract_scene_graph::StateSolver::Ptr
std::shared_ptr< StateSolver > Ptr
environment.h
tesseract_kinematics
tesseract_common::GeneralResourceLocator
BM_JOINT_GROUP_COPY
static void BM_JOINT_GROUP_COPY(benchmark::State &state, JointGroup::ConstPtr jg)
Benchmark that checks the Tesseract clone method.
Definition: environment_clone_benchmarks.cpp:70
BM_STATE_SOLVER_CLONE
static void BM_STATE_SOLVER_CLONE(benchmark::State &state, StateSolver::Ptr state_solver)
Benchmark that checks the Tesseract clone method.
Definition: environment_clone_benchmarks.cpp:50
tesseract_collision
joint_group.h
macros.h
tesseract_scene_graph::SceneGraph::Ptr
std::shared_ptr< SceneGraph > Ptr
tesseract_scene_graph
getSceneGraph
SceneGraph::Ptr getSceneGraph(const tesseract_common::ResourceLocator &locator)
Definition: environment_clone_benchmarks.cpp:21


tesseract_environment
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:21