#!/usr/bin/env python3
#
# Copyright 2019 ROBOTIS CO., LTD.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Authors: Darby Lim
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import ThisLaunchFileDir
from launch.actions import ExecuteProcess
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.substitutions import Command
import xacro
TURTLEBOT3_MODEL = "waffle_pi"
def generate_launch_description():
use_sim_time = LaunchConfiguration('use_sim_time', default='true')
world_file_name = 'turtlebot3_tc_two_robots.world'
world = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'worlds', world_file_name)
robot_desc_path = os.path.join(get_package_share_directory("turtlebot3_description"), "urdf", "turtlebot3_waffle_pi.urdf")
entity_name_0="tb3_0"
entity_name_1="tb3_1"
return LaunchDescription([
ExecuteProcess(
cmd=['gazebo', '--verbose', world, '-s', 'libgazebo_ros_init.so'],
output='screen'),
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
namespace=entity_name_0,
parameters=[{
'frame_prefix': entity_name_0+'/',
'use_sim_time': use_sim_time,
'robot_description': Command([
'xacro ', robot_desc_path,
' robot_name:=', entity_name_0])}],
output="screen"
),
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
namespace=entity_name_1,
parameters=[{
'frame_prefix': entity_name_1+'/',
'use_sim_time': use_sim_time,
'robot_description': Command([
'xacro ', robot_desc_path,
' robot_name:=', entity_name_1])}],
output="screen"
)
])
I’ve taken the code from open class #163, multirobot navigation
Could anyone please explain:
what does the + in do ‘frame_prefix’: entity_name_1+'/
Why is there a need to add a robot name AND name space.
Shouldnt putting the namespace add tb3_0 in front all of the frames by default
E.g odom becomes tb3_0/odom
Also when I try to run this launch file on my own system I get an error that there is No such file or directory: ‘xacro’ -