0
$\begingroup$

I am trying to namespace the topic, nodes and tf frames of a turtlebot3 to use it for multirobot experiment.

So, i created a rsp.launch.py file to just publish the robot description at first using the urdf files of the burger model.

When am launching the above mentioned file in my laptop i can see the tf frames are being prefixed the contents of frames.gv is below: enter image description here

But, when i launch the same launch file also using the same urdf files on turtlebot3 hardware using ssh the tf prefixes vanishes for some reason the frames.gv file for this is below: enter image description here

i don't know why this is happening any help is appreciated.thanks.

Below is the launch file that i am using:

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument
from launch_ros.actions import Node
from launch.substitutions import Command, LaunchConfiguration, PythonExpression, PathJoinSubstitution
from launch.launch_description_sources import PythonLaunchDescriptionSource
import xacro

def generate_launch_description():

    # Declaring and creating launch config for robot_prefix
    robot_prefix_arg = DeclareLaunchArgument('robot_prefix', default_value="")
    robot_prefix = LaunchConfiguration('robot_prefix')

    # Check if we're told to use sim time
    use_sim_time = LaunchConfiguration('use_sim_time')

    # Process the URDF file
    pkg_path = os.path.join(get_package_share_directory('my_tb3_launcher'))
    xacro_file = os.path.join(pkg_path,'description','burger.urdf.xacro')
#    robot_description_config = Command(['xacro ', str(xacro_file), 'frame_prefix:=', robot_prefix, 'topic_prefix:=', robot_prefix])
    robot_description_config = xacro.process_file(xacro_file)

 
    # Create a robot_state_publisher node
    params = {'robot_description': robot_description_config.toxml(), 
                'use_sim_time': use_sim_time,
                'frame_prefix': PythonExpression(["'", LaunchConfiguration('robot_prefix'), "/'"])
            }

    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher',
        output='screen',
        namespace=robot_prefix,
        parameters=[params]
    )

    # Launch!
    return LaunchDescription([
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='Use sim time if true'),
        robot_prefix_arg,
        node_robot_state_publisher
    ])

Here i am trying to add frame prefix by one of the two ways:

  • one is to use the frame_prefix parameter of the robot_state_publisher node (working in laptop not working in turtlebot)
  • or adding frame prefix to each link of the robot by preprocessing the xacro file ( not working in laptop and turtlebot ).
  • also tried both at the same time which also did not work

Below are the logs when i launch this file:

ubuntu@ubuntu:~$ ros2 launch my_tb3_launcher rsp.launch.py robot_prefix:=bot1
[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2024-01-24-09-32-48-442712-ubuntu-2160
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [2162]
[robot_state_publisher-1] Parsing robot urdf xml string.
[robot_state_publisher-1] Link base_link had 5 children
[robot_state_publisher-1] Link caster_back_link had 0 children
[robot_state_publisher-1] Link imu_link had 0 children
[robot_state_publisher-1] Link base_scan had 0 children
[robot_state_publisher-1] Link wheel_left_link had 0 children
[robot_state_publisher-1] Link wheel_right_link had 0 children
[robot_state_publisher-1] [INFO] [1706088768.963265666] [bot1.robot_state_publisher]: got segment base_footprint
[robot_state_publisher-1] [INFO] [1706088768.963568453] [bot1.robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1706088768.963627765] [bot1.robot_state_publisher]: got segment base_scan
[robot_state_publisher-1] [INFO] [1706088768.963662690] [bot1.robot_state_publisher]: got segment caster_back_link
[robot_state_publisher-1] [INFO] [1706088768.963693634] [bot1.robot_state_publisher]: got segment imu_link
[robot_state_publisher-1] [INFO] [1706088768.963722725] [bot1.robot_state_publisher]: got segment wheel_left_link
[robot_state_publisher-1] [INFO] [1706088768.963750336] [bot1.robot_state_publisher]: got segment wheel_right_link

Below are the enviornmrnt varisbles from the turtlebot:

ubuntu@ubuntu:~$ printenv | grep ros
AMENT_PREFIX_PATH=/home/ubuntu/turtlebot3_ws/install/turtlebot3:/home/ubuntu/turtlebot3_ws/install/turtlebot3_teleop:/home/ubuntu/turtlebot3_ws/install/turtlebot3_bringup:/home/ubuntu/turtlebot3_ws/install/turtlebot3_node:/home/ubuntu/turtlebot3_ws/install/turtlebot3_example:/home/ubuntu/turtlebot3_ws/install/turtlebot3_description:/home/ubuntu/turtlebot3_ws/install/my_tb3_launcher:/home/ubuntu/turtlebot3_ws/install/ld08_driver:/opt/ros/foxy
PYTHONPATH=/home/ubuntu/turtlebot3_ws/build/turtlebot3_teleop:/home/ubuntu/turtlebot3_ws/install/turtlebot3_teleop/lib/python3.8/site-packages:/home/ubuntu/turtlebot3_ws/build/turtlebot3_example:/home/ubuntu/turtlebot3_ws/install/turtlebot3_example/lib/python3.8/site-packages:/opt/ros/foxy/lib/python3.8/site-packages
LD_LIBRARY_PATH=/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/lib/aarch64-linux-gnu:/opt/ros/foxy/lib
PATH=/opt/ros/foxy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$\endgroup$
1
  • $\begingroup$ Hi nitish, please try and upload any terminal logs as formatted code. It makes the logs more readable. :) $\endgroup$
    – ssarkar
    Commented Jan 23 at 12:34

3 Answers 3

0
$\begingroup$

Ideally you can use __node:=<namespace> for running the node in specific namespace with ros2 run. For a detailed explanation regarding namespace in ros2, have a look at this question

$\endgroup$
1
  • $\begingroup$ There is no problem with the node namespacing and the topic namespacing they are namespaced fine. The only problem is with tf frames. $\endgroup$
    – nitish
    Commented Jan 23 at 13:03
0
$\begingroup$

I think you should set the tf_prefix argument when you launch the model here is an example of launching multiples turtlebots in the same stage but for ROS1.

For ROS2 I found a video from theconstruct where they launch multiples robots of the same model.

The robot fix the tf to /namespace/tf to avoid problems maybe you have to look on tb3 package to look if they are remapping the tf.

$\endgroup$
3
  • $\begingroup$ tf_prefix was deprecated in ros2 and was reintroduced in foxy and galactic as frame_prefix and it is working fine when i run the state publisher on my laptop but the problem is when i run it in turtlebot3(burger model) so i do not know how could this be happening. $\endgroup$
    – nitish
    Commented Jan 23 at 17:28
  • $\begingroup$ can you paste your launch file and both .bashrc files from computer and laptop (at least the env variables for ROS) to review in more detail pls? $\endgroup$
    – rdelgadov
    Commented Jan 23 at 17:50
  • $\begingroup$ i have added the launch file, logs and ros related environment variables. $\endgroup$
    – nitish
    Commented Jan 24 at 9:37
0
$\begingroup$

You can have a look at this package where the Turtlebot3 models are fully in xacro syntax.

Even if tf_prefix has come back, the console will list the raw frame names. robot_state_publisher will still renames the published frames on-the-fly.

Unfortunately this approach does not handle the frame prefix that are nested in messages (lidar, odometry, etc.). The only way to do that is through xacro, especially for simulation where this prefix should be added to the Gazebo plugins.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.