Robotics StackExchange | Archived questions

Spawning two robots with two different namespaces

I am currently working with ROS2 Galactic and Ignition. For my purposes I am trying two spawn two robots with a camera sensor through a launch file in an Ignition world:

first_robot_node = Node(
    package='ros_ign_gazebo',
    executable='create',
    output='screen',
    arguments=[ "-file", get_package_share_directory('rollbot_description')+"/urdf/rollbot.urdf",
                "-name", 'rollbot', "-x", "-2", "-y", "0", "-z", "0.1"]
)   

second_robot_node = Node(
    package='ros_ign_gazebo',
    executable='create',
    output='screen',
    arguments=[ "-file", get_package_share_directory('climbbot_description')+"/urdf/climbbot.urdf",
                "-name", 'climbbot', "-x", "5", "-y", "0", "-z", "0.1"],
) 

The problem being, both of the robots are publishing to the "/image" topic, causing conflicts. So I'd like to have the rollbot publish to "/rollbot/image" and climbbot publish to "/climbbot/image". However, I can't seem to work out how to do that. I have tried modifying the node call in the following ways:

 first_robot_node = Node(
    package='ros_ign_gazebo',
    namespace="rollbot", # First I tried giving the node a namespace but this had no effect
    remappings=[("/image","/rollbot/image")], # Secondly I tried remapping the topic. Also no effect.
    executable='create',
    output='screen',
    arguments=[ "-file", get_package_share_directory('rollbot_description')+"/urdf/rollbot.urdf",
                "-name", 'rollbot',
                # Third I tried passing namespace as an argument to create. But also no effect.
                "-namespace", "rollbot",
                "-x", "-2", "-y", "0", "-z", "0.1"]
)   

The only thread I can find where someone spawned multiple robots with different namespaces is this Box Bot project which uses 3 different files to spawn multiple robots. It just feels like massive complexity for something that I feel must be a pretty common problem.

Anyone know how I need to modify my launch file for both bots to publish to different topics?

Asked by ROS_Engineer on 2023-04-04 16:11:47 UTC

Comments

Answers

I was ultimately able to spawn the two robots with the cameras publishing to different topics by changing the topics of the cameras in each URDF file. This, however, does not address the underlying problem that there does not seem to be a method of spawning the same robot on two different namespaces.

Asked by ROS_Engineer on 2023-04-11 16:09:41 UTC

Comments