Cannot set env variables when ssh a network machine [closed]
I am trying to set up a network configuration between two machines. I already did all the steps mentioned in the ROS tutorials. This is my setup:
In PC1:
roscore
export ROS_MASTER_URI=https://${PC1_hostname}:11311
rosrun <package> <node>
In PC2:
export ROS_IP="$(ifconfig | perl -nle'/dr:(10\.85\.167\.\S+)/ && print $1')"
export ROS_HOSTNAME="<PC2_hostname>"
export ROS_MASTER_URI=https://${PC1_hostname}:11311
rosrun <package> <node>
I can trasmit data back and forth between the two machines using ROS.
Now, I want to start PC2 from PC1 using a launch file. ROS indeed get the connection from PC1 to PC2, but then the program fails when trying to run the node. I found that the error is because ROS is ssh
-ing into PC2, and ssh does not allow to set environment variables, which means ROS was never sourced and there isn't any environment variables. My env.sh
file is right since if I run the script locally it works.
I found this on the web, I tried some of the solutions with no success.
How to allow environment variables to be set when ssh into an external PC?
Environment variables must be set when you ssh into another machine.