[ROS Notes] Setting and modifying ROS environment variables

ROS set environment variables

After ROS is installed in Ubuntu, it is in /optthe 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 bashin :bash

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

bashIf 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-RELEASEindicates 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.basha command like this, and change melodic to the desired ROS version.

reference

  1. Hu Chunxu. ROS robot development practice. Beijing: Mechanical Industry Press, 2018.5

おすすめ

転載: blog.csdn.net/hypc9709/article/details/130111257