(ros/qt报错) FATAL: ROS_MASTER_URI is not defined in the environment

安装qt之后,明明打开roscore但是qt运行跟ros有关的节点时报错:

[FATAL] [1450943695.306401842]: ROS_MASTER_URI is not defined in the environment. Either type the following or (preferrably) add this to your ~/.bashrc file in order set up your local machine as a ROS master:

export ROS_MASTER_URI=http://localhost:11311

then, type 'roscore' in another shell to actually launch the master program.

当用qt打开cmakelist时,出现找不到cantkin_make 也是这个原因, qt启动时,没有加载ros环境变量,所以必须从终端启动ros


Traceback (most recent call last):
File "/home/wsh/download_wsh_backup/IGV02-SW-build/catkin_generated/generate_cached_setup.py", line 20, in
from catkin.environment_cache import generate_environment_script
ImportError: No module named catkin.environment_cache

主要原因是因为没有从bash里面启动qt,所以qt的环境变量里面没有ros的变量环境.
解决办法,主要是从bash中启动qt,根本原因是要在ros环境变量执行之后再执行qt

我的解决办法是在.bashrc中添加如下语句


alias qt=/opt/Qt5/Tools/QtCreator/bin/qtcreator





设置了别名,每次启动qt从终端中启动qt,这样就能确保环境变量正确
【(ros/qt报错) FATAL: ROS_MASTER_URI is not defined in the environment】

(ros/qt报错) FATAL: ROS_MASTER_URI is not defined in the environment
文章图片



author: wsh
email: tongzhuodenilove@163.com

    推荐阅读