diff --git a/src/robot_control/launch/gazebo_gui.launch.py b/src/robot_control/launch/gazebo_gui.launch.py index d60ad89..502cb57 100644 --- a/src/robot_control/launch/gazebo_gui.launch.py +++ b/src/robot_control/launch/gazebo_gui.launch.py @@ -146,7 +146,6 @@ def generate_launch_description(): {"use_sim_time": True}, {"moveit_current_state_monitor.joint_state_qos": "sensor_data"}, ], # Pass the MoveIt config to the GUI node - # arguments=['--ros-args', '--log-level', 'debug'], ) # Return the LaunchDescription diff --git a/src/robot_control/launch/moveit_control.launch.py b/src/robot_control/launch/moveit_control.launch.py index 43b60bc..a0cb24e 100644 --- a/src/robot_control/launch/moveit_control.launch.py +++ b/src/robot_control/launch/moveit_control.launch.py @@ -8,6 +8,7 @@ import os from launch import LaunchDescription +from ament_index_python.packages import get_package_share_directory from launch_ros.actions import Node from moveit_configs_utils import MoveItConfigsBuilder @@ -22,11 +23,22 @@ def generate_launch_description(): @return LaunchDescription object containing the nodes to launch. """ - # Load the MoveIt configuration using MoveItConfigsBuilder + # Specify the name of the package and path to xacro file within the package + pkg_name = "robot_description" # Name of the robot description package + share_dir = get_package_share_directory( + pkg_name + ) # Get the share directory of the package + + # Use xacro to process the file + xacro_file = os.path.join( + share_dir, "urdf", "r5a_v_ros.urdf.xacro" + ) # Full path to the XACRO file + + # MoveIt configuration using MoveItConfigsBuilder moveit_config = ( MoveItConfigsBuilder("robot_moveit_config", package_name="robot_moveit_config") .robot_description( - file_path="config/r5a_v_ros.urdf.xacro", mappings={"use_sim_time": "true"} + file_path=xacro_file, mappings={"use_sim_time": "true"} ) .robot_description_semantic("config/armr5.srdf") .robot_description_kinematics("config/kinematics.yaml") diff --git a/src/robot_control/launch/moveit_control2.launch.py b/src/robot_control/launch/moveit_control2.launch.py index 7775394..f1adaa4 100644 --- a/src/robot_control/launch/moveit_control2.launch.py +++ b/src/robot_control/launch/moveit_control2.launch.py @@ -8,6 +8,7 @@ import os from launch import LaunchDescription +from ament_index_python.packages import get_package_share_directory from launch_ros.actions import Node from moveit_configs_utils import MoveItConfigsBuilder @@ -21,11 +22,22 @@ def generate_launch_description(): @return LaunchDescription object containing the robot control node. """ - # Load the MoveIt configuration using MoveItConfigsBuilder + # Specify the name of the package and path to xacro file within the package + pkg_name = "robot_description" # Name of the robot description package + share_dir = get_package_share_directory( + pkg_name + ) # Get the share directory of the package + + # Use xacro to process the file + xacro_file = os.path.join( + share_dir, "urdf", "r5a_v_ros.urdf.xacro" + ) # Full path to the XACRO file + + # MoveIt configuration using MoveItConfigsBuilder moveit_config = ( MoveItConfigsBuilder("robot_moveit_config", package_name="robot_moveit_config") .robot_description( - file_path="config/r5a_v_ros.urdf.xacro", mappings={"use_sim_time": "true"} + file_path=xacro_file, mappings={"use_sim_time": "true"} ) .robot_description_semantic("config/armr5.srdf") .robot_description_kinematics("config/kinematics.yaml") diff --git a/src/robot_control/launch/moveit_control_gui.launch.py b/src/robot_control/launch/moveit_control_gui.launch.py index a129112..55c4fc1 100644 --- a/src/robot_control/launch/moveit_control_gui.launch.py +++ b/src/robot_control/launch/moveit_control_gui.launch.py @@ -8,6 +8,7 @@ import os from launch import LaunchDescription +from ament_index_python.packages import get_package_share_directory from launch_ros.actions import Node from moveit_configs_utils import MoveItConfigsBuilder @@ -22,11 +23,22 @@ def generate_launch_description(): @return LaunchDescription object containing the GUI node. """ - # Load the MoveIt configuration using MoveItConfigsBuilder + # Specify the name of the package and path to xacro file within the package + pkg_name = "robot_description" # Name of the robot description package + share_dir = get_package_share_directory( + pkg_name + ) # Get the share directory of the package + + # Use xacro to process the file + xacro_file = os.path.join( + share_dir, "urdf", "r5a_v_ros.urdf.xacro" + ) # Full path to the XACRO file + + # MoveIt configuration using MoveItConfigsBuilder moveit_config = ( MoveItConfigsBuilder("robot_moveit_config", package_name="robot_moveit_config") .robot_description( - file_path="config/r5a_v_ros.urdf.xacro", mappings={"use_sim_time": "true"} + file_path=xacro_file, mappings={"use_sim_time": "true"} ) .robot_description_semantic("config/armr5.srdf") .robot_description_kinematics("config/kinematics.yaml") diff --git a/src/robot_control/launch/visual_sim.launch.py b/src/robot_control/launch/visual_sim.launch.py index 5b7f436..eab1ad7 100644 --- a/src/robot_control/launch/visual_sim.launch.py +++ b/src/robot_control/launch/visual_sim.launch.py @@ -32,9 +32,9 @@ def generate_launch_description(): This function sets up the robot description, launches Gazebo with a custom world file, spawns the robot entity, configures MoveIt, and starts the necessary nodes and controllers, including the GUI node, object detector node, and visual joint state publisher node. - + It now accepts a parameter 'num_cameras' to determine whether to launch the single or double ArUco detector. - + @return LaunchDescription object containing all the nodes and configurations to launch. """ @@ -77,7 +77,7 @@ def generate_launch_description(): parameters=[robot_description, {"use_sim_time": True}], ) - # Gazebo launch with a custom world file that includes a spotlight + # Gazebo Launch world_file_path = os.path.join( share_dir, "worlds", "spotlight.world" ) # Path to the custom world file @@ -156,7 +156,6 @@ def generate_launch_description(): ) load_gripper_controller = ExecuteProcess( - cmd=[ "ros2", "control", @@ -166,8 +165,8 @@ def generate_launch_description(): "gripper_controller", ], output="screen", - ) + # Launch the GUI Node gui_node = Node( package="robot_control", # Package name containing the GUI node @@ -177,7 +176,7 @@ def generate_launch_description(): moveit_config.to_dict(), {"use_sim_time": True}, {"moveit_current_state_monitor.joint_state_qos": "sensor_data"}, - ], # Pass MoveIt config to the GUI node + ], # Pass the MoveIt config to the GUI node ) # Aruco Detector Single Node @@ -220,7 +219,6 @@ def generate_launch_description(): output='screen', parameters=[{'use_sim_time': True}] ), - SetParameter(name="use_sim_time", value=True), # Enable simulation time RegisterEventHandler( event_handler=OnProcessExit( @@ -237,8 +235,10 @@ def generate_launch_description(): RegisterEventHandler( event_handler=OnProcessExit( target_action=load_arm_controller, - on_exit=[load_gripper_controller, move_group_node], # Load gripper controller before move group - + on_exit=[ + load_gripper_controller, + move_group_node + ], # Load gripper controller before move group ) ), RegisterEventHandler( diff --git a/src/robot_description/launch/gazebo.launch.py b/src/robot_description/launch/gazebo.launch.py index 249b408..f5ac216 100644 --- a/src/robot_description/launch/gazebo.launch.py +++ b/src/robot_description/launch/gazebo.launch.py @@ -34,7 +34,6 @@ def generate_launch_description(): # Specify the name of the package and path to xacro file within the package pkg_name = "robot_description" # Name of the robot description package - share_dir = get_package_share_directory( pkg_name ) # Get the share directory of the package @@ -58,6 +57,7 @@ def generate_launch_description(): {"use_sim_time": True}, ], # Parameters ) + # Node to spawn the entity in Gazebo spawn_entity = Node( package="gazebo_ros", # Package containing the node @@ -70,6 +70,7 @@ def generate_launch_description(): ], # Arguments for spawning output="screen", ) + # Include the Gazebo launch file gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource( @@ -92,6 +93,7 @@ def generate_launch_description(): ], # Command to load and activate joint_state_broadcaster output="screen", ) + load_arm_controller = ExecuteProcess( cmd=[ "ros2", diff --git a/src/robot_description/launch/gazebo_move.launch.py b/src/robot_description/launch/gazebo_move.launch.py index 6e55f44..9b8d312 100644 --- a/src/robot_description/launch/gazebo_move.launch.py +++ b/src/robot_description/launch/gazebo_move.launch.py @@ -111,7 +111,7 @@ def generate_launch_description(): moveit_config = ( MoveItConfigsBuilder("robot_moveit_config", package_name="robot_moveit_config") .robot_description( - file_path="config/r5a_v_ros.urdf.xacro", mappings={"use_sim_time": "true"} + file_path=xacro_file, mappings={"use_sim_time": "true"} ) .robot_description_semantic("config/armr5.srdf") .robot_description_kinematics("config/kinematics.yaml")