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

Spawning two robots with two different namespaces

asked 2023-04-04 16:11:47 -0600

ROS_Engineer gravatar image

updated 2023-04-05 12:15:07 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-04-11 16:09:41 -0600

ROS_Engineer gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-04-04 16:11:47 -0600

Seen: 561 times

Last updated: Apr 11 '23