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

Revision history [back]

click to hide/show revision 1
initial version

As you are spawning the robots successfully, i think you can define namespace of each bot in the launch file separately. Having done this you should publish the cmd_vel to each bot with separate topics which get created according to their namespace in launch file. Below is example of launch file i used.

<launch>    
    <group ns="Robot">
        <node pkg="velocity_obstacle" name="rosaria" type="robot_node" output="screen">
        <param name="port" value="10.2.36.7"/>
        </node>
    </group>
    <group ns="Obstacle2">
        <node pkg="velocity_obstacle" name="rosaria" type="robot_node" output="screen">
        <param name="port" value="10.2.36.6"/>
        </node>
    </group>
</launch>

And publishers as below

robot_vel_pub = n.advertise<geometry_msgs::Twist>("Robot/rosaria/cmd_vel", 1000);
obs1_vel_pub = n.advertise<<geometry_msgs::Twist>("Obstacle1/rosaria/cmd_vel", 1000);

As you are spawning the robots successfully, i think you can define namespace of each bot in the launch file separately. Having done this you should publish the cmd_vel to each bot with separate topics which get created according to their namespace in launch file. Below is example of launch file i used.

<launch>    
    <group ns="Robot">
        <node pkg="velocity_obstacle" name="rosaria" type="robot_node" output="screen">
        <param name="port" value="10.2.36.7"/>
        </node>
    </group>
    <group ns="Obstacle2">
ns="Obstacle1">
        <node pkg="velocity_obstacle" name="rosaria" type="robot_node" output="screen">
        <param name="port" value="10.2.36.6"/>
        </node>
    </group>
</launch>

And publishers as below

robot_vel_pub = n.advertise<geometry_msgs::Twist>("Robot/rosaria/cmd_vel", 1000);
obs1_vel_pub = n.advertise<<geometry_msgs::Twist>("Obstacle1/rosaria/cmd_vel", 1000);

As you are spawning the robots successfully, i think you can define namespace of each bot in the launch file separately. Having done this you should publish the cmd_vel to each bot with separate topics which get created according to their namespace in launch file. Below is example of launch file i used.

<launch>    
    <group ns="Robot">
        <node pkg="velocity_obstacle" name="rosaria" type="robot_node" output="screen">
        <param name="port" value="10.2.36.7"/>
        </node>
    </group>
    <group ns="Obstacle1">
        <node pkg="velocity_obstacle" name="rosaria" type="robot_node" output="screen">
        <param name="port" value="10.2.36.6"/>
        </node>
    </group>
</launch>

And publishers as below

robot_vel_pub = n.advertise<geometry_msgs::Twist>("Robot/rosaria/cmd_vel", 1000);
obs1_vel_pub = n.advertise<<geometry_msgs::Twist>("Obstacle1/rosaria/cmd_vel", 1000);

For the updated question: I guess the mistake is in the launch file. You have the param section and node section written separately (I don't know their significance here and their effects) in the following way

<group ns="XXX">
      <param xxxxxxxxxxxxxxxxx /> #param closed here
      <node xxxxxxxxxxxxxxxxxx /> #node closed here
      <node xxxxxxxxxxxxxxxxxx /> #node closed here
</group> #group closed here

If you want a param specific to a node then you should have something like the below

<group ns="XXX>
      <node xxxxxxxxxxxxxxxxxx> #node not closed here
      <param xxxxxxxxxxxxxxxxx /> #param closed here but still in node which is not closed
      </node> #node closed here
</group> #group closed here

Hope this helps a bit in debugging your issue. Though i am not sure if this is your problem.