38 #include <gtest/gtest.h>
40 #include "fcl/config.h"
53 #include "fcl_resources/config.h"
59 void octomap_cost_test(S env_scale, std::size_t env_size, std::size_t num_max_cost_sources,
bool use_mesh,
bool use_mesh_octomap,
double resolution = 0.1);
65 octomap_cost_test<S>(200, 100, 10,
false,
false);
66 octomap_cost_test<S>(200, 1000, 10,
false,
false);
68 octomap_cost_test<S>(200, 10, 10,
false,
false, 0.1);
69 octomap_cost_test<S>(200, 100, 10,
false,
false, 0.1);
76 test_octomap_cost<double>();
83 octomap_cost_test<S>(200, 100, 10,
true,
false);
84 octomap_cost_test<S>(200, 1000, 10,
true,
false);
86 octomap_cost_test<S>(200, 2, 4,
true,
false, 1.0);
87 octomap_cost_test<S>(200, 5, 4,
true,
false, 1.0);
94 test_octomap_cost_mesh<double>();
98 void octomap_cost_test(S env_scale, std::size_t env_size, std::size_t num_max_cost_sources,
bool use_mesh,
bool use_mesh_octomap,
double resolution)
100 std::vector<CollisionObject<S>*> env;
106 OcTree<S>* tree =
new OcTree<S>(std::shared_ptr<const octomap::OcTree>(test::generateOcTree(resolution)));
114 cdata.
request.enable_cost =
true;
115 cdata.
request.num_max_cost_sources = num_max_cost_sources;
127 cdata3.
request.enable_cost =
true;
128 cdata3.
request.num_max_cost_sources = num_max_cost_sources;
142 std::vector<CollisionObject<S>*> boxes;
144 test::generateBoxesFromOctomapMesh(boxes, *tree);
146 test::generateBoxesFromOctomap(boxes, *tree);
158 cdata2.
request.enable_cost =
true;
159 cdata3.
request.num_max_cost_sources = num_max_cost_sources;
166 std::cout << cdata.
result.numContacts() <<
" " << cdata3.
result.numContacts() <<
" " << cdata2.
result.numContacts() << std::endl;
167 std::cout << cdata.
result.numCostSources() <<
" " << cdata3.
result.numCostSources() <<
" " << cdata2.
result.numCostSources() << std::endl;
170 std::vector<CostSource<S>> cost_sources;
171 cdata.
result.getCostSources(cost_sources);
172 for(std::size_t i = 0; i < cost_sources.size(); ++i)
174 std::cout << cost_sources[i].aabb_min.transpose() <<
" " << cost_sources[i].aabb_max.transpose() <<
" " << cost_sources[i].cost_density << std::endl;
177 std::cout << std::endl;
179 cdata3.
result.getCostSources(cost_sources);
180 for(std::size_t i = 0; i < cost_sources.size(); ++i)
182 std::cout << cost_sources[i].aabb_min.transpose() <<
" " << cost_sources[i].aabb_max.transpose() <<
" " << cost_sources[i].cost_density << std::endl;
185 std::cout << std::endl;
187 cdata2.
result.getCostSources(cost_sources);
188 for(std::size_t i = 0; i < cost_sources.size(); ++i)
190 std::cout << cost_sources[i].aabb_min.transpose() <<
" " << cost_sources[i].aabb_max.transpose() <<
" " << cost_sources[i].cost_density << std::endl;
193 std::cout << std::endl;
202 for(std::size_t i = 0; i < boxes.size(); ++i)
205 std::cout <<
"collision cost" << std::endl;
206 std::cout <<
"1) octomap overall time: " << t1.
overall_time << std::endl;
207 std::cout <<
"1') octomap overall time (as geometry): " << t3.
overall_time << std::endl;
208 std::cout <<
"2) boxes overall time: " << t2.
overall_time << std::endl;
209 std::cout <<
" a) to boxes: " << t2.
records[0] << std::endl;
210 std::cout <<
" b) structure init: " << t2.
records[1] << std::endl;
211 std::cout <<
" c) collision: " << t2.
records[2] << std::endl;
212 std::cout <<
"Note: octomap may need more collides when using mesh, because octomap collision uses box primitive inside" << std::endl;
216 int main(
int argc,
char* argv[])
218 ::testing::InitGoogleTest(&argc, argv);
219 return RUN_ALL_TESTS();