73int main(
int argc,
char** argv)
75 rclcpp::init(argc, argv);
76 auto node = rclcpp::Node::make_shared(
"evaluate_collision_checking_speed");
79 unsigned int nthreads = 2;
80 unsigned int trials = 10000;
81 boost::program_options::options_description desc;
82 desc.add_options()(
"nthreads", boost::program_options::value<unsigned int>(&nthreads)->default_value(nthreads),
83 "Number of threads to use")(
84 "trials", boost::program_options::value<unsigned int>(&trials)->default_value(trials),
85 "Number of collision checks to perform with each thread")(
"wait",
86 "Wait for a user command (so the planning scene can be "
87 "updated in the background)")(
"help",
"this screen");
88 boost::program_options::variables_map vm;
89 boost::program_options::parsed_options po = boost::program_options::parse_command_line(argc, argv, desc);
90 boost::program_options::store(po, vm);
91 boost::program_options::notify(vm);
95 std::cout << desc <<
'\n';
99 rclcpp::executors::MultiThreadedExecutor executor;
100 executor.add_node(node);
105 if (vm.count(
"wait"))
109 std::cout <<
"Listening to planning scene updates. Press Enter to continue ..." <<
'\n';
113 rclcpp::sleep_for(500ms);
115 std::vector<moveit::core::RobotStatePtr> states;
116 RCLCPP_INFO(node->get_logger(),
"Sampling %u valid states...", nthreads);
117 for (
unsigned int i = 0; i < nthreads; ++i)
131 states.push_back(moveit::core::RobotStatePtr(state));
134 std::vector<std::thread*> threads;
136 for (
unsigned int i = 0; i < states.size(); ++i)
138 threads.push_back(
new std::thread([i, trials, &scene = *psm.
getPlanningScene(), &state = *states[i]] {
139 return runCollisionDetection(i, trials, scene, state);
143 for (
unsigned int i = 0; i < states.size(); ++i)
150 RCLCPP_ERROR(node->get_logger(),
"Planning scene not configured");
void checkCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res)
Check whether the current state is in collision, and if needed, updates the collision transforms of t...
void startWorldGeometryMonitor(const std::string &collision_objects_topic=DEFAULT_COLLISION_OBJECT_TOPIC, const std::string &planning_scene_world_topic=DEFAULT_PLANNING_SCENE_WORLD_TOPIC, const bool load_octomap_monitor=true)
Start the OccupancyMapMonitor and listening for: