ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to call launch file with parameters from another launch file?

asked 2021-10-22 08:38:23 -0500

bhomaidan gravatar image

updated 2021-10-22 09:03:38 -0500

Thomas D gravatar image

I have a launch file:

<?xml version="1.0" encoding="utf-8"?>
<launch>
  <!-- Name of the world -->
  <arg name="world" default="empty"/>
  <!-- Path to the world file -->
  <arg name="world_file" default="$(find smb_gazebo)/worlds/$(arg world).world"/>
  <!-- Set the initial pose of the robot's main body -->
  <arg name="x"                                     default="0.0"/>
  <arg name="y"                                     default="0.0"/>
  <arg name="z"                                     default="0.4"/>
  <arg name="roll"                                  default="0.0"/>
  <arg name="pitch"                                 default="0.0"/>
  <arg name="yaw"                                   default="0.0"/>
  <!-- Start paused -->
  <arg name="paused"                                default="false"/>
  <!-- Use simulation clock -->
  <arg name="use_sim_time"                          default="true"/>
  <!-- Debug mode -->
  <arg name="debug"                                 default="false"/>
  <!-- Verbose mode -->
  <arg name="verbose"                               default="true"/>
    <!-- ROBOT ARGUMENTS -->
  <!-- Name of the robot description parameter -->
  <arg name="robot_description" default="robot_description"/>
  <!-- Load Gazebo world -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <env name="GAZEBO_MODEL_PATH" value="$(arg model_path)"/>
    <arg name="world_name"        value="$(arg world_file)"/>
    <arg name="paused"            value="$(arg paused)"/>
    <arg name="use_sim_time"      value="$(arg use_sim_time)"/>
    <arg name="gui"               value="$(arg run_gui)"/>
    <arg name="headless"          value="$(arg headless)"/>
    <arg name="debug"             value="$(arg debug)"/>
    <arg name="verbose"           value="$(arg verbose)"/>
  </include>
  <!-- Spawn robot in Gazebo -->
  <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model"
    args="-param $(arg robot_description) -urdf -model $(arg robot_model_name) -x $(arg x)
      -y $(arg y) -z $(arg z) -R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"
    output="screen"/>
</launch>

and I'm trying to call this launch file using another launch file with changing a default parameter like this:

<?xml version="1.0"?>
<launch>
  <include file="$(find smb_gazebo)/launch/smb_gazebo.launch">
    <arg name="world" value="robocup09_spl_field"/>
  </include>
</launch>

But Gazebo is not loading the other world! can you please tell me what is my mistake? thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-22 11:19:39 -0500

bhomaidan gravatar image

updated 2021-10-22 11:27:24 -0500

Sorry, It was my bad the original launch file should contain instead of:

<arg name="world_file" default="$(find smb_gazebo)/worlds/$(arg world).world"/>

This line:

<arg name="world_file" default="$/usr/share/gazebo-11/worlds/$(arg world).world"/>
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-10-22 08:38:23 -0500

Seen: 299 times

Last updated: Oct 22 '21