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

How to split a launch file for two different nodes?

asked 2021-06-27 05:21:32 -0500

rosnroll gravatar image

I am new to ROS, please bear with me.

I am trying to run a PX4 drone avoidance module, with a PX4 drone simulator, on two different computers. (intel x86, and jetson tx2). Both have ROS melodic installed.

All the instructions on how to do so on a _single computer_ are here. From what I understand, first you build the avoidance module, build the simulator, then update the ROS_PACKAGE_PATH and GAZEBO_MODEL_PATH, so that the launch files can locate simulator. And the module is launched using,

roslaunch local_planner local_planner_stereo.launch

This launch file, calls the another launch file, avoidance_sitl_stereo.launch, which calls avoidance_sitl_mavros.launch. all three launch files
local_planner_stereo.launch
avoidance_sitl_stereo.launch
avoidance_sitl_mavros.launch
Within the launch files, PX4 refers to simulator.

My questions are,

  1. How do i split the launch file, so that PX4 runs on one system, and avoidance on the other? in local_planner_stereo.launch, should i just comment out the section launching PX4 and mavros, and have that run on different computer?
  2. Should then MAVROS be running on both systems?
  3. What other MAVROS parameters would need to be modified?
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-28 06:14:58 -0500

pvl gravatar image

Welcome to the ROS community!

Launch files & ROS nodes

A launch file is used to start the nodes required for the application. In the launch file, these nodes are independent. It should not matter if you start them from one launch file or from multiple launch files. As the startup order of the nodes is not guaranteed anyway, the nodes should be able to handle the delayed startup of collaborating nodes. Thus splitting the nodes over multiple launch files that are run on two systems is certainly possible. So in summary, removing parts of the launch file (or commenting them) can be done.

Networking two ROS systems

The two systems should be able to communicate to each other. See this networking guidefrom ros.org, to setup the connections. Choose one of the systems to start the ros master. The other system should connect to it.

Questions

  1. Yes, that is possible. If you want to run PX4 to run on a separate computer, then I would suggest separating this part from avoidance_sitl_mavros.launch. I have not used these systems, so it is an educated guess.

    <!-- Launch PX4 SITL -->
    <include file="$(find px4)/launch/px4.launch">
        <arg name="vehicle" value="$(arg vehicle)"/>
    </include>
    
  2. ROS communication is separate from MAVROS/mavlink. Thus if nodes on one system don't need it, then on that system is does not have to be running.

  3. If you follow the suggestion above, then the only parameter that should be set on both systems is the vehicle argument. I cannot see from the launch files if the PX4 node, requires topics, service or actions from other nodes. Again, this is an educated guess.
edit flag offensive delete link more

Comments

I commented out the px4 part from the launch files, and modified a different launch file that comes with PX4 installation.

Both launch files run, the other node can list and echo other nodes topics.
roslaunch px4 mavros_posic_sitl_avoidance.launch
and
roslaunch local_planner local_planner_stereo.launch

but when one is running, the other one is shows the error that

RLException: Unable to contact my own server at [http://192.168.2.3:45371/]. This usually means that the network is not configured properly.

similarly the same thing happens on the other node. I have configured ROS_MASTER_URI, ROS_IP, and ROS_HOSTNAME correctly on both systems(i think). And both system's /etc/hosts have user name added as well(echo does not work with out it), i.e. 192.168.2.3 user-desktop --> on 192.168.2.1 192.168.2.1 aamir-HP --> on 192.168.2.3
What am I missing here?

rosnroll gravatar image rosnroll  ( 2021-06-29 05:29:44 -0500 )edit
1

Have you tested the things mentioned in the ros.org networking guide? The link is in the answer.

pvl gravatar image pvl  ( 2021-06-29 05:42:42 -0500 )edit

It was environment variable issue. and commenting out works. There are other errors but they are unrelated to this(i think)

rosnroll gravatar image rosnroll  ( 2021-07-01 05:55:19 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-06-27 05:21:32 -0500

Seen: 353 times

Last updated: Jun 28 '21