Ubuntu下在ROS工作空间中添加环境变量及查看环境变量
1.在当前路径下创建将要初始化的文件夹
mkdir -p catkin_qt/src
2.进入src,初始化工作空间
cd catkin_qt/src
catkin_init_workspace //此操作后src文件夹下多出CMakeList.txt
cd .. //返回上级目录
catkin_make //此操作后catkin_qt目录下多出build、devel
3.将当前文件路径加入环境变量
方法一:
pwd //显示当前路径,本人路径为/home/ghy/catkin_qt
echo "source /home/ghy/catkin_qt/devel/setup.bash">> ~/.bashrc
方法二:
进入.bashrc文档
$gedit ~/.bashrc
在最后边加入需要设置变量的shell语句,例如:
source /opt/ros/melodic/setup.bash //ROS安装时的环境变量
source /home/ghy/catkin_qt/devel/setup.bash
4.确认是否加入
source ~/.bashrc
echo $ROS_PACKAGE_PATH
可看到路径已成功加入,显示内容如下:
/home/ghy/catkin_qt/src:/opt/ros/melodic/share