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

Launching multiple instances of same ROS node (with different names)

asked 2016-11-10 13:27:10 -0600

PrasadNR gravatar image

updated 2016-11-13 11:40:28 -0600

The problem is in simulating two independent different robots in Gazebo: Copter and Rover with same mavros functionality. (Two independent instances of mavros would do great) Can two instances of mavros nodes be run using different names?

So, I tried to call mavros and the problem turned out to be "A new node registered with same name" which terminates Gazebo. To avoid this problem, I have tried to rename node-calls and the attempts include the following mentioned below.

<node ns="copter" pkg="mavros" type="mavros_node" name="mavros">
<node ns="rover" pkg="mavros" type="mavros_node" name="mavros">

1. Using namespaces as shown above; This still registers the node name as "/mavros" instead of "/copter/mavros" and "/rover/mavros"

2. Coding separate mavros_node codes for copter and rover instead of mavros_node.cpp. The modified version contains the lines shown below.

ros::init(argc, argv, "mavros_copter"); //In mavros_node_copter.cpp

ros::init(argc, argv, "mavros_rover"); //In mavros_node_rover.cpp

mavros_node.cpp, mavros_node_copter.cpp and mavros_node_rover.cpp source files are all placed in the same original folder. The entire package is then compiled with catkin_make. But, even then, using "mavros_copter" and "mavros_rover" as node name won't work with ROS Service properly while using "mavros" works.

<node pkg="mavros" type="mavros_node" name="mavros"> is the original code in launch file which works.

type="mavros_node_copter" name="mavros" (works)

type="mavros_node_copter" name="mavros_copter" (doesn't work)

3. I tried rqt_graph and this is the most confusing part in the software simulation. mavros node is shown as an independent node. I tried to assess how mavros is interacting with Gazebo and where how that is getting called and rqt_graph doesn't provide that information (even for original code which works).

4. Remapping nodes is not possible using roslaunch while command-line options like rosrun can be used. I even tried _name:="something" in command line along with roslaunch; But, that does not seem to work. (Original name is retained somehow)

Can you please let me know how multiple instances of same node can be run? (Optional: It will be great if you let me know how mavros is interacting with Gazebo)

Any help will be greatly, gratefully and whole-heartedly appreciated. Thanks for your time and consideration.

Prasad N R

Reference question: Multiple robots in ROS Gazebo SITL with separate MAVlink/MAVproxy codes

copter_circuit -> apm_sitl_copter & copter_circuit.world -> node_copter

rover_circuit1 -> apm_sitl_rover & rover_circuit1.world (.so plugin) -> node_rover

Output of roswtf , launch commands , CMakeLists.txt and the original folder structure can be found in Google Drive (uploaded sometime ago).

Can you please let me know if I should create new packages? (namely mavros_copter and mavros_rover and guidance on that will be gratefully appreciated)

A relatively small video has been made regarding the same.

edit retag flag offensive close merge delete

Comments

1

Post exact launch code at gist. Cape-posty error?

vooon gravatar image vooon  ( 2016-11-11 01:46:47 -0600 )edit

Use http://wiki.ros.org/roslaunch/XML/group (place node inside).

vooon gravatar image vooon  ( 2016-11-11 01:48:28 -0600 )edit

2: Did you edit CMakeLists.txt? But that wrong approach anyway...

vooon gravatar image vooon  ( 2016-11-11 01:49:10 -0600 )edit
1

3: What you expect? Use rosnode to verify.

vooon gravatar image vooon  ( 2016-11-11 01:49:51 -0600 )edit
1

4: What you try to remap??? Remap change topic or service name, not node. And again: __name, not _name!

vooon gravatar image vooon  ( 2016-11-11 01:51:32 -0600 )edit

@vooon , Thanks for that excellent clarification; If you find difficulty, I will upload on Github (multiple git init required) Trying __name and rosnode ; Thank you so much and I consider this an opportunity to thank you for excellent contributions to robotic softwares.

PrasadNR gravatar image PrasadNR  ( 2016-11-11 03:31:10 -0600 )edit

@vooon and viewers, you are humbly requested to let me know the mistake; "mavros_copter" node ( = "mavros" ) doesn't work like "mavros" (with __name:= override or directly using in launch file) What files that I should modify?

PrasadNR gravatar image PrasadNR  ( 2016-11-11 09:41:21 -0600 )edit

The output of rosnode info is too cryptic to understand and SearchMonkey returns nothing when I search for "mavros" in files (except mavros_node.cpp). I am ready to help with documentation on mavros once this research is finished. (I really wish to finish this soon and hope to contribute more)

PrasadNR gravatar image PrasadNR  ( 2016-11-11 09:46:17 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2016-11-11 12:01:08 -0600

ahendrix gravatar image

updated 2016-11-11 12:14:37 -0600

Using roslaunch to rename nodes should work, and is the correct way to do this.

The sample launch file that you posted appears to have a typo (both lines are the same)

You can put each node in a separate namespace:

<node ns="copter" pkg="mavros" type="mavros_node" name="mavros"/>
<node ns="rover" pkg="mavros" type="mavros_node" name="mavros"/>

Or you can avoid namespaces and just give them different names:

<node pkg="mavros" type="mavros_node" name="mavros_copter"/>
<node pkg="mavros" type="mavros_node" name="mavros_rover"/>

If you're using <include> tags in roslaunch, you can also push all of the nodes in that launch file into a namespace with the ns parameter:

<include ns="copter" file="$(find mavros)/launch/node.launch">
  <arg name="pluginlists_yaml" value="$(find mavros)/launch/apm_pluginlists.yaml" />
  <arg name="config_yaml" value="$(find mavros)/launch/apm_config.yaml" />
  <arg name="fcu_url" value="$(arg fcu_url/copter)" />
  <arg name="gcs_url" value="$(arg gcs_url/copter)" />
  <arg name="tgt_system" value="$(arg tgt_system/copter)" />
  <arg name="tgt_component" value="$(arg tgt_component/copter)" />
  <arg name="log_output" value="$(arg log_output/copter)" />
</include>

<include ns="rover" file="$(find mavros)/launch/node.launch">
  <arg name="pluginlists_yaml" value="$(find mavros)/launch/apm_pluginlists.yaml" />
  <arg name="config_yaml" value="$(find mavros)/launch/apm_config.yaml" />
  <arg name="fcu_url" value="$(arg fcu_url/rover)" />
  <arg name="gcs_url" value="$(arg gcs_url/rover)" />
  <arg name="tgt_system" value="$(arg tgt_system/rover)" />
  <arg name="tgt_component" value="$(arg tgt_component/rover)" />
  <arg name="log_output" value="$(arg log_output/rover)" />
</include>
edit flag offensive delete link more

Comments

Fixed that typo :) @ahendrix I think we both are close to the solution. You are humbly requested to let me know. Thanks! (video has been made as mentioned in question https://vimeo.com/191208613 ) roslaunch both copter and rover in one launch has flaws as mentioned in reference question. (no chars)

PrasadNR gravatar image PrasadNR  ( 2016-11-11 14:53:06 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-11-10 13:27:10 -0600

Seen: 9,157 times

Last updated: Nov 13 '16