0
$\begingroup$

Rosanswers logo

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.


Originally posted by PrasadNR on ROS Answers with karma: 37 on 2016-11-10

Post score: 1


Original comments

Comment by vooon on 2016-11-11:
Post exact launch code at gist. Cape-posty error?

Comment by vooon on 2016-11-11:
Use http://wiki.ros.org/roslaunch/XML/group (place node inside).

Comment by vooon on 2016-11-11:
2: Did you edit CMakeLists.txt? But that wrong approach anyway...

Comment by vooon on 2016-11-11:
3: What you expect? Use rosnode to verify.

Comment by vooon on 2016-11-11:
4: What you try to remap??? Remap change topic or service name, not node. And again: __name, not _name!

Comment by PrasadNR on 2016-11-11:
@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.

Comment by PrasadNR on 2016-11-11:
@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?

Comment by PrasadNR on 2016-11-11:
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)

Comment by vooon on 2016-11-13:
In your gist, i see that node name is changed /mavros_copter, SetMode obviously fails because it try to use /mavros. https://github.com/erlerobot/ros_erle_takeoff_land/blob/master/src/main.cpp

You need to use remap for all services.

Comment by vooon on 2016-11-13:
Another way — edit erlerobot's node to remove / from beginning of topic (service) name. Place both mavros and that node into same namespace.

<group ns="copter">
    <include file="$(find mavros)/launch/apm.launch">
    </include>
    <include file="...." />
</group>

Comment by PrasadNR on 2016-11-13:
@vooon , Hats off and thanks for your efforts; almost like "God of software", you solved it. This is the proper answer; So amazing. I solved this with (no private parameter needed) "/mavros_copter/..." which isn't filesystem that I was searching for in "/home" and "/usr" and compiled.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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>

Originally posted by ahendrix with karma: 47576 on 2016-11-11

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by PrasadNR on 2016-11-11:
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)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.