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

Files not found when launching from remote PC

asked 2018-01-18 08:49:39 -0500

DidrikSG gravatar image

updated 2018-01-19 13:34:10 -0500

When trying to use a launchfile to launch ROS nodes on two seperate machines, the remote PC cannot find the files I want to launch. I have also installed both packages on both machines for testing purpouses. The files is can be launched on both PC's, but when I try to launch them remotely, they're not found.

I have looked at a lot of other people using ROS on two machines, but I cannot seem to find any solution to this problem. Any suggestions/help is appreciated. All necessary files is listed below.

EDIT: I have tried launching the turtlesim teleop node on the remote PC, a node that is native in ROS. This works with no problem, so the problem lies in custom made nodes.

EDIT: Added the "printenv" variables from manually

Main launch file

<launch>
  <include file="$(find r18dv_tf_publisher)/hosts/hosts.machine" />
  <node machine="tegra_a" pkg="r18dv_tf_publisher" type="tf_broadcaster" name="tf_broadcaster" />
  <node machine="tegra_b" pkg="r18dv_simple_heading_controller" type="r18dv_simple_heading_controller_node" name="heading_controller" output="screen" />
</launch>

hosts.machine

<launch>
  <machine name="tegra_a" address="10.42.0.28" env-loader="/opt/ros/kinetic/env.sh" />
  <machine name="tegra_b" address="10.42.0.29" env-loader="/opt/ros/kinetic/env.sh" />
</launch>

The file structure is identical on the two machines, and both env.sh files is located at the same location.

env.sh on tegra_a

#!/usr/bin/env sh
# generated from catkin/cmake/templates/env.sh.in

if [ $# -eq 0 ] ; then
  /bin/echo "Usage: env.sh COMMANDS"
  /bin/echo "Calling env.sh without arguments is not supported anymore. Instead spawn a subshell and source a setup file manually."
  exit 1
fi

# ensure to not use different shell type which was set before
CATKIN_SHELL=sh

# source setup.sh from same directory as this file
_CATKIN_SETUP_DIR=$(cd "`dirname "$0"`" > /dev/null && pwd)
. "$_CATKIN_SETUP_DIR/setup.sh"

export ROS_WS=/home/nvidia/catkin_ws
export ROS_KINETIC=/etc/ros/kinetic
source $ROS_WS/devel/setup.bash
source $ROS_KINETIC/setup.bash
export PATH=$ROS_ROOT/bin:$PATH
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$ROS_WS
export ROS_MASTER_URI=http://10.42.0.28:11311/
export ROS_HOSTNAME=10.42.0.28
exec "$@"

env.sh on tegra_b

#!/usr/bin/env sh
# generated from catkin/cmake/templates/env.sh.in

if [ $# -eq 0 ] ; then
  /bin/echo "Usage: env.sh COMMANDS"
  /bin/echo "Calling env.sh without arguments is not supported anymore. Instead spawn a subshell and source a setup file manually."
  exit 1
fi

# ensure to not use different shell type which was set before
CATKIN_SHELL=sh

# source setup.sh from same directory as this file
_CATKIN_SETUP_DIR=$(cd "`dirname "$0"`" > /dev/null && pwd)
. "$_CATKIN_SETUP_DIR/setup.sh"

export ROS_WS=/home/nvidia/catkin_ws
export ROS_KINETIC=/etc/ros/kinetic
source $ROS_WS/devel/setup.bash
source $ROS_KINETIC/setup.bash
export PATH=$ROS_ROOT/bin:$PATH
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$ROS_WS
export ROS_MASTER_URI=http://10.42.0.28:11311/
export ROS_HOSTNAME=10.42.0.29
exec "$@"

Output when launching the launchfile

nvidia@nvidia:/opt/ros/kinetic$ roslaunch r18dv_tf_publisher test_launch.launch 
... logging to /home/nvidia/.ros/log/3dfcc3a4-fba0-11e7-8f39-00044b8da45f/roslaunch-nvidia-8089.log
Checking log directory for disk usage. This may ...
(more)
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
5

answered 2018-01-25 04:36:43 -0500

DidrikSG gravatar image

updated 2018-01-25 04:37:36 -0500

I found the error, and it is (of course) a simple and dumb mistake

In the <machine> tag, I set the env-loader to use the env.sh file in /opt/ros/kinetic/, but as this executes and uses the setup.sh file in the same folder as the env.sh file. The env.sh file in the rosdistro will not find files in your catkin_ws. By changing the path to the env.sh file to /home/catkin_ws/devel/env.sh, and updated the env.sh file to the same as listed in my original question, everything worked as it should (note that all the other mistakes also needed to be fixed for everything to work as well)

Correct and tested hosts.machine file

<launch>
  <machine name="tegra_a" address="10.42.0.28" env-loader="/home/catkin_ws/devel/env.sh" />
  <machine name="tegra_b" address="10.42.0.29" env-loader="/home/catkin_ws/devel/env.sh" />
</launch>

Correct and tested env.sh file in /home/catkin_ws/devel/ on tegra_b

#!/usr/bin/env sh
# generated from catkin/cmake/templates/env.sh.in

if [ $# -eq 0 ] ; then
  /bin/echo "Usage: env.sh COMMANDS"
  /bin/echo "Calling env.sh without arguments is not supported anymore. Instead spawn a subshell and source a setup file manually."
  exit 1
fi

# ensure to not use different shell type which was set before
CATKIN_SHELL=sh

# source setup.sh from same directory as this file
_CATKIN_SETUP_DIR=$(cd "`dirname "$0"`" > /dev/null && pwd)
. "$_CATKIN_SETUP_DIR/setup.sh"

export ROS_WS=/home/nvidia/catkin_ws
export ROS_KINETIC=/etc/ros/kinetic
source $ROS_WS/devel/setup.bash
source $ROS_KINETIC/setup.bash
export PATH=$ROS_ROOT/bin:$PATH
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$ROS_WS
export ROS_MASTER_URI=http://10.42.0.28:11311/
export ROS_HOSTNAME=10.42.0.29
exec "$@"
edit flag offensive delete link more
1

answered 2018-09-13 11:25:19 -0500

DavidTorresOcana gravatar image

Hello

Perhaps too late, but I hope it helps somebody.

You can configure the environment of a machine from only one env.sh, in this case as @DidrikSG was trying, from /opt/ros/kinetic/env.sh

If we read carefully, everything that env.sh is dong is running the setup.sh on the same folder, so we only need to run the setup.sh of all the workspaces we need.

In my case, running a node in TegraA from TegraB:

TegraB:

export ROS_IP=10.42.0.29
roslaunch test.launch

test.launch is something like:

<launch> 
   <machine name="nvidiaTA" address="10.42.0.28" env-loader="/opt/ros/kinetic/env.sh" user="nvidia" /> 
   <node machine="nvidiaTA" name="gmsl_n_cameras_node" pkg="gmsl_n_cameras" type="gmsl_n_cameras_node" /> 
  ...
</launch>

and

TegraA

In /opt/ros/kinetic/env.sh I only added:

. /home/nvidia/catkin_ws/devel/setup.sh
export ROS_IP=10.42.0.28
export ROS_MASTER_URI=http://10.42.0.29:11311

So, @DidrikSG in your /opt/ros/kinetic/env.sh just add:

. /home/nvidia/catkin_ws/devel/setup.sh

and as many workspaces you need

I hope it helps!

Regards

edit flag offensive delete link more
1

answered 2018-01-19 08:46:40 -0500

updated 2018-01-19 13:48:46 -0500

It looks like you're sourcing the ros setup and workspace setup files in the wrong order.

source $ROS_WS/devel/setup.bash
source $ROS_KINETIC/setup.bash

The main ros setup.bash will overwrite the workspace setup, so you always want to source the workspace setup.bash file second.

Update thanks for the new information. There are two differences that look like they might be causing the problem. ROSLISP_PACKAGE_DIRECTORIES is blank when setup using 'env.sh' the other is that the order of the paths in ROS_PACKAGE_PATH is reversed. If i had to guess the missing ROSLISP path is looking the most suspicious.

edit flag offensive delete link more

Comments

Hi Pete. I changed the order on both env.sh files, but I still get the same output

DidrikSG gravatar image DidrikSG  ( 2018-01-19 10:25:26 -0500 )edit
1

[..] so you always want to source the workspace setup.bash file second.

yes, and you don't even need to source the one in /opt/ros/$distro ..

gvdhoorn gravatar image gvdhoorn  ( 2018-01-19 10:33:32 -0500 )edit

Just to check can you roslaunch the files individually if you ssh in without any problems? If so try a printenv here when you're ssh'ed in and another printenv to a log file in the env.sh script. If there are any differences they might be the source of the problem.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-01-19 10:56:54 -0500 )edit

I have no problem launching the files individually, but I suspect that there might be a difference in the env's. The variables from manually sshing in and writing "printenv" and the "printenv" from the env.sh file is now added in the question.

DidrikSG gravatar image DidrikSG  ( 2018-01-19 13:35:02 -0500 )edit

Hi Pete! Thank you for the updated information! I tried changing the order on the two paths in the ROS_PACKAGE_PATH and I also exported the correct ROSLISP_PACKAGE_DIRECTORIES in the env.sh file, but this did not fix the problem, and I get the same output as before

DidrikSG gravatar image DidrikSG  ( 2018-01-21 10:16:45 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-01-18 08:49:39 -0500

Seen: 1,970 times

Last updated: Sep 13 '18