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?