Launching multiple instances of same ROS node (with different names)
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)
Post exact launch code at gist. Cape-posty error?
Use http://wiki.ros.org/roslaunch/XML/group (place node inside).
2: Did you edit CMakeLists.txt? But that wrong approach anyway...
3: What you expect? Use
rosnode
to verify.4: What you try to remap??? Remap change topic or service name, not node. And again:
__name
, not_name
!@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.
@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?
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)