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

How to include a .launch file on a remote machine from a .launch file?

asked 2012-08-14 12:12:44 -0500

cdleveille gravatar image

updated 2014-04-20 14:09:24 -0500

ngrennan gravatar image

Hi,

I'm using openni_launch drivers for the Kinect on my robot. I am running roscore on a separate computer, my laptop. I have added a line reading <env name="ROS_MASTER_URI" value="MY_LAPTOP_NAME:PORT_NUM"/> to the openni.launch file on the robot computer so I can access the various image topics such as /camera/rgb/image_color from my laptop.

As it is, I can run the launch file on my laptop which creates the connection to the robot, and THEN I have to go over to the robot computer and launch openni.launch to start the Kinect drivers. This works fine, but it is inconvenient. I want to be able to start the Kinect drivers (execute the openni.launch file on the robot computer) from the launch file on my laptop.

I am wondering if there is a way to add an <include file=""/> tag to the launch file on my laptop that will run the openni.launch file on the robot.

Naturally, I looked at the <include> documentation at http://www.ros.org/wiki/roslaunch/XML/include already, but there doesn't seem to be anything about including a file on another machine. That's why I thought I would check here.

Thanks very much for reading, and hope you can help!

-Chris

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
3

answered 2012-08-14 12:40:29 -0500

jbohren gravatar image

updated 2012-08-14 12:49:27 -0500

It looks like it's undocumented, and it even gives a warning if you try to use it, but! You can, in fuerte, at least, add a "machine" attribute to an "include" tag in a launchfile and get it to launch everything in that included launchfile to come up on another machine.

See here for setting up machine tags: http://www.ros.org/wiki/roslaunch/XML/machine

And then just simply do (with appropriate values) something like:

<launch>
  <machine name="other-pc" address="192.168.13.37" env-loader="/opt/ros/fuerte/env.sh"/>
  <include file="/path/to/file/on/local/machine.launch" machine="other-pc"/>
</launch>

It looks like what this is doing is actually reading a launchfile on the local machine, and then bringing up its nodes on the other machine!

edit flag offensive delete link more

Comments

I have tried that with openni.launch, but it still launches nodes on local machine.

liborw gravatar image liborw  ( 2012-09-04 21:05:53 -0500 )edit
1

Maybe it only works one level deep. This is an undocumented feature, but definitely something that I think should be added to the hydro roslaunch SIG: http://www.ros.org/wiki/hydro/Planning/roslaunch

jbohren gravatar image jbohren  ( 2012-09-05 02:37:28 -0500 )edit
1

I tried it in ROS Electric, but had no luck. WARNING: [path/to/MASTER/pc/name.launch] unknown <include> attribute 'machine'

I need to launch a node in a ClientPC with files living in the ClientPC too. Currently it attempts to read files in MASTERPC which also has them, but no luck either. Ideas?

amrivera gravatar image amrivera  ( 2013-03-22 07:30:00 -0500 )edit
4

On hydro this results in error: WARNING: [...launch] unknown <include> attribute 'machine'

liborw gravatar image liborw  ( 2013-08-15 04:32:49 -0500 )edit
2

This isn't working on ROS Kinetic either, resulting in a warning and the nodes being launched on the local PC.

Girmi gravatar image Girmi  ( 2017-01-16 08:00:09 -0500 )edit
2

answered 2017-01-17 02:59:55 -0500

Girmi gravatar image

updated 2018-02-22 03:58:42 -0500

If anyone is still looking for an answer, I think currently the most elegant solution is:

<launch>
        <include file="local_nodes.launch" />

        <group>
            <machine name="remote_machine" address="1.2.3.4" default="true" />
            <include file="remote_nodes.launch" />
        </group>
</launch>

Tested with ROS Kinectic on Ubuntu 16.04.

Edit: Apparently the machine tag doesn't apply to a specific group, but to any nodes/includes that come after it. So the order in which the tags are defined is important!

edit flag offensive delete link more

Comments

1

Apparently the machine tag doesn't apply to a specific group, but to any nodes/includes that come after it. So the order in which the tags are defined is important!

Girmi gravatar image Girmi  ( 2017-02-06 03:56:19 -0500 )edit

Also the default="true" tag is needed to work properly. After adding that, it is finally working for me. Thanks!

philwall3 gravatar image philwall3  ( 2018-02-22 03:24:34 -0500 )edit

Do you mean the defailt="true" attribute of the <machine> element (which is present in my example)? Or is an additional attribute needed somewhere?

Girmi gravatar image Girmi  ( 2018-02-22 04:08:14 -0500 )edit

Yes I mean in the machine element like shown in your example. I was missing it at first and it was not opening the ssh connection to the remote machine, but instead just starting the launch file on the local machine.

philwall3 gravatar image philwall3  ( 2018-02-22 05:59:06 -0500 )edit

It seems to me like any file included via the file="" tag will be read locally but launched remotely, as in remote_nodes.launch must exist locally, but will launch the nodes mentioned within remotely. Can anyone else confirm this behaviour?

MikeWrock gravatar image MikeWrock  ( 2019-11-19 11:59:58 -0500 )edit

This is indeed the case. The same goes for the fact that any nodes you want to launch remotely, have to be installed locally as well.

Girmi gravatar image Girmi  ( 2019-11-20 07:39:03 -0500 )edit

I was able to launch a node remotely and that node was not installed locally. However, I am observing a problem with launching remote launch files. The ROS path of the local system is being checked for the package that contains the launch file and I recieved the ResourceNotFound error.

Hemanth gravatar image Hemanth  ( 2019-11-21 04:57:33 -0500 )edit

does anyone has solved this issue. cas i'm also facing same issue and unable to solve it.

dinesh gravatar image dinesh  ( 2021-07-13 02:20:02 -0500 )edit
0

answered 2021-07-13 11:24:28 -0500

MikeWrock gravatar image

This isn't the most elegant solution, but I have found a workaround to launch a launch file on a remote machine without having the launch file or nodes on the local machine

On the local machine I add the following script (remote_launch.bash) to one of my packages:

#!/usr/bin/env bash
ssh user@remote_ip "roslaunch your_remote_package launchfile.launch"

Don't forget to ssh-copy-id from the local to the remote machine so you don't need a password to ssh

My local machine's launch file just looks like:

<launch>
  <node name="your_name" pkg="your_package" type="remote_launch.bash" />
</launch>
edit flag offensive delete link more

Question Tools

4 followers

Stats

Asked: 2012-08-14 12:12:44 -0500

Seen: 5,797 times

Last updated: Jul 13 '21