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

Unique namespace for a robot using the launch file.

asked 2019-03-19 06:55:37 -0500

TharushiDeSilva gravatar image

updated 2019-03-19 21:27:25 -0500

Hi! I am trying to develop a multi-robot system using Qbots. For that I need to assign different namespaces to each robot in the network. (As Qbot1, Qbot2 etc.) As my previous question, and the answers I got, I wrote a single launch file and tried to push all of my topics under a given namespace. For this process, I used "ns" variable in include tag. Although there was a lot of issues in the results, I decided to make this question simpler by providing a small code, which I think includes the root of those problems.

This is a very simple launch file which can launch a kobuki core and then operate it manually by executing keyop program.

Here is my first launch file without including the namespace.

 <launch>
    <!-- Run the Kobuki base -->
    <include file="$(find kobuki_node)/launch/minimal.launch"/>

    <!-- Run the Keyop controller -->
    <include file="$(find kobuki_keyop)/launch/keyop.launch"/>
    </launch>

This is the rqt_graph I obtained by running the above program.

image description

This is the second launch file I wrote by including the namespace variable.

    <launch>
    <!-- Run the Kobuki base -->
    <include ns="qbot1" file="$(find kobuki_node)/launch/minimal.launch"/>

    <!-- Run the Keyop controller -->
    <include ns="qbot1" file="$(find kobuki_keyop)/launch/keyop.launch"/>
    </launch>

And this is the relevant rqt graph

image description

Although both of the launch files work without a problem, I can see that there are differences in two rqt graphs. Instead of a single mobile_base_nodelet_manager topic (when there is no namespace), the second rqt_graph displays a node and a topic under the name of mobile_base_nodelet_manager. Due to this reason, the more advanced launch files in my program does not work properly.

Can anyone explain me what is wrong with the second launch file, and how can I make it work like the first one. (I already tried writing a single namespace for the whole launch file, and also the group tag)

I use ROS Kinetic version on Ubuntu 16.04.

edit retag flag offensive close merge delete

Comments

Please attach your imaged directly to your question instead of linking to your google drive. I've given you sufficient karma for that.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-19 07:51:20 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-03-21 00:49:04 -0500

janindu gravatar image

updated 2019-03-21 00:55:27 -0500

There are no differences between the two rqt graphs, except for the namespace. If you look at the first graph, you can see 4 nodes

  1. /keyop
  2. /mobile_base
  3. /mobile_base_nodelet_manager
  4. /diagnostic_aggregator

and 4 topics

  1. /mobile_base_nodelet_manager/bond
  2. /mobile_base/commands/velocity
  3. /mobile_base/commands/motor_power
  4. /diagnostics

If you look at the second graph, you can see the corresponding topics and nodes with the prefix qbot1 and that all nodes are subscribed to / publishing to correct topics.

I think your confusion is about the namespace box. In rqt graphs, the topics and nodes are grouped by the top level namespace in boxes. For an instance, in the first rqt graph, /mobile_base_nodelet_manager/bond topic is inside the box /mobile_base_nodelet_manager because it's the top level namespace. Similarly, topics /mobile_base/commands/velocity and /mobile_base/commands/motor_power are inside the box /mobile_base.

Since you add a top level namespace /qbot1, everything with /qbot1 as the top level namespace, (that is, everything except /diagnostics topic) is within the qbot1 box. In the second rqt graph, you can see the bottom of the box but top and sides are cropped out. The rqt_graph wiki page has an example image which would make it clearer to you.

The bottom line is, given your launch files, the rqt_graphs you are getting are correct. Personally, I prefer the <group> tag if more than one launch file is included in the namespace group.

If your more complex launch files are not working, can you please edit the question or post it as a new question with the actual problem you are running into?

edit flag offensive delete link more

Comments

@janindu. Thank you so much for the explanation. I have posted my advanced issue as a new question in here.

TharushiDeSilva gravatar image TharushiDeSilva  ( 2019-03-21 02:25:12 -0500 )edit

I can't see the question anymore. Hope you have solved it!

janindu gravatar image janindu  ( 2019-03-21 18:43:50 -0500 )edit

Sorry about that. I sort of figured out the node which is creating the problem, and I had temporarily deleted the question until I could edit it. It is available now. I'm so thankful if you can take a look at it.
https://answers.ros.org/question/3190...

TharushiDeSilva gravatar image TharushiDeSilva  ( 2019-03-21 23:37:31 -0500 )edit
0

answered 2019-03-19 21:38:56 -0500

hwil292 gravatar image

updated 2019-03-20 14:27:23 -0500

Hi,

if you wrap the <include> in a <group> tag you can do what you want.

Example: <group ns="qbot1"> <include>....</include> </group>

It will put all the nodes inside the group under the given namespaces.

EDIT: When creating the publisher subscriber are you setting the name as "/example_node" or "node", putting the "/" at the start of the node name will force it to the base namespace, if you omit the "/" the namespace will be correctly tagged onto the node

ns = "foo" with sub/pub topic = "/test_node" will always be /test_node

ns ="foo" with "test_node" will correctly become "/foo/test_node"

edit flag offensive delete link more

Comments

The <include> tag does not support the "ns" parameter

roslaunch/XML/include seems to say it does.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-20 02:35:19 -0500 )edit

Have edited answer above. I think I got my tags wrong.

hwil292 gravatar image hwil292  ( 2019-03-20 14:23:20 -0500 )edit

@hwil292 Thank you so much for your answer. I have already tried the <group> tag, but it gives me the same result. I will try looking inside the publisher and subscriber. And I will publish my result.

TharushiDeSilva gravatar image TharushiDeSilva  ( 2019-03-20 22:46:07 -0500 )edit

@hwil292 Although this isn't the perfect answer for this question, the absolute and relative namespace concept became the answer to my real issue. Thank you so much for sharing your knowledge.

TharushiDeSilva gravatar image TharushiDeSilva  ( 2019-03-22 23:17:14 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-03-19 06:55:37 -0500

Seen: 1,227 times

Last updated: Mar 21 '19