Skip to content

Environmental Variables

Kenneth L edited this page Oct 23, 2023 · 2 revisions

What are environmental variables

Environmental variables in Linux are variables that contain information about the operating system and user environment. They can be used by programs and scripts to access system resources or to store configuration settings.

How can you change them?

To change environmental variables in Linux, you can modify the values in the ~/.bashrc or ~/.bash_profile files and then source them using the source command. This will apply the changes immediately.

In regular linux, read up using export in bash. In our repository, many helper functions help change environmental variables temporarily (within a terminal) or persistently. See commands pexport, punset, setbotmaster, setdevmaster, etc.

How can you check their values?

  • To check the value of a specific variable, use echo $VARIABLE_NAME.

  • To list all environmental variables, use the env command.

  • To find specific variables, use the grep command with a keyword or pattern to search for.

    Example

    To find all environmental variables containing the word "HOME", you can use the following command:

    env | grep HOME
    

    This will list all environmental variables that contain the word "HOME", such as HOME=/home/username and XDG_DATA_HOME=/home/username/.local/share.

Common Unix variables

  • PATH: Linux path for finding executables
  • HOME: The user's home directory
  • PWD: The current working directory
  • USER: The current user's username
  • SHELL: The user's default shell

Custom environmental variables

The following are defined in ~/.bashrc

  • CATKIN_WS_PATH: Where the catkin_ws is, used for cdws; defaults to ~/catkin_ws
  • GRA_REPO: Used for cdrepo, defaults to ~/gra
  • DOCKERFILE: Used for RUN script, described below; defaults to $GRA_REPO/.devcontainer/Dockerfile
  • DEV_MASTER_URI: The development machine (Docker’s) master URI, assuming we are using the same machine for the roscore
  • DEV_BOT_HOSTNAME: The hostname / IP to find the robot, used for various remote scripts to the robot.
  • DEV_BOT_USERNAME: The username in which we should use to login to the bot
  • DEV_BOT_MASTER_URI: The address where roscore would live in, if we are using the bot as the master.
  • DEV_ENV: Helper variable to indicate if we are in the Docker, or the bot.
  • ARDUINO_UPDATE_PORT: The port in which we should flash the Arduino with in au

ROS variables

  • ROS_MASTER_URI: Specifies the URI of the ROS master. Manages the communication between the different nodes in a ROS system.
  • ROS_HOSTNAME: Specifies the hostname or IP address of the machine running the ROS node. Identifies the computer running the node to other nodes in the system.

Clone this wiki locally