48int main(
int argc,
char* argv[])
50 std::filesystem::path config_pkg_path;
51 std::filesystem::path urdf_path;
52 std::filesystem::path srdf_path;
53 std::filesystem::path output_path;
55 bool include_default =
false, include_always =
false, keep_old =
false, verbose =
false;
57 double min_collision_fraction = 1.0;
59 uint32_t never_trials = 0;
62 po::options_description desc(
"Allowed options");
63 desc.add_options()(
"help",
"show help")(
"config-pkg", po::value(&config_pkg_path),
"path to MoveIt config package")(
64 "urdf", po::value(&urdf_path),
"path to URDF ( or xacro)")(
"srdf", po::value(&srdf_path),
65 "path to SRDF ( or xacro)")(
66 "output", po::value(&output_path),
67 "output path for SRDF")(
"xacro-args", po::value<std::vector<std::string> >()->composing(),
68 "additional arguments for xacro")(
"default", po::bool_switch(&include_default),
69 "disable default colliding pairs")(
70 "always", po::bool_switch(&include_always),
"disable always colliding pairs")(
"keep", po::bool_switch(&keep_old),
71 "keep disabled link from SRDF")(
72 "verbose", po::bool_switch(&verbose),
"verbose output")(
"trials", po::value(&never_trials),
73 "number of trials for searching never colliding pairs")(
74 "min-collision-fraction", po::value(&min_collision_fraction),
75 "fraction of small sample size to determine links that are always colliding");
78 po::positional_options_description pos_desc;
79 pos_desc.add(
"xacro-args", -1);
82 po::store(po::command_line_parser(argc, argv).options(desc).positional(pos_desc).run(), vm);
87 std::cout << desc <<
'\n';
91 rclcpp::init(argc, argv);
92 rclcpp::Node::SharedPtr node = std::make_shared<rclcpp::Node>(
"collision_updater");
93 moveit_setup::DataWarehousePtr config_data = std::make_shared<moveit_setup::DataWarehouse>(node);
98 if (!config_pkg_path.empty())
105 catch (
const std::runtime_error& e)
107 RCLCPP_ERROR_STREAM(node->get_logger(),
"Could not load config at '" << config_pkg_path <<
"'. " << e.what());
111 else if (urdf_path.empty() || srdf_path.empty())
113 RCLCPP_ERROR_STREAM(node->get_logger(),
"Please provide config package or URDF and SRDF path");
118 RCLCPP_ERROR_STREAM(node->get_logger(),
"Please provide a different output file for SRDF xacro input file");
125 if (!urdf_path.empty())
129 std::vector<std::string> xacro_args;
130 if (vm.count(
"xacro-args"))
131 xacro_args = vm[
"xacro-args"].as<std::vector<std::string> >();
135 if (!srdf_path.empty())
137 srdf_config->loadSRDFFile(srdf_path);
142 srdf_config->clearCollisionData();
147 int last_progress = 0;
150 if (thread_progress - last_progress > 10)
152 RCLCPP_INFO(node->get_logger(),
"%d%% complete...", thread_progress);
153 last_progress = thread_progress;
157 RCLCPP_INFO(node->get_logger(),
"100%% complete...");
159 size_t skip_mask = 0;
160 if (!include_default)
167 srdf_config->write(output_path.empty() ? srdf_config->getPath() : output_path);