43 #include <boost/filesystem/path.hpp>
44 #include <boost/filesystem/operations.hpp>
45 #include <boost/algorithm/string/trim.hpp>
46 #include <boost/algorithm/string/predicate.hpp>
53 #include <ompl/config.h>
58 namespace fs = boost::filesystem;
66 srdf_ = std::make_shared<srdf::SRDFWriter>();
67 urdf_model_ = std::make_shared<urdf::Model>();
74 if (setup_assistant_path_.empty())
76 setup_assistant_path_ =
".";
112 ROS_INFO(
"Updating kinematic model");
148 for (
const std::string&
name :
srdf.no_default_collision_links_)
151 for (
auto const& collision :
srdf.enabled_collision_pairs_)
154 for (
auto const& collision :
srdf.disabled_collision_pairs_)
163 YAML::Emitter emitter;
164 emitter << YAML::BeginMap;
167 emitter << YAML::Key <<
"moveit_setup_assistant_config";
169 emitter << YAML::Value << YAML::BeginMap;
172 emitter << YAML::Key <<
"URDF";
173 emitter << YAML::Value << YAML::BeginMap;
174 emitter << YAML::Key <<
"package" << YAML::Value <<
urdf_pkg_name_;
176 emitter << YAML::Key <<
"xacro_args" << YAML::Value <<
xacro_args_;
177 emitter << YAML::EndMap;
180 emitter << YAML::Key <<
"SRDF";
181 emitter << YAML::Value << YAML::BeginMap;
183 emitter << YAML::EndMap;
186 emitter << YAML::Key <<
"CONFIG";
187 emitter << YAML::Value << YAML::BeginMap;
188 emitter << YAML::Key <<
"author_name" << YAML::Value <<
author_name_;
189 emitter << YAML::Key <<
"author_email" << YAML::Value <<
author_email_;
190 auto cur_time = std::time(
nullptr);
191 emitter << YAML::Key <<
"generated_timestamp" << YAML::Value << cur_time;
192 emitter << YAML::EndMap;
194 emitter << YAML::EndMap;
196 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
197 if (!output_stream.good())
203 output_stream << emitter.c_str();
204 output_stream.close();
218 std::ofstream os(file_path.c_str(), std::ios_base::trunc);
236 YAML::Emitter emitter;
237 emitter << YAML::BeginMap;
240 emitter << YAML::Key <<
"planner_configs";
242 emitter << YAML::Value << YAML::BeginMap;
247 std::vector<std::string> pconfigs;
250 std::string defaultconfig = planner_de.name_;
251 emitter << YAML::Key << defaultconfig;
252 emitter << YAML::Value << YAML::BeginMap;
253 emitter << YAML::Key <<
"type" << YAML::Value <<
"geometric::" + planner_de.name_;
256 emitter << YAML::Key << ompl_planner_param.
name;
257 emitter << YAML::Value << ompl_planner_param.
value;
258 emitter << YAML::Comment(ompl_planner_param.
comment);
260 emitter << YAML::EndMap;
262 pconfigs.push_back(defaultconfig);
266 emitter << YAML::EndMap;
271 emitter << YAML::Key <<
group.name_;
272 emitter << YAML::Value << YAML::BeginMap;
275 emitter << YAML::Key <<
"default_planner_config" << YAML::Value <<
group_meta_data_[
group.name_].default_planner_;
276 emitter << YAML::Key <<
"planner_configs";
277 emitter << YAML::Value << YAML::BeginSeq;
278 for (
const std::string& pconfig : pconfigs)
280 emitter << YAML::EndSeq;
284 if (!projection_joints.empty())
286 emitter << YAML::Key <<
"projection_evaluator";
287 emitter << YAML::Value << projection_joints;
289 emitter << YAML::Key <<
"longest_valid_segment_fraction";
290 emitter << YAML::Value <<
"0.005";
293 emitter << YAML::EndMap;
296 emitter << YAML::EndMap;
298 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
299 if (!output_stream.good())
305 output_stream << emitter.c_str() << std::endl;
306 output_stream.close();
316 YAML::Emitter emitter;
317 emitter << YAML::BeginMap;
322 emitter << YAML::Key <<
"stomp/" +
group.name_;
323 emitter << YAML::BeginMap;
324 emitter << YAML::Key <<
"group_name";
325 emitter << YAML::Value <<
group.name_;
327 emitter << YAML::Key <<
"optimization";
328 emitter << YAML::BeginMap;
329 emitter << YAML::Key <<
"num_timesteps";
330 emitter << YAML::Value <<
"60";
331 emitter << YAML::Key <<
"num_iterations";
332 emitter << YAML::Value <<
"40";
333 emitter << YAML::Key <<
"num_iterations_after_valid";
334 emitter << YAML::Value <<
"0";
335 emitter << YAML::Key <<
"num_rollouts";
336 emitter << YAML::Value <<
"30";
337 emitter << YAML::Key <<
"max_rollouts";
338 emitter << YAML::Value <<
"30";
339 emitter << YAML::Key <<
"initialization_method";
340 emitter << YAML::Value <<
"1";
341 emitter << YAML::Comment(
"[1 : LINEAR_INTERPOLATION, 2 : CUBIC_POLYNOMIAL, 3 : MININUM_CONTROL_COST]");
342 emitter << YAML::Key <<
"control_cost_weight";
343 emitter << YAML::Value <<
"0.0";
344 emitter << YAML::EndMap;
346 emitter << YAML::Key <<
"task";
347 emitter << YAML::BeginMap;
349 emitter << YAML::Key <<
"noise_generator";
350 emitter << YAML::BeginSeq;
351 emitter << YAML::BeginMap;
352 emitter << YAML::Key <<
"class";
353 emitter << YAML::Value <<
"stomp_moveit/NormalDistributionSampling";
354 emitter << YAML::Key <<
"stddev";
355 emitter << YAML::Flow;
357 const std::vector<const moveit::core::JointModel*>& joint_models = joint_model_group->
getActiveJointModels();
358 std::vector<float> stddev(joint_models.size(), 0.05);
359 emitter << YAML::Value << stddev;
360 emitter << YAML::EndMap;
361 emitter << YAML::EndSeq;
363 emitter << YAML::Key <<
"cost_functions";
364 emitter << YAML::BeginSeq;
365 emitter << YAML::BeginMap;
366 emitter << YAML::Key <<
"class";
367 emitter << YAML::Value <<
"stomp_moveit/CollisionCheck";
368 emitter << YAML::Key <<
"collision_penalty";
369 emitter << YAML::Value <<
"1.0";
370 emitter << YAML::Key <<
"cost_weight";
371 emitter << YAML::Value <<
"1.0";
372 emitter << YAML::Key <<
"kernel_window_percentage";
373 emitter << YAML::Value <<
"0.2";
374 emitter << YAML::Key <<
"longest_valid_joint_move";
375 emitter << YAML::Value <<
"0.05";
376 emitter << YAML::EndMap;
377 emitter << YAML::EndSeq;
379 emitter << YAML::Key <<
"noisy_filters";
380 emitter << YAML::BeginSeq;
381 emitter << YAML::BeginMap;
382 emitter << YAML::Key <<
"class";
383 emitter << YAML::Value <<
"stomp_moveit/JointLimits";
384 emitter << YAML::Key <<
"lock_start";
385 emitter << YAML::Value <<
"True";
386 emitter << YAML::Key <<
"lock_goal";
387 emitter << YAML::Value <<
"True";
388 emitter << YAML::EndMap;
389 emitter << YAML::BeginMap;
390 emitter << YAML::Key <<
"class";
391 emitter << YAML::Value <<
"stomp_moveit/MultiTrajectoryVisualization";
392 emitter << YAML::Key <<
"line_width";
393 emitter << YAML::Value <<
"0.02";
394 emitter << YAML::Key <<
"rgb";
395 emitter << YAML::Flow;
396 std::vector<float> noisy_filters_rgb{ 255, 255, 0 };
397 emitter << YAML::Value << noisy_filters_rgb;
398 emitter << YAML::Key <<
"marker_array_topic";
399 emitter << YAML::Value <<
"stomp_trajectories";
400 emitter << YAML::Key <<
"marker_namespace";
401 emitter << YAML::Value <<
"noisy";
402 emitter << YAML::EndMap;
403 emitter << YAML::EndSeq;
405 emitter << YAML::Key <<
"update_filters";
406 emitter << YAML::BeginSeq;
407 emitter << YAML::BeginMap;
408 emitter << YAML::Key <<
"class";
409 emitter << YAML::Value <<
"stomp_moveit/PolynomialSmoother";
410 emitter << YAML::Key <<
"poly_order";
411 emitter << YAML::Value <<
"6";
412 emitter << YAML::EndMap;
413 emitter << YAML::BeginMap;
414 emitter << YAML::Key <<
"class";
415 emitter << YAML::Value <<
"stomp_moveit/TrajectoryVisualization";
416 emitter << YAML::Key <<
"line_width";
417 emitter << YAML::Value <<
"0.05";
418 emitter << YAML::Key <<
"rgb";
419 emitter << YAML::Flow;
420 std::vector<float> update_filters_rgb{ 0, 191, 255 };
421 emitter << YAML::Value << update_filters_rgb;
422 emitter << YAML::Key <<
"error_rgb";
423 emitter << YAML::Flow;
424 std::vector<float> update_filters_error_rgb{ 255, 0, 0 };
425 emitter << YAML::Value << update_filters_error_rgb;
426 emitter << YAML::Key <<
"publish_intermediate";
427 emitter << YAML::Value <<
"True";
428 emitter << YAML::Key <<
"marker_topic";
429 emitter << YAML::Value <<
"stomp_trajectory";
430 emitter << YAML::Key <<
"marker_namespace";
431 emitter << YAML::Value <<
"optimized";
432 emitter << YAML::EndMap;
433 emitter << YAML::EndSeq;
435 emitter << YAML::EndMap;
436 emitter << YAML::EndMap;
439 emitter << YAML::EndMap;
441 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
442 if (!output_stream.good())
448 output_stream << emitter.c_str();
449 output_stream.close();
459 YAML::Emitter emitter;
460 emitter << YAML::BeginMap;
470 emitter << YAML::Key <<
group.name_;
471 emitter << YAML::Value << YAML::BeginMap;
474 emitter << YAML::Key <<
"kinematics_solver";
478 emitter << YAML::Key <<
"kinematics_solver_search_resolution";
482 emitter << YAML::Key <<
"kinematics_solver_timeout";
486 emitter << YAML::Key <<
"goal_joint_tolerance";
490 emitter << YAML::Key <<
"goal_position_tolerance";
494 emitter << YAML::Key <<
"goal_orientation_tolerance";
497 emitter << YAML::EndMap;
500 emitter << YAML::EndMap;
502 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
503 if (!output_stream.good())
509 output_stream << emitter.c_str();
510 output_stream.close();
522 std::vector<std::string>::iterator joint_it =
523 std::find(ros_control_config.joints_.begin(), ros_control_config.joints_.end(), joint_name);
524 if (joint_it != ros_control_config.joints_.end())
526 if (ros_control_config.type_.substr(0, 8) ==
"position")
527 return "hardware_interface/PositionJointInterface";
528 else if (ros_control_config.type_.substr(0, 8) ==
"velocity")
529 return "hardware_interface/VelocityJointInterface";
532 return "hardware_interface/EffortJointInterface";
536 return "hardware_interface/EffortJointInterface";
541 YAML::Emitter emitter;
542 emitter << YAML::BeginMap;
544 emitter << YAML::Key <<
"controller_list";
545 emitter << YAML::Value << YAML::BeginSeq;
552 emitter << YAML::BeginMap;
553 const std::vector<const moveit::core::JointModel*>& joint_models = joint_model_group->
getActiveJointModels();
554 emitter << YAML::Key <<
"name";
555 emitter << YAML::Value <<
"fake_" +
group.name_ +
"_controller";
556 emitter << YAML::Key <<
"type";
557 emitter << YAML::Value <<
"$(arg fake_execution_type)";
558 emitter << YAML::Key <<
"joints";
559 emitter << YAML::Value << YAML::BeginSeq;
566 emitter << joint->getName();
568 emitter << YAML::EndSeq;
569 emitter << YAML::EndMap;
572 emitter << YAML::EndSeq;
575 emitter << YAML::Key <<
"initial" << YAML::Comment(
"Define initial robot poses per group");
577 bool poses_found =
false;
578 std::string default_group_name;
581 if (default_group_name.empty())
582 default_group_name =
group.name_;
590 emitter << YAML::Value << YAML::BeginSeq;
592 emitter << YAML::BeginMap;
593 emitter << YAML::Key <<
"group";
594 emitter << YAML::Value <<
group.name_;
595 emitter << YAML::Key <<
"pose";
596 emitter << YAML::Value << group_state.
name_;
597 emitter << YAML::EndMap;
603 emitter << YAML::EndSeq;
607 if (default_group_name.empty())
608 default_group_name =
"group";
609 emitter << YAML::Newline;
610 emitter << YAML::Comment(
" - group: " + default_group_name) << YAML::Newline;
611 emitter << YAML::Comment(
" pose: home") << YAML::Newline;
614 emitter << YAML::BeginSeq;
615 emitter << YAML::EndSeq;
618 emitter << YAML::EndMap;
620 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
621 if (!output_stream.good())
627 output_stream << emitter.c_str();
628 output_stream.close();
635 std::map<std::string, double> joints;
645 if (pair.second.size() != 1)
647 joints[pair.first] = pair.second.front();
657 std::vector<OMPLPlannerDescription> planner_des;
659 OMPLPlannerDescription aps(
"AnytimePathShortening",
"geometric");
660 aps.addParameter(
"shortcut",
"true",
"Attempt to shortcut all new solution paths");
661 aps.addParameter(
"hybridize",
"true",
"Compute hybrid solution trajectories");
662 aps.addParameter(
"max_hybrid_paths",
"24",
"Number of hybrid paths generated per iteration");
663 aps.addParameter(
"num_planners",
"4",
"The number of default planners to use for planning");
664 aps.addParameter(
"planners",
"",
665 "A comma-separated list of planner types (e.g., \"PRM,EST,RRTConnect\""
666 "Optionally, planner parameters can be passed to change the default:"
667 "\"PRM[max_nearest_neighbors=5],EST[goal_bias=.5],RRT[range=10. goal_bias=.1]\"");
668 planner_des.push_back(aps);
671 sbl.addParameter(
"range",
"0.0",
"Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()");
672 planner_des.push_back(sbl);
675 est.addParameter(
"range",
"0.0",
"Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0 setup()");
676 est.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability. default: 0.05");
677 planner_des.push_back(est);
680 lbkpiece.addParameter(
"range",
"0.0",
681 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
683 lbkpiece.addParameter(
"border_fraction",
"0.9",
"Fraction of time focused on boarder default: 0.9");
684 lbkpiece.addParameter(
"min_valid_path_fraction",
"0.5",
"Accept partially valid moves above fraction. default: 0.5");
685 planner_des.push_back(lbkpiece);
688 bkpiece.addParameter(
"range",
"0.0",
689 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
691 bkpiece.addParameter(
"border_fraction",
"0.9",
"Fraction of time focused on boarder default: 0.9");
692 bkpiece.addParameter(
"failed_expansion_score_factor",
"0.5",
693 "When extending motion fails, scale score by factor. "
695 bkpiece.addParameter(
"min_valid_path_fraction",
"0.5",
"Accept partially valid moves above fraction. default: 0.5");
696 planner_des.push_back(bkpiece);
699 kpiece.addParameter(
"range",
"0.0",
700 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
702 kpiece.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability. default: 0.05");
703 kpiece.addParameter(
"border_fraction",
"0.9",
"Fraction of time focused on boarder default: 0.9 (0.0,1.]");
704 kpiece.addParameter(
"failed_expansion_score_factor",
"0.5",
705 "When extending motion fails, scale score by factor. "
707 kpiece.addParameter(
"min_valid_path_fraction",
"0.5",
"Accept partially valid moves above fraction. default: 0.5");
708 planner_des.push_back(kpiece);
711 rrt.addParameter(
"range",
"0.0",
"Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()");
712 rrt.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability? default: 0.05");
713 planner_des.push_back(rrt);
716 rrt_connect.addParameter(
"range",
"0.0",
717 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
719 planner_des.push_back(rrt_connect);
722 rr_tstar.addParameter(
"range",
"0.0",
723 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
725 rr_tstar.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability? default: 0.05");
726 rr_tstar.addParameter(
"delay_collision_checking",
"1",
727 "Stop collision checking as soon as C-free parent found. "
729 planner_des.push_back(rr_tstar);
732 trrt.addParameter(
"range",
"0.0",
"Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on setup()");
733 trrt.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability? default: 0.05");
734 trrt.addParameter(
"max_states_failed",
"10",
"when to start increasing temp. default: 10");
735 trrt.addParameter(
"temp_change_factor",
"2.0",
"how much to increase or decrease temp. default: 2.0");
736 trrt.addParameter(
"min_temperature",
"10e-10",
"lower limit of temp change. default: 10e-10");
737 trrt.addParameter(
"init_temperature",
"10e-6",
"initial temperature. default: 10e-6");
738 trrt.addParameter(
"frontier_threshold",
"0.0",
739 "dist new state to nearest neighbor to disqualify as frontier. "
740 "default: 0.0 set in setup()");
741 trrt.addParameter(
"frontier_node_ratio",
"0.1",
"1/10, or 1 nonfrontier for every 10 frontier. default: 0.1");
742 trrt.addParameter(
"k_constant",
"0.0",
"value used to normalize expresssion. default: 0.0 set in setup()");
743 planner_des.push_back(trrt);
746 prm.addParameter(
"max_nearest_neighbors",
"10",
"use k nearest neighbors. default: 10");
747 planner_des.push_back(prm);
750 planner_des.push_back(pr_mstar);
753 fmt.addParameter(
"num_samples",
"1000",
"number of states that the planner should sample. default: 1000");
754 fmt.addParameter(
"radius_multiplier",
"1.1",
"multiplier used for the nearest neighbors search radius. default: 1.1");
755 fmt.addParameter(
"nearest_k",
"1",
"use Knearest strategy. default: 1");
756 fmt.addParameter(
"cache_cc",
"1",
"use collision checking cache. default: 1");
757 fmt.addParameter(
"heuristics",
"0",
"activate cost to go heuristics. default: 0");
758 fmt.addParameter(
"extended_fmt",
"1",
759 "activate the extended FMT*: adding new samples if planner does not finish "
760 "successfully. default: 1");
761 planner_des.push_back(fmt);
764 bfmt.addParameter(
"num_samples",
"1000",
"number of states that the planner should sample. default: 1000");
765 bfmt.addParameter(
"radius_multiplier",
"1.0",
766 "multiplier used for the nearest neighbors search radius. default: "
768 bfmt.addParameter(
"nearest_k",
"1",
"use the Knearest strategy. default: 1");
769 bfmt.addParameter(
"balanced",
"0",
770 "exploration strategy: balanced true expands one tree every iteration. False will "
771 "select the tree with lowest maximum cost to go. default: 1");
772 bfmt.addParameter(
"optimality",
"1",
773 "termination strategy: optimality true finishes when the best possible path is "
774 "found. Otherwise, the algorithm will finish when the first feasible path is "
775 "found. default: 1");
776 bfmt.addParameter(
"heuristics",
"1",
"activates cost to go heuristics. default: 1");
777 bfmt.addParameter(
"cache_cc",
"1",
"use the collision checking cache. default: 1");
778 bfmt.addParameter(
"extended_fmt",
"1",
779 "Activates the extended FMT*: adding new samples if planner does not finish "
780 "successfully. default: 1");
781 planner_des.push_back(bfmt);
784 rrt.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability? default: 0.05");
785 planner_des.push_back(pdst);
788 stride.addParameter(
"range",
"0.0",
789 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
791 stride.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability. default: 0.05");
792 stride.addParameter(
"use_projected_distance",
"0",
793 "whether nearest neighbors are computed based on distances in a "
794 "projection of the state rather distances in the state space "
795 "itself. default: 0");
796 stride.addParameter(
"degree",
"16",
797 "desired degree of a node in the Geometric Near-neightbor Access Tree (GNAT). "
799 stride.addParameter(
"max_degree",
"18",
"max degree of a node in the GNAT. default: 12");
800 stride.addParameter(
"min_degree",
"12",
"min degree of a node in the GNAT. default: 12");
801 stride.addParameter(
"max_pts_per_leaf",
"6",
"max points per leaf in the GNAT. default: 6");
802 stride.addParameter(
"estimated_dimension",
"0.0",
"estimated dimension of the free space. default: 0.0");
803 stride.addParameter(
"min_valid_path_fraction",
"0.2",
"Accept partially valid moves above fraction. default: 0.2");
804 planner_des.push_back(stride);
807 bi_trrt.addParameter(
"range",
"0.0",
808 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
810 bi_trrt.addParameter(
"temp_change_factor",
"0.1",
"how much to increase or decrease temp. default: 0.1");
811 bi_trrt.addParameter(
"init_temperature",
"100",
"initial temperature. default: 100");
812 bi_trrt.addParameter(
"frontier_threshold",
"0.0",
813 "dist new state to nearest neighbor to disqualify as frontier. "
814 "default: 0.0 set in setup()");
815 bi_trrt.addParameter(
"frontier_node_ratio",
"0.1",
"1/10, or 1 nonfrontier for every 10 frontier. default: 0.1");
816 bi_trrt.addParameter(
"cost_threshold",
"1e300",
817 "the cost threshold. Any motion cost that is not better will not be "
818 "expanded. default: inf");
819 planner_des.push_back(bi_trrt);
822 lbtrrt.addParameter(
"range",
"0.0",
823 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
825 lbtrrt.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability. default: 0.05");
826 lbtrrt.addParameter(
"epsilon",
"0.4",
"optimality approximation factor. default: 0.4");
827 planner_des.push_back(lbtrrt);
830 bi_est.addParameter(
"range",
"0.0",
831 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
833 planner_des.push_back(bi_est);
836 proj_est.addParameter(
"range",
"0.0",
837 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
839 proj_est.addParameter(
"goal_bias",
"0.05",
"When close to goal select goal, with this probability. default: 0.05");
840 planner_des.push_back(proj_est);
843 lazy_prm.addParameter(
"range",
"0.0",
844 "Max motion added to tree. ==> maxDistance_ default: 0.0, if 0.0, set on "
846 planner_des.push_back(lazy_prm);
849 planner_des.push_back(lazy_pr_mstar);
852 spars.addParameter(
"stretch_factor",
"3.0",
853 "roadmap spanner stretch factor. multiplicative upper bound on path "
854 "quality. It does not make sense to make this parameter more than 3. "
856 spars.addParameter(
"sparse_delta_fraction",
"0.25",
857 "delta fraction for connection distance. This value represents "
858 "the visibility range of sparse samples. default: 0.25");
859 spars.addParameter(
"dense_delta_fraction",
"0.001",
"delta fraction for interface detection. default: 0.001");
860 spars.addParameter(
"max_failures",
"1000",
"maximum consecutive failure limit. default: 1000");
861 planner_des.push_back(spars);
864 spar_stwo.addParameter(
"stretch_factor",
"3.0",
865 "roadmap spanner stretch factor. multiplicative upper bound on path "
866 "quality. It does not make sense to make this parameter more than 3. "
868 spar_stwo.addParameter(
"sparse_delta_fraction",
"0.25",
869 "delta fraction for connection distance. This value represents "
870 "the visibility range of sparse samples. default: 0.25");
871 spar_stwo.addParameter(
"dense_delta_fraction",
"0.001",
"delta fraction for interface detection. default: 0.001");
872 spar_stwo.addParameter(
"max_failures",
"5000",
"maximum consecutive failure limit. default: 5000");
873 planner_des.push_back(spar_stwo);
876 aitstar.addParameter(
"use_k_nearest",
"1",
877 "whether to use a k-nearest RGG connection model (1) or an r-disc model (0). Default: 1");
878 aitstar.addParameter(
"rewire_factor",
"1.001",
879 "rewire factor of the RGG. Valid values: [1.0:0.01:3.0]. Default: 1.001");
880 aitstar.addParameter(
"samples_per_batch",
"100",
"batch size. Valid values: [1:1:1000]. Default: 100");
881 aitstar.addParameter(
"use_graph_pruning",
"1",
"enable graph pruning (1) or not (0). Default: 1");
882 aitstar.addParameter(
"find_approximate_solutions",
"0",
"track approximate solutions (1) or not (0). Default: 0");
883 aitstar.addParameter(
"set_max_num_goals",
"1",
884 "maximum number of goals sampled from sampleable goal regions. "
885 "Valid values: [1:1:1000]. Default: 1");
886 planner_des.push_back(aitstar);
889 abitstar.addParameter(
"use_k_nearest",
"1",
890 "whether to use a k-nearest RGG connection model (1) or an r-disc model (0). Default: 1");
891 abitstar.addParameter(
"rewire_factor",
"1.001",
892 "rewire factor of the RGG. Valid values: [1.0:0.01:3.0]. Default: 1.001");
893 abitstar.addParameter(
"samples_per_batch",
"100",
"batch size. Valid values: [1:1:1000]. Default: 100");
894 abitstar.addParameter(
"use_graph_pruning",
"1",
"enable graph pruning (1) or not (0). Default: 1");
895 abitstar.addParameter(
896 "prune_threshold_as_fractional_cost_change",
"0.1",
897 "fractional change in the solution cost AND problem measure necessary for pruning to occur. Default: 0.1");
898 abitstar.addParameter(
"delay_rewiring_to_first_solution",
"0",
899 "delay (1) or not (0) rewiring until a solution is found. Default: 0");
900 abitstar.addParameter(
"use_just_in_time_sampling",
"0",
901 "delay the generation of samples until they are * necessary. Only works with r-disc connection "
902 "and path length minimization. Default: 0");
903 abitstar.addParameter(
"drop_unconnected_samples_on_prune",
"0",
904 "drop unconnected samples when pruning, regardless of their heuristic value. Default: 0");
905 abitstar.addParameter(
"stop_on_each_solution_improvement",
"0",
906 "stop the planner each time a solution improvement is found. Useful for debugging. Default: 0");
907 abitstar.addParameter(
"use_strict_queue_ordering",
"0",
908 "sort edges in the queue at the end of the batch (0) or after each rewiring (1). Default: 0");
909 abitstar.addParameter(
"find_approximate_solutions",
"0",
"track approximate solutions (1) or not (0). Default: 0");
910 abitstar.addParameter(
911 "initial_inflation_factor",
"1000000",
912 "inflation factor for the initial search. Valid values: [1.0:0.01:1000000.0]. Default: 1000000");
913 abitstar.addParameter(
914 "inflation_scaling_parameter",
"10",
915 "scaling parameter for the inflation factor update policy. Valid values: [1.0:0.01:1000000.0]. Default: 0");
916 abitstar.addParameter(
917 "truncation_scaling_parameter",
"5.0",
918 "scaling parameter for the truncation factor update policy. Valid values: [1.0:0.01:1000000.0]. Default: 0");
919 planner_des.push_back(abitstar);
922 bitstar.addParameter(
"use_k_nearest",
"1",
923 "whether to use a k-nearest RGG connection model (1) or an r-disc model (0). Default: 1");
924 bitstar.addParameter(
"rewire_factor",
"1.001",
925 "rewire factor of the RGG. Valid values: [1.0:0.01:3.0]. Default: 1.001");
926 bitstar.addParameter(
"samples_per_batch",
"100",
"batch size. Valid values: [1:1:1000]. Default: 100");
927 bitstar.addParameter(
"use_graph_pruning",
"1",
"enable graph pruning (1) or not (0). Default: 1");
928 bitstar.addParameter(
929 "prune_threshold_as_fractional_cost_change",
"0.1",
930 "fractional change in the solution cost AND problem measure necessary for pruning to occur. Default: 0.1");
931 bitstar.addParameter(
"delay_rewiring_to_first_solution",
"0",
932 "delay (1) or not (0) rewiring until a solution is found. Default: 0");
933 bitstar.addParameter(
"use_just_in_time_sampling",
"0",
934 "delay the generation of samples until they are * necessary. Only works with r-disc connection "
935 "and path length minimization. Default: 0");
936 bitstar.addParameter(
"drop_unconnected_samples_on_prune",
"0",
937 "drop unconnected samples when pruning, regardless of their heuristic value. Default: 0");
938 bitstar.addParameter(
"stop_on_each_solution_improvement",
"0",
939 "stop the planner each time a solution improvement is found. Useful for debugging. Default: 0");
940 bitstar.addParameter(
"use_strict_queue_ordering",
"0",
941 "sort edges in the queue at the end of the batch (0) or after each rewiring (1). Default: 0");
942 bitstar.addParameter(
"find_approximate_solutions",
"0",
"track approximate solutions (1) or not (0). Default: 0");
943 planner_des.push_back(bitstar);
953 YAML::Emitter emitter;
954 emitter << YAML::BeginMap;
955 emitter << YAML::Key <<
"controller_list";
956 emitter << YAML::Value << YAML::BeginSeq;
960 std::string type = controller.type_;
961 if (boost::ends_with(type,
"/JointTrajectoryController"))
962 type =
"FollowJointTrajectory";
963 if (type ==
"FollowJointTrajectory" || type ==
"GripperCommand")
965 emitter << YAML::BeginMap;
966 emitter << YAML::Key <<
"name";
967 emitter << YAML::Value << controller.name_;
968 emitter << YAML::Key <<
"action_ns";
969 emitter << YAML::Value << (type ==
"FollowJointTrajectory" ?
"follow_joint_trajectory" :
"gripper_action");
970 emitter << YAML::Key <<
"type";
971 emitter << YAML::Value << type;
972 emitter << YAML::Key <<
"default";
973 emitter << YAML::Value <<
"True";
976 emitter << YAML::Key <<
"joints";
977 emitter << YAML::Value << YAML::BeginSeq;
979 for (
const std::string& joint : controller.joints_)
981 emitter << YAML::EndSeq;
983 emitter << YAML::EndMap;
986 emitter << YAML::EndSeq;
987 emitter << YAML::EndMap;
989 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
990 if (!output_stream.good())
995 output_stream << emitter.c_str();
996 output_stream.close();
1006 if (!
srdf_->group_states_.empty())
1007 return srdf_->group_states_[0];
1018 std::vector<std::vector<std::string>> planning_groups;
1024 std::vector<std::string> group_joints;
1027 const std::vector<const moveit::core::JointModel*>& joint_models = joint_model_group->
getActiveJointModels();
1034 group_joints.push_back(joint->getName());
1037 planning_groups.push_back(group_joints);
1040 YAML::Emitter emitter;
1041 emitter << YAML::BeginMap;
1044 #if 0 // TODO: This is only for fake ROS controllers, which should go into a separate file
1046 emitter << YAML::Comment(
"Simulation settings for using moveit_sim_controllers");
1047 emitter << YAML::Key <<
"moveit_sim_hw_interface" << YAML::Value << YAML::BeginMap;
1051 emitter << YAML::Key <<
"joint_model_group";
1055 emitter << YAML::Key <<
"joint_model_group_pose";
1058 emitter << YAML::EndMap;
1061 emitter << YAML::Newline;
1062 emitter << YAML::Comment(
"Settings for ros_control_boilerplate control loop");
1063 emitter << YAML::Key <<
"generic_hw_control_loop" << YAML::Value << YAML::BeginMap;
1065 emitter << YAML::Key <<
"loop_hz";
1066 emitter << YAML::Value <<
"300";
1067 emitter << YAML::Key <<
"cycle_time_error_threshold";
1068 emitter << YAML::Value <<
"0.01";
1069 emitter << YAML::EndMap;
1072 emitter << YAML::Newline;
1073 emitter << YAML::Comment(
"Settings for ros_control hardware interface");
1074 emitter << YAML::Key <<
"hardware_interface" << YAML::Value << YAML::BeginMap;
1077 const std::vector<const moveit::core::JointModel*>& joint_models =
getRobotModel()->getJointModels();
1079 emitter << YAML::Key <<
"joints";
1081 if (joint_models.size() != 1)
1083 emitter << YAML::Value << YAML::BeginSeq;
1085 for (std::vector<const moveit::core::JointModel*>::const_iterator joint_it = joint_models.begin();
1086 joint_it < joint_models.end(); ++joint_it)
1088 if ((*joint_it)->isPassive() || (*joint_it)->getMimic() !=
nullptr ||
1092 emitter << (*joint_it)->getName();
1094 emitter << YAML::EndSeq;
1098 emitter << YAML::Value << YAML::BeginMap;
1099 emitter << joint_models[0]->getName();
1100 emitter << YAML::EndMap;
1103 emitter << YAML::Key <<
"sim_control_mode";
1104 emitter << YAML::Value <<
"1";
1105 emitter << YAML::Comment(
"0: position, 1: velocity");
1106 emitter << YAML::Newline;
1107 emitter << YAML::EndMap;
1112 if (controller.type_ ==
"FollowJointTrajectory" || controller.type_ ==
"GripperCommand")
1115 emitter << YAML::Key << controller.name_;
1116 emitter << YAML::Value << YAML::BeginMap;
1117 emitter << YAML::Key <<
"type";
1118 emitter << YAML::Value << controller.type_;
1121 emitter << YAML::Key <<
"joints";
1122 emitter << YAML::Value << YAML::BeginSeq;
1124 for (
const std::string& joint : controller.joints_)
1126 emitter << YAML::EndSeq;
1129 emitter << YAML::Key <<
"gains";
1130 emitter << YAML::Value << YAML::BeginMap;
1133 for (
const std::string& joint : controller.joints_)
1135 emitter << YAML::Key << joint << YAML::Value << YAML::BeginMap;
1136 emitter << YAML::Key <<
"p";
1137 emitter << YAML::Value <<
"100";
1138 emitter << YAML::Key <<
"d";
1139 emitter << YAML::Value <<
"1";
1140 emitter << YAML::Key <<
"i";
1141 emitter << YAML::Value <<
"1";
1142 emitter << YAML::Key <<
"i_clamp";
1143 emitter << YAML::Value <<
"1" << YAML::EndMap;
1145 emitter << YAML::EndMap;
1147 emitter << YAML::EndMap;
1151 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
1152 if (!output_stream.good())
1157 output_stream << emitter.c_str();
1158 output_stream.close();
1168 YAML::Emitter emitter;
1170 emitter << YAML::BeginMap;
1171 emitter << YAML::Key <<
"sensors";
1172 emitter << YAML::Value << YAML::BeginSeq;
1176 emitter << YAML::BeginMap;
1178 for (
auto& parameter : sensors_plugin_config)
1180 emitter << YAML::Key << parameter.first;
1181 emitter << YAML::Value << parameter.second.getValue();
1183 emitter << YAML::EndMap;
1186 emitter << YAML::EndSeq;
1188 emitter << YAML::EndMap;
1190 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
1191 if (!output_stream.good())
1197 output_stream << emitter.c_str();
1198 output_stream.close();
1208 YAML::Emitter emitter;
1209 emitter << YAML::Comment(
"joint_limits.yaml allows the dynamics properties specified in the URDF "
1210 "to be overwritten or augmented as needed");
1211 emitter << YAML::Newline;
1213 emitter << YAML::BeginMap;
1215 emitter << YAML::Comment(
"For beginners, we downscale velocity and acceleration limits.") << YAML::Newline;
1216 emitter << YAML::Comment(
"You can always specify higher scaling factors (<= 1.0) in your motion requests.");
1217 emitter << YAML::Comment(
"Increase the values below to 1.0 to always move at maximum speed.");
1218 emitter << YAML::Key <<
"default_velocity_scaling_factor";
1219 emitter << YAML::Value <<
"0.1";
1221 emitter << YAML::Key <<
"default_acceleration_scaling_factor";
1222 emitter << YAML::Value <<
"0.1";
1224 emitter << YAML::Newline << YAML::Newline;
1225 emitter << YAML::Comment(
"Specific joint properties can be changed with the keys "
1226 "[max_position, min_position, max_velocity, max_acceleration]")
1228 emitter << YAML::Comment(
"Joint limits can be turned off with [has_velocity_limits, has_acceleration_limits]");
1230 emitter << YAML::Key <<
"joint_limits";
1231 emitter << YAML::Value << YAML::BeginMap;
1234 std::set<const moveit::core::JointModel*, JointModelCompare> joints;
1242 const std::vector<const moveit::core::JointModel*>& joint_models = joint_model_group->
getJointModels();
1248 if (joint_model->getVariableCount() == 1)
1249 joints.insert(joint_model);
1256 emitter << YAML::Key << joint->getName();
1257 emitter << YAML::Value << YAML::BeginMap;
1262 emitter << YAML::Key <<
"has_velocity_limits";
1264 emitter << YAML::Value <<
"true";
1266 emitter << YAML::Value <<
"false";
1269 emitter << YAML::Key <<
"max_velocity";
1273 emitter << YAML::Key <<
"has_acceleration_limits";
1275 emitter << YAML::Value <<
"true";
1277 emitter << YAML::Value <<
"false";
1280 emitter << YAML::Key <<
"max_acceleration";
1283 emitter << YAML::EndMap;
1286 emitter << YAML::EndMap;
1288 std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc);
1289 if (!output_stream.good())
1294 output_stream << emitter.c_str();
1295 output_stream.close();
1305 std::string joint_pair =
"";
1308 const moveit::core::RobotModelConstPtr& model =
getRobotModel();
1311 if (!model->hasJointModelGroup(planning_group))
1318 const std::vector<std::string>& joints =
group->getJointModelNames();
1320 if (joints.size() >= 2)
1323 if (
group->getJointModel(joints[0])->getVariableCount() == 1 &&
1324 group->getJointModel(joints[1])->getVariableCount() == 1)
1327 joint_pair =
"joints(" + joints[0] +
"," + joints[1] +
")";
1334 template <
typename T>
1335 bool parse(
const YAML::Node& node,
const std::string& key, T& storage,
const T& default_value = T())
1337 const YAML::Node& n = node[key];
1338 bool valid = n.IsDefined();
1346 std::ifstream input_stream(file_path.c_str());
1347 if (!input_stream.good())
1356 YAML::Node doc = YAML::Load(input_stream);
1359 for (YAML::const_iterator group_it = doc.begin(); group_it != doc.end(); ++group_it)
1362 const std::string group_name = group_it->first.as<std::string>();
1365 std::map<std::string, GroupMetaData>::iterator group_meta_it;
1369 std::string planner;
1370 parse(group_it->second,
"default_planner_config", planner);
1371 std::size_t pos = planner.find(
"kConfigDefault");
1372 if (pos != std::string::npos)
1374 planner = planner.substr(0, pos);
1380 catch (YAML::ParserException& e)
1394 std::ifstream input_stream(file_path.c_str());
1395 if (!input_stream.good())
1404 YAML::Node doc = YAML::Load(input_stream);
1407 for (YAML::const_iterator group_it = doc.begin(); group_it != doc.end(); ++group_it)
1409 const std::string& group_name = group_it->first.as<std::string>();
1410 const YAML::Node
group = group_it->second;
1413 GroupMetaData meta_data;
1415 parse(group,
"kinematics_solver", meta_data.kinematics_solver_);
1416 parse(group,
"kinematics_solver_search_resolution", meta_data.kinematics_solver_search_resolution_,
1419 parse(group,
"goal_joint_tolerance", meta_data.goal_joint_tolerance_,
1421 parse(group,
"goal_position_tolerance", meta_data.goal_position_tolerance_,
1423 parse(group,
"goal_orientation_tolerance", meta_data.goal_orientation_tolerance_,
1430 catch (YAML::ParserException& e)
1444 TiXmlDocument launch_document(file_path);
1445 if (!launch_document.LoadFile())
1452 TiXmlHandle doc(&launch_document);
1453 TiXmlElement* kinematics_group = doc.FirstChild(
"launch").FirstChild(
"group").ToElement();
1454 while (kinematics_group && kinematics_group->Attribute(
"ns") &&
1455 kinematics_group->Attribute(
"ns") != std::string(
"$(arg robot_description)_kinematics"))
1457 kinematics_group = kinematics_group->NextSiblingElement(
"group");
1459 if (!kinematics_group)
1461 ROS_ERROR(
"<group ns=\"$(arg robot_description)_kinematics\"> not found");
1467 for (TiXmlElement* kinematics_parameter_file = kinematics_group->FirstChildElement(
"rosparam");
1468 kinematics_parameter_file; kinematics_parameter_file = kinematics_parameter_file->NextSiblingElement(
"rosparam"))
1470 const char* ns = kinematics_parameter_file->Attribute(
"ns");
1473 group_meta_data_[ns].kinematics_parameters_file_ = kinematics_parameter_file->Attribute(
"file");
1486 ControllerConfig control_setting;
1488 if (
const YAML::Node& trajectory_controllers = controller)
1490 for (
const YAML::Node& trajectory_controller : trajectory_controllers)
1493 if (
const YAML::Node& controller_node = trajectory_controller)
1495 if (
const YAML::Node& joints = controller_node[
"joints"])
1497 control_setting.joints_.clear();
1498 for (YAML::const_iterator joint_it = joints.begin(); joint_it != joints.end(); ++joint_it)
1500 control_setting.joints_.push_back(joint_it->as<std::string>());
1502 if (!
parse(controller_node,
"name", control_setting.name_))
1507 if (!
parse(controller_node,
"type", control_setting.type_))
1532 ControllerConfig control_setting;
1533 YAML::Node controllers = YAML::Load(input_stream);
1536 for (YAML::const_iterator controller_it = controllers.begin(); controller_it != controllers.end(); ++controller_it)
1539 if (controller_it->first.as<std::string>() ==
"controller_list")
1547 const std::string& controller_name = controller_it->first.as<std::string>();
1548 control_setting.joints_.clear();
1551 if (
const YAML::Node& joints = controller_it->second[
"joints"])
1553 if (joints.IsSequence())
1555 for (YAML::const_iterator joint_it = joints.begin(); joint_it != joints.end(); ++joint_it)
1557 control_setting.joints_.push_back(joint_it->as<std::string>());
1562 control_setting.joints_.push_back(joints.as<std::string>());
1567 if (!control_setting.joints_.empty())
1569 if (
const YAML::Node& urdf_node = controller_it->second[
"type"])
1571 control_setting.type_ = controller_it->second[
"type"].as<std::string>();
1572 control_setting.name_ = controller_name;
1574 control_setting.joints_.clear();
1588 std::ifstream input_stream(file_path.c_str());
1589 if (!input_stream.good())
1600 catch (YAML::ParserException& e)
1614 if (
srdf_->srdf_model_->getGroups().empty())
1622 const std::vector<const moveit::core::JointModel*>& joint_models = joint_model_group->
getActiveJointModels();
1629 group_controller.
joints_.push_back(joint->getName());
1631 if (!group_controller.
joints_.empty())
1633 group_controller.
name_ = group_it.name_ +
"_controller";
1634 group_controller.
type_ = controller_type;
1646 std::string full_package_path;
1649 if (!fs::is_directory(pkg_path))
1655 if (!fs::is_directory(full_package_path))
1663 full_package_path = pkg_path;
1676 std::string& relative_filepath)
const
1678 fs::path sub_path = path;
1679 fs::path relative_path;
1681 bool package_found =
false;
1684 while (!sub_path.empty())
1687 if (fs::is_regular_file(sub_path /
"package.xml"))
1689 ROS_DEBUG_STREAM(
"Found package.xml in " << sub_path.make_preferred().string());
1690 package_found =
true;
1691 relative_filepath = relative_path.string();
1692 package_name = sub_path.filename().string();
1695 relative_path = sub_path.filename() / relative_path;
1696 sub_path.remove_filename();
1706 ROS_DEBUG_STREAM(
"Package name for file \"" << path <<
"\" is \"" << package_name <<
"\"");
1719 return fs::is_regular_file(path);
1740 if (robot_desc_pkg_path.empty())
1770 std::ifstream input_stream(file_path.c_str());
1771 if (!input_stream.good())
1780 const YAML::Node& doc = YAML::Load(input_stream);
1783 if (
const YAML::Node& title_node = doc[
"moveit_setup_assistant_config"])
1786 if (
const YAML::Node& urdf_node = title_node[
"URDF"])
1797 if (
const YAML::Node& srdf_node = title_node[
"SRDF"])
1803 if (
const YAML::Node& config_node = title_node[
"CONFIG"])
1812 catch (YAML::ParserException& e)
1833 std::vector<std::map<std::string, GenericParameter>>
config;
1836 if (file_path.empty())
1840 std::ifstream input_stream(file_path.c_str());
1841 if (!input_stream.good())
1850 const YAML::Node& doc = YAML::Load(input_stream);
1852 const YAML::Node& sensors_node = doc[
"sensors"];
1855 if (sensors_node && sensors_node.IsSequence())
1858 for (
const YAML::Node& sensor : sensors_node)
1860 std::map<std::string, GenericParameter> sensor_map;
1861 bool empty_node =
true;
1862 for (YAML::const_iterator sensor_it = sensor.begin(); sensor_it != sensor.end(); ++sensor_it)
1866 sensor_param.
setName(sensor_it->first.as<std::string>());
1867 sensor_param.
setValue(sensor_it->second.as<std::string>());
1870 sensor_map[sensor_it->first.as<std::string>()] = sensor_param;
1874 config.push_back(sensor_map);
1878 catch (YAML::ParserException& e)
1891 fs::path result = path1;
1893 return result.make_preferred().string();
1903 if (
group.name_ == name)
1905 searched_group = &
group;
1911 if (searched_group ==
nullptr)
1912 ROS_FATAL_STREAM(
"An internal error has occured while searching for groups. Group '" << name
1913 <<
"' was not found "
1916 return searched_group;
1927 if (controller.name_ == controller_name)
1942 if (controller_it->name_ == controller_name)
1960 if (controller && controller->
type_ == new_controller.
type_)
1971 const std::string& )