ROS set environment variables
After ROS is installed in Ubuntu, it is in /opt
the path by default. Since ROS commands are frequently used in the terminal during use, its environment variables need to be set.
Ubuntu uses the terminal by default as the command to set the ROS environment variable bash
in :bash
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
bash
If you use the zsh terminal, change all the above commands to zsh
.
Change the ROS environment variables used by the current terminal
ROS needs to find the location of the command through environment variables. If multiple ROS versions are installed, how to determine which ROS version the command used by the current terminal is? Environment variables need to be set by:
source /opt/ros/ROS-RELEASE/setup.bash
It ROS-RELEASE
indicates the ROS version you want to use (such as melodic, noetic, etc.)
- Note: This method can only modify the current terminal. If you open another terminal, the environment variables set in the bash configuration file will still be used by default.
- If you want to change the default ROS environment variable, you need to open ~/.bashrc, find
source /opt/ros/melodic/setup.bash
a command like this, and change melodic to the desired ROS version.
reference
- Hu Chunxu. ROS robot development practice. Beijing: Mechanical Industry Press, 2018.5