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

How do I set environment variable for node launched on remote machine ?

asked 2021-07-02 22:36:40 -0500

elpidiovaldez gravatar image

updated 2021-07-03 18:17:37 -0500

I have a launch file which runs some nodes on a remote machine. I declare the remote machine as follows:

  <machine name="petra" address="petra" env-loader="/home/paul/catkin_ws/devel_isolated/env.sh"/>

and launch a remote node with:

  <node machine="petra" name="myspeech.py" pkg="speech_infinite" type="myspeech.py" output="screen"/>

The node uses Google cloud speech API and requires an environment variable of the form:

export GOOGLE_APPLICATION_CREDENTIALS=/home/paul/Programs/GoogleAccount/myproject-blahblah.json

Currently I edit env.sh in devel_isolated, but that gets overwritten when I make the workspace.

I have traced through the shell scripts, which include other scripts, which include other scripts and hooks etc. It left my head spinning ! Can anyone suggest a good way(i.e. minimal changes to ROS boilerplate) to set this up, so that:

  1. The Google credentials are included even after remaking catkin workspace
  2. All the rest of my catkin environment continues to be loaded.
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-07-03 07:19:25 -0500

bob-ROS gravatar image

updated 2021-07-03 07:21:32 -0500

Tried using env-loader to just run a seperate bash script? You could source the "/home/paul/catkin_ws/devel_isolated/env.sh" from the other "start_script.sh" if necessary?

<node machine="petra" name="myspeech.py" pkg="speech_infinite" type="myspeech.py" env-loader="/suitable_directory/start_script.sh" output="screen"/>

Alternatively put the export in your /etc/profile or ~/.bashrc on the remote machine?

edit flag offensive delete link more

Comments

Thanks for your suggestion. It seems blindingly obvious now, but at the time I was reeling from trying to follow what was going on with all the indirection. I thought I had to go via the provided env file. Following your idea, I made a file on the remote machine ,called env.bash, which works perfectly:

#!/usr/bin/env bash

#This allows use of Google speech recognition and other cloud services.
export GOOGLE_APPLICATION_CREDENTIALS="/home/paul/Programs/GoogleAccount/zen-speech-2bcd94a51876.json"

source /home/paul/catkin_ws/devel_isolated/setup.bash
exec "$@"

The launch file contains:

<machine name="petra" address="petra" env-loader="/home/paul/catkin_ws/src/env.bash"/>
elpidiovaldez gravatar image elpidiovaldez  ( 2021-07-03 19:00:54 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-07-02 22:36:40 -0500

Seen: 221 times

Last updated: Jul 03 '21