在运行老师给的参考项目时报错:

ImportError: No module named openai_ros

在网上搜了很多资料都没有介绍说怎么安装openai_ros,fanqiang去了外网才找到答案。在这里总结一番:
首先在终端中cd到在你的工作空间:

cd ~/ros_ws/src

执行命令:

git clone https://bitbucket.org/theconstructcore/openai_ros.git

将openai_ros包下载下来后,返回上一级目录:

cd ~/ros_ws

执行编译命令:

catkin_make

然后执行

source devel/setup.bash

最后再执行:

rosdep install openai_ros

就大功告成了。

注:由于我用的是ubuntu20.04+ros_noetic版本,最后一步rosdep我并没有执行,也可以解决报错问题。不清楚其他ros版本是否需要最后一步的执行,大家可以根据自己的ros版本试试看。

------------------------------------------分割线---------------------------------------------------------------
我的ros版本是noetic,今天尝试了最后一步:

rosdep install openai_ros

首先是报错rosdep不存在的问题,我通过:

sudo apt-get install python3-rosdep

安装完之后,根据终端提示需要:

sudo rosdep init

但执行完命令后报错:

ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

后通过这篇博客解决了这个问题。
本以为万事大吉了,没想到重新运行后又报错:

chh3213@Fire-MECHREVO:~/ros_wc$ rosdep install openai_ros

ERROR: the following packages/stacks could not have their rosdep keys resolved to system dependencies:

openai_ros: No definition of [python-catkin-pkg] for OS version [focal]

简直要疯了!于是用谷歌搜索了这个问题,终于通过以下方法解决了:

  • 首先cd到your_ws/src/openai_ros/openai_ros/
  • 打开package.xml:
    gedit package.xml
    大概在14行的位置你会看到:
  <build_depend>python-catkin-pkg</build_depend>

此代码为python2声明了catkin-pkg,但Noetic已经可以在Python3上运行,故将其修改为:

<build_depend>python3-catkin-pkg</build_depend>

或者

<build_depend>python3-catkin-pkg-modules</build_depend>
  • 最后,保存上述操作后,重新运行rosdep install openai_ros
chh3213@Fire-MECHREVO:~/ros_wc$ rosdep install openai_ros
#All required rosdeps installed successfully

完美解决。

Logo

一站式 AI 云服务平台

更多推荐