moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
hybrid_planning_common.py
Go to the documentation of this file.
1# Return a list of nodes we commonly launch for the demo. Nice for testing use.
2import os
3import yaml
4
5from ament_index_python.packages import get_package_share_directory
6from launch_ros.descriptions import ComposableNode
7from launch_ros.actions import ComposableNodeContainer
8from moveit_configs_utils import MoveItConfigsBuilder
9
10
11def load_yaml(package_name, file_path):
12 package_path = get_package_share_directory(package_name)
13 absolute_file_path = os.path.join(package_path, file_path)
14
15 try:
16 with open(absolute_file_path, "r") as file:
17 return yaml.safe_load(file)
18 except (
19 EnvironmentError
20 ): # parent of IOError, OSError *and* WindowsError where available
21 return None
22
23
25 # Load the moveit configuration
26 moveit_config = (
27 MoveItConfigsBuilder("moveit_resources_panda")
28 .robot_description(file_path="config/panda.urdf.xacro")
30 publish_robot_description=True, publish_robot_description_semantic=True
31 )
32 .planning_pipelines("ompl", ["ompl"])
33 .trajectory_execution(file_path="config/moveit_controllers.yaml")
34 .to_moveit_configs()
35 )
36
37 # Hybrid planning parameter
38 # Any parameters that are unique to your plugins go here
39 global_planner_param = load_yaml(
40 "moveit_hybrid_planning", "config/global_planner.yaml"
41 )
42 local_planner_param = load_yaml(
43 "moveit_hybrid_planning", "config/local_planner.yaml"
44 )
45 hybrid_planning_manager_param = load_yaml(
46 "moveit_hybrid_planning", "config/hybrid_planning_manager.yaml"
47 )
48
49 # Generate launch description with multiple components
50 container = ComposableNodeContainer(
51 name="hybrid_planning_container",
52 namespace="/",
53 package="rclcpp_components",
54 executable="component_container_mt",
55 composable_node_descriptions=[
56 ComposableNode(
57 package="moveit_hybrid_planning",
58 plugin="moveit::hybrid_planning::GlobalPlannerComponent",
59 name="global_planner",
60 parameters=[
61 global_planner_param,
62 moveit_config.to_dict(),
63 ],
64 ),
65 ComposableNode(
66 package="moveit_hybrid_planning",
67 plugin="moveit::hybrid_planning::LocalPlannerComponent",
68 name="local_planner",
69 parameters=[
70 local_planner_param,
71 moveit_config.to_dict(),
72 ],
73 ),
74 ComposableNode(
75 package="moveit_hybrid_planning",
76 plugin="moveit::hybrid_planning::HybridPlanningManager",
77 name="hybrid_planning_manager",
78 parameters=[
79 hybrid_planning_manager_param,
80 ],
81 ),
82 ],
83 output="screen",
84 )
85
86 launched_nodes = [
87 container,
88 ]
89
90 return launched_nodes