# Multirobot not working - Robots answering to same publisher even with two different publishers declared

Hi,

I'm trying to use two pioneer robots on ROS Kinect but I'm having a little bit of trouble: both robots are receiving the same output of the cmd_vel even when I got two different publishers for each of them. So far, I've done this:

rospy.init_node('twoRobotsExample', anonymous=True)
publisher_r0 = rospy.Publisher('/robot_0/cmd_vel', Twist, queue_size=10)
publisher_r1 = rospy.Publisher('/robot_1/cmd_vel', Twist, queue_size=10)
rospy.Subscriber('/robot_0/base_scan_1', LaserScan, laserCallback)
rospy.Subscriber('/robot_0/odom', Odometry, odometerCallback)
rospy.Subscriber('/robot_1/base_scan_1', LaserScan, laserCallback)
rospy.Subscriber('/robot_1/odom', Odometry, odometerCallback)


And I created a dummy function in order to try to check what's wrong:

def move(publisher, linearVelocity):
speedCmd = Twist()
speedCmd.linear.x = linearVelocity
speedCmd.angular.z = 0
publisher.publish(speedCmd)
rospy.sleep(0.01)


I'm testing it using the function with the values move(publisher_r0, 3) and move(publisher_r1, 0), so the robot robot_0would move with a linear constant value of 3 and the robot robot_1 would stay still. The problem is that both robots are moving. I'm using the cave.world map, the only difference I've made was adding a new pioneer robot, so it ended up like this:

pioneer2dx
(
# can refer to the robot by this name
name "robot_0"
pose [ -7.000 -7.000 0 0.000 ]
# pioneer2dx's sonars   will be ranger:0 and the laser will be ranger:1
sicklaser( pose [ 0 0 0 0 ] )
# demonstrate a plugin controller, implemented in examples/ctrl/wander.cc
# you probably should comment this out when using simple.cfg with Player
ctrl "wander"

localization "gps"
localization_origin [ 0 0 0 0 ]
)

pioneer2dx
(
# can refer to the robot by this name
name "robot_1"
pose [ 7.000 7.000 0 0.000 ]
# pioneer2dx's sonars   will be ranger:0 and the laser will be ranger:1
sicklaser( pose [ 0 0 0 0 ] )
# demonstrate a plugin controller, implemented in examples/ctrl/wander.cc
# you probably should comment this out when using simple.cfg with Player
ctrl "wander"

localization "gps"
localization_origin [ 0 0 0 0 ]
)


Can someone help me? I already checked if all the topics are correctly running and they are, (link: https://imgur.com/a/G1PjeqI ). Not sure if a relevant info but I'm using stagefor simulations.

edit retag close merge delete