Skip to content

Instantly share code, notes, and snippets.

@winwinashwin
Last active October 19, 2021 13:17
Show Gist options
  • Save winwinashwin/cd7f781013d91caa74f766d247e338e2 to your computer and use it in GitHub Desktop.
Save winwinashwin/cd7f781013d91caa74f766d247e338e2 to your computer and use it in GitHub Desktop.
ROSx Environment variables fetch script for IDE Build configuration
#!/bin/bash
# Prints all ROS specific environment variables used for building the package. Intended to be used for configuring IDE
# environment variables.
#
# Tested with ROS Noetic, ROS Melodic and ROS2 Foxy
#
# @author: Ashwin A Nayar
read -rd '' ROS2_VARS << EOL
AMENT_PREFIX_PATH
PYTHONPATH
ROS_VERSION
ROS_DISTRO
ROS_PYTHON_VERSION
ROS_LOCALHOST_ONLY
LD_LIBRARY_PATH
PATH
EOL
read -rd '' ROS1_VARS << EOL
CMAKE_PREFIX_PATH
PYTHONPATH
ROS_VERSION
ROS_DISTRO
ROS_PYTHON_VERSION
ROS_PACKAGE_PATH
ROSLISP_PACKAGE_DIRECTORIES
ROS_ETC_DIR
ROS_MASTER_URI
ROS_ROOT
LD_LIBRARY_PATH
PATH
EOL
env_string=""
# Change to ROS2_VARS for ROS2
for e in $ROS1_VARS; do
env_string+="$e=${!e};"
done
echo "$env_string"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment