Remote node does not receive parameters
I'm trying to run a node remotely from one PC, which is connected to another on a local network using the following launch file:
<launch>
<arg name="machine" default="side-machine" />
<arg name="user" default="my-user" />
<!-- Datacentre -->
<arg name="db_path" default="/my/db/path"/>
<arg name="port" default="11111" />
<arg name="defaults_path" default=""/>
<!-- NOW when launching in a remote mode it will need the ROS_ENV_LOADER set if not it will leave it empty -->
<machine name="$(arg machine)" address="$(arg machine)" env-loader="/home/strands/my_test_ws/devel/env.sh" user="$(arg user)" def\
ault="true"/>
<node name="launchtest" pkg="latest" type="launchtest.py" output="screen" machine="$(arg machine)">
<param name="database_path" value="$(arg db_path)"/>
</node>
</launch>
launchtest.py
looks like this:
#!/usr/bin/env python
import rospy
rospy.init_node("launchtest")
rospy.loginfo(rospy.get_param(""))
rospy.loginfo(rospy.get_param("~database_path")
When I run the launch file, I get the following result:
launching remote roslaunch child with command: [env ROS_MASTER_URI=http://localhost:11311 /home/my-user/my_test_ws/devel/env.sh roslaunch -c side-machine-0 -u http://main-machine:39722/ --run_id 127726c0-7040-11e7-9d42-901b0eacf01e]
remote[side-machine-0]: ssh connection created
SUMMARY
========
PARAMETERS
* /launchtest/database_path: /my/db/path
* /rosdistro: indigo
* /rosversion: 1.11.21
MACHINES
* my-user
NODES
/
launchtest (latest/launchtest.py)
ROS_MASTER_URI=http://localhost:11311
core service [/rosout] found
[side-machine-0]: launching nodes...
[side-machine-0]: auto-starting new master
[side-machine-0]: process[master]: started with pid [22973]
[side-machine-0]: ROS_MASTER_URI=http://localhost:11311
[side-machine-0]: setting /run_id to 127726c0-7040-11e7-9d42-901b0eacf01e
[side-machine-0]: process[launchtest-1]: started with pid [22987]
[side-machine-0]: ... done launching nodes
[side-machine-0]: [launchtest-1] process has died [pid 22987, exit code 1, cmd /home/my-user/my_test_ws/src/latest/scripts/launchtest.py __name:=launchtest __log:=/home/my-user/.ros/log/127726c0-7040-11e7-9d42-901b0eacf01e/launchtest-1.log].
log file: /home/my-user/.ros/log/127726c0-7040-11e7-9d42-901b0eacf01e/launchtest-1*.log
Where the output in the log file is
[rospy.client][INFO] 2017-07-24 09:40:35,815: init_node, name[/launchtest], pid[22987]
[xmlrpc][INFO] 2017-07-24 09:40:35,815: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2017-07-24 09:40:35,815: Started XML-RPC server [http://side-machine:55695/]
[rospy.init][INFO] 2017-07-24 09:40:35,815: ROS Slave URI: [http://side-machine:55695/]
[rospy.impl.masterslave][INFO] 2017-07-24 09:40:35,816: _ready: http://side-machine:55695/
[xmlrpc][INFO] 2017-07-24 09:40:35,816: xml rpc node: starting XML-RPC server
[rospy.registration][INFO] 2017-07-24 09:40:35,816: Registering with master node http://localhost:11311
[rospy.init][INFO] 2017-07-24 09:40:35,916: registered with master
[rospy.rosout][INFO] 2017-07-24 09:40:35,916: initializing /rosout core topic
[rospy.rosout][INFO] 2017-07-24 09:40:35,918: connected to core topic /rosout
[rospy.simtime][INFO] 2017-07-24 09:40:35,919: /use_sim_time is not set, will not subscribe to simulated time [/clock] topic
[rosout][INFO] 2017-07-24 09:40:35,922: {'roslaunch': {'uris': {'host_main-machine__39722': 'http://main-machine:39722/'}}, 'run_id': '127726c0-7040-11e7-9d42-901b0eacf01e'}
[rospy.core][INFO] 2017-07-24 09:40:35,923: signal_shutdown [atexit]
[rospy.impl.masterslave][INFO] 2017-07-24 09:40:35,924: atexit
It appears that the remote node is not receiving the parameters from the main-machine
. This is odd, because if I do rosparam list
on the side-machine
, I can see all the parameters:
/launchtest/database_path
/rosdistro
/roslaunch/uris/host_main-machine__39722
/rosversion
/run_id
And the /launchtest/database_path
is correctly set. I believe my network setup is correct - both machines can ping each other and themselves, and I am able to ssh between both of them without issues. What am I missing here?
Asked by heuristicus on 2017-07-24 03:14:06 UTC
Answers
I encountered this in ROS Kinetic. I found that the ROS_MASTER_URI
environment variable was not set correctly on the remote machine.
I found that when I launched a remote node, the remote machine was acting as its own ROS master. That is, I could see that a process had been launched (using top
, ps
, or so on), but running rosnode list
on either the local or remote machine did not show the node. Attaching a debugger on the remote machine and inspecting the environment confirmed that ROS_MASTER_URI
was still set to http://localhost:11311
.
Note that setting ROS_MASTER_URI
in ~/.bashrc
or somewhere similar does not work in this case, because that file does not get sourced when your remotely launch a node. This is why your node might have worked fine if you were to log in to the remote machine and launch it from there.
I believe the preferred solution is to make sure that the script specified by the env-loader
parameter in your <machine>
entry is setting ROS_MASTER_URI
correctly; if you have it set to env-loader="/opt/ros/kinetic/env.sh"
or something like that, then it's probably not being set correctly by default.
Asked by adeschamps on 2019-10-31 09:25:59 UTC
Comments