基于ubuntu16.04和ROS-kinetic安装gym-gazebo时候遇到不少BUG

官方已不再对ubuntu16.04下的gym-gazebo提供支持,不过要想用,也是可以装的。

一般的安装操作可参考:
  (1) 大佬博客
  (2) 官方github
不过我在安装的过程中还是遇到了各式各样的坑,现在进行总结,希望后人少踩坑。

1. 其中在bash setup_kinetic.bash时候,

遇到提示setup kinetic.bash: line 76: vcs: command not found,这个问题看似不显眼,但必须要解决。
解决办法:

1 sudo apt-get install python3-vcstool

2. 同样在bash setup_kinetic.bash过程中,

(这个问题真的坑了我好久):
(1)提示找不到 /home/xy/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/devel/setup.bash, 然后就是一顿google,最终发现把setup_kinetic.bash文件更改一下,替换成下面这样即可通过bash:

 1 #!/bin/bash
 2 if [ -z "$ROS_DISTRO" ]; then
 3   echo "ROS not installed. Check the installation steps: https://github.com/erlerobot/gym#installing-the-gazebo-environment"
 4 fi
 5 
 6 program="gazebo"
 7 condition=$(which $program 2>/dev/null | grep -v "not found" | wc -l)
 8 if [ $condition -eq 0 ] ; then
 9     echo "Gazebo is not installed. Check the installation steps: https://github.com/erlerobot/gym#installing-the-gazebo-environment"
10 fi
11 
12 source /opt/ros/kinetic/setup.bash
13 
14 # Create catkin_ws
15 ws="catkin_ws"
16 if [ -d $ws ]; then
17   echo "Error: catkin_ws directory already exists" 1>&2
18 fi
19 src=$ws"/src"
20 mkdir -p $src
21 cd $src
22 catkin_init_workspace
23 
24 # Import and build dependencies
25 cd ../../catkin_ws/src/
26 vcs import < ../../gazebo.repos
27 cd ../
28 catkin_make
29 bash -c 'echo source `pwd`/devel/setup.bash >> ~/.bashrc'
30 echo "## ROS workspace compiled ##"
31 
32 # add own models path to gazebo models path
33 if [ -z "$GAZEBO_MODEL_PATH" ]; then
34   bash -c 'echo "export GAZEBO_MODEL_PATH="`pwd`/../../assets/models >> ~/.bashrc'
35   exec bash #reload bashrc
36 fi
37 
38 echo "finish setup_kinetic!"

3. 在运行下面这个简单的测试环境时,

1 cd gym_gazebo/examples/scripts_turtlebot
2 python circuit2_turtlebot_lidar_qlearn.py

报错:

 1 nuc@xy:~/gym-gazebo/examples/turtlebot$ python circuit2_turtlebot_lidar_qlearn.py 
 2 ...
 3 Traceback (most recent call last):
 4   File "/home/xy/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model", line 32, in <module>
 5     import tf.transformations as tft
 6   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
 7     from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
 8   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>
 9     from tf2_py import *
10   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>
11     from ._tf2 import *
12 ImportError: dynamic module does not define module export function (PyInit__tf2)
13 ...
14 [spawn_turtlebot_model-3] process has died [pid 22795, exit code 1, cmd /home/xy/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model -unpause -urdf -param robot_description -model mobile_base __name:=spawn_turtlebot_model __log:=/home/xy/.ros/log/fac134ea-6ea1-11ea-bacb-e470b8e684d0/spawn_turtlebot_model-3.log].
15 log file: /home/xy/.ros/log/fac134ea-6ea1-11ea-bacb-e470b8e684d0/spawn_turtlebot_model-3*.log

这个问题同样隔应了我好久,最后发现把gym-gazebo/gym_gazebo/envs/installation/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model文件中第一行内容更改一下即可:

1 #!/usr/bin/env python
2 将上面内容替换为:
3 #!/usr/bin/env python2

4. 在这之后,又遇到一个报错:

1 nuc@xy:~/gym-gazebo/examples/turtlebot$ python circuit2_turtlebot_lidar_qlearn.py 
2 
3 [Err] [Plugin.hh:165] Failed to load plugin libhector_gazebo_ros_sonar.so: libhector_gazebo_ros_sonar.so: cannot open shared object file: No such file or directory

解决办法:

1 nuc@xy:~$ sudo apt install ros-kinetic-hector-gazebo*

至此,我在安装gym-gazebo过程中所遇到BUG都在这儿了。大家有其他问题可以留言讨论。

5. 安装完成后,做一系列测试

主要参考:官方链接

posted @ 2020-05-20 16:48  墨池有雨  阅读(615)  评论(0编辑  收藏  举报