本机环境:ubuntu16.04, ros-kinetic
$ roscore
报错
Traceback (most recent call last): File "/opt/ros/kinetic/bin/roscore", line 70, in <module> roslaunch.main(['roscore', '--core'] + sys.argv[1:]) AttributeError: 'module' object has no attribute 'main'
经过多番检索和尝试,终于找出了原因.
首先查看环境变量
$ env | grep ROS
输出如下
ROS_ROOT=/opt/ros/kinetic/share/ros ROS_PACKAGE_PATH=/home/gordon/ros_ws/src:/opt/ros/kinetic/share ROS_MASTER_URI=http://localhost:11311 ROSCONSOLE_CONFIG_FILE=/home/gordon/ros_ws/src/ros_comm/tools/rosconsole/config/rosconsole.config ROS_VERSION=1 ROSLISP_PACKAGE_DIRECTORIES=/home/gordon/ros_ws/devel/share/common-lisp ROS_DISTRO=kinetic ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
高亮处变量,本应该如下所示。
ROSCONSOLE_CONFIG_FILE=/opt/ros/kinetic/share/ros/config/rosconsole.config
检查后发现,之前下载在工作空间的ros_comm源码包,与ros内置的工具文件互相冲突。
解决方法:
1)移除ros_comm源码包,移除工作空间中的devel文件夹
2) export ROSCONSOLE_CONFIG_FILE=/opt/ros/kinetic/share/ros/config/rosconsole.config
3)再次 catkin_make