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:
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:
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