From 99ed6f00323e2d581f191014505d1bb734a82008 Mon Sep 17 00:00:00 2001 From: Adrian Ricardez Ortigosa Date: Tue, 5 Aug 2025 14:26:00 +0200 Subject: [PATCH 1/5] custom spawn positions arguments for gz --- rox_bringup/launch/bringup_sim_launch.py | 61 ++++++++++++++++++++---- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/rox_bringup/launch/bringup_sim_launch.py b/rox_bringup/launch/bringup_sim_launch.py index ad70e27..4f9ace6 100644 --- a/rox_bringup/launch/bringup_sim_launch.py +++ b/rox_bringup/launch/bringup_sim_launch.py @@ -7,7 +7,8 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction, AppendEnvironmentVariable from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration, Command +from launch.conditions import IfCondition +from launch.substitutions import LaunchConfiguration, Command, PathJoinSubstitution from launch_ros.actions import Node from launch.launch_context import LaunchContext from launch_ros.descriptions import ParameterValue @@ -15,6 +16,7 @@ import os from pathlib import Path import xacro +from launch_ros.substitutions import FindPackageShare def execution_stage(context: LaunchContext, rox_type, @@ -24,7 +26,9 @@ def execution_stage(context: LaunchContext, scanner_type, ur_dc, gripper_type, - headless_sim): + headless_sim, + spawn_x, spawn_y, spawn_z, + spawn_R, spawn_P, spawn_Y): launch_actions = [] @@ -48,7 +52,9 @@ def execution_stage(context: LaunchContext, joint_type = "revolute" # Getting the robot description xacro - urdf = os.path.join(get_package_share_directory('rox_description'), 'urdf', 'rox.urdf.xacro') + urdf = os.path.join(get_package_share_directory('rox_description'), + 'urdf', + 'rox.urdf.xacro') spawn_robot = Node( package='ros_gz_sim', @@ -57,7 +63,15 @@ def execution_stage(context: LaunchContext, output='screen', arguments=[ '-topic', "robot_description", - '-name', "rox"]) + '-name', "rox", + '-x', spawn_x.perform(context), + '-y', spawn_y.perform(context), + '-z', spawn_z.perform(context), + '-R', spawn_R.perform(context), + '-P', spawn_P.perform(context), + '-Y', spawn_Y.perform(context) + ] + ) # Define gz_args based on headless_simulation argument gz_args = f"-r {default_world_path}" @@ -148,7 +162,7 @@ def execution_stage(context: LaunchContext, output='screen', prefix = 'xterm -e', name='teleop', - parameters=[{'stamped': False}] # Set stamped parameter to true for TwistStamped /cmd_vel + parameters=[{'stamped': True}] # Set stamped parameter to true for TwistStamped /cmd_vel ) gz_bridge = Node( @@ -215,8 +229,8 @@ def execution_stage(context: LaunchContext, # Set environment variable for gripper description packages if gripper_typ == 'epick': env_var_value += ':' + os.path.dirname(get_package_share_directory('epick_description')) - else: - env_var_value += ':' + os.path.dirname(get_package_share_directory('robotiq_description')) + #else: # commented out just for debugging + # env_var_value += ':' + os.path.dirname(get_package_share_directory('robotiq_description')) set_env_vars_resources = AppendEnvironmentVariable('GZ_SIM_RESOURCE_PATH', env_var_value) @@ -239,6 +253,25 @@ def execution_stage(context: LaunchContext, def generate_launch_description(): + declare_spawn_x_cmd = DeclareLaunchArgument( + 'spawn_x', default_value='0.0', description='Initial X position of the robot in gz' + ) + declare_spawn_y_cmd = DeclareLaunchArgument( + 'spawn_y', default_value='0.0', description='Initial Y position of the robot in gz' + ) + declare_spawn_z_cmd = DeclareLaunchArgument( + 'spawn_z', default_value='0.1', description='Initial Z position of the robot in gz' + ) + declare_spawn_R_cmd = DeclareLaunchArgument( + 'spawn_R', default_value='0.0', description='Initial roll of the robot in gz' + ) + declare_spawn_P_cmd = DeclareLaunchArgument( + 'spawn_P', default_value='0.0', description='Initial pitch of the robot in gz' + ) + declare_spawn_Y_cmd = DeclareLaunchArgument( + 'spawn_Y', default_value='0.0', description='Initial yaw of the robot in gz' + ) + declare_rox_type_cmd = DeclareLaunchArgument( 'rox_type',default_value='argo', choices = ['', 'argo', 'argo-trio', 'diff', 'trike'], @@ -293,7 +326,13 @@ def generate_launch_description(): LaunchConfiguration('scanner_type'), LaunchConfiguration('use_ur_dc'), LaunchConfiguration('gripper_type'), - LaunchConfiguration('headless_simulation') + LaunchConfiguration('headless_simulation'), + LaunchConfiguration('spawn_x'), + LaunchConfiguration('spawn_y'), + LaunchConfiguration('spawn_z'), + LaunchConfiguration('spawn_R'), + LaunchConfiguration('spawn_P'), + LaunchConfiguration('spawn_Y'), ]) ld = LaunchDescription([ @@ -305,6 +344,12 @@ def generate_launch_description(): declare_ur_pwr_variant_cmd, declare_gripper_type_cmd, declare_headless_sim_cmd, + declare_spawn_x_cmd, + declare_spawn_y_cmd, + declare_spawn_z_cmd, + declare_spawn_R_cmd, + declare_spawn_P_cmd, + declare_spawn_Y_cmd, opq_function ]) return ld From bff54aae2dc2295067dbc1a232a9844a20e91211 Mon Sep 17 00:00:00 2001 From: Adrian Ricardez Ortigosa Date: Tue, 5 Aug 2025 14:38:14 +0200 Subject: [PATCH 2/5] removed unused libraries --- rox_bringup/launch/bringup_sim_launch.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rox_bringup/launch/bringup_sim_launch.py b/rox_bringup/launch/bringup_sim_launch.py index 4f9ace6..aca4382 100644 --- a/rox_bringup/launch/bringup_sim_launch.py +++ b/rox_bringup/launch/bringup_sim_launch.py @@ -8,15 +8,13 @@ from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction, AppendEnvironmentVariable from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.conditions import IfCondition -from launch.substitutions import LaunchConfiguration, Command, PathJoinSubstitution +from launch.substitutions import LaunchConfiguration, Command from launch_ros.actions import Node from launch.launch_context import LaunchContext from launch_ros.descriptions import ParameterValue from param_file_utils import generate_final_yaml import os from pathlib import Path -import xacro -from launch_ros.substitutions import FindPackageShare def execution_stage(context: LaunchContext, rox_type, From 61f46516048ba1de6c546311e79e43f7192499d8 Mon Sep 17 00:00:00 2001 From: Adrian Ricardez Ortigosa Date: Tue, 5 Aug 2025 14:40:11 +0200 Subject: [PATCH 3/5] origin z spawn position --- rox_bringup/launch/bringup_sim_launch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rox_bringup/launch/bringup_sim_launch.py b/rox_bringup/launch/bringup_sim_launch.py index aca4382..c33ba04 100644 --- a/rox_bringup/launch/bringup_sim_launch.py +++ b/rox_bringup/launch/bringup_sim_launch.py @@ -258,7 +258,7 @@ def generate_launch_description(): 'spawn_y', default_value='0.0', description='Initial Y position of the robot in gz' ) declare_spawn_z_cmd = DeclareLaunchArgument( - 'spawn_z', default_value='0.1', description='Initial Z position of the robot in gz' + 'spawn_z', default_value='0.0', description='Initial Z position of the robot in gz' ) declare_spawn_R_cmd = DeclareLaunchArgument( 'spawn_R', default_value='0.0', description='Initial roll of the robot in gz' From bb9158fb08bc1db35250c35d23e087af8523195b Mon Sep 17 00:00:00 2001 From: Adrian Ricardez Ortigosa Date: Tue, 5 Aug 2025 14:41:08 +0200 Subject: [PATCH 4/5] removed IfCondition library --- rox_bringup/launch/bringup_sim_launch.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rox_bringup/launch/bringup_sim_launch.py b/rox_bringup/launch/bringup_sim_launch.py index c33ba04..978734d 100644 --- a/rox_bringup/launch/bringup_sim_launch.py +++ b/rox_bringup/launch/bringup_sim_launch.py @@ -7,7 +7,6 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction, AppendEnvironmentVariable from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.conditions import IfCondition from launch.substitutions import LaunchConfiguration, Command from launch_ros.actions import Node from launch.launch_context import LaunchContext From 95fc0eff4ff373e5b2a743337833112f623b5412 Mon Sep 17 00:00:00 2001 From: Adrian Ricardez Ortigosa Date: Tue, 5 Aug 2025 14:43:11 +0200 Subject: [PATCH 5/5] xterm to originally 'False' --- rox_bringup/launch/bringup_sim_launch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rox_bringup/launch/bringup_sim_launch.py b/rox_bringup/launch/bringup_sim_launch.py index 978734d..6869fef 100644 --- a/rox_bringup/launch/bringup_sim_launch.py +++ b/rox_bringup/launch/bringup_sim_launch.py @@ -159,7 +159,7 @@ def execution_stage(context: LaunchContext, output='screen', prefix = 'xterm -e', name='teleop', - parameters=[{'stamped': True}] # Set stamped parameter to true for TwistStamped /cmd_vel + parameters=[{'stamped': False}] # Set stamped parameter to true for TwistStamped /cmd_vel ) gz_bridge = Node( @@ -226,8 +226,8 @@ def execution_stage(context: LaunchContext, # Set environment variable for gripper description packages if gripper_typ == 'epick': env_var_value += ':' + os.path.dirname(get_package_share_directory('epick_description')) - #else: # commented out just for debugging - # env_var_value += ':' + os.path.dirname(get_package_share_directory('robotiq_description')) + else: + env_var_value += ':' + os.path.dirname(get_package_share_directory('robotiq_description')) set_env_vars_resources = AppendEnvironmentVariable('GZ_SIM_RESOURCE_PATH', env_var_value)