基于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,这个问题看似不显眼,但必须要解决。
解决办法:

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:

#!/bin/bash
if [ -z "$ROS_DISTRO" ]; then
  echo "ROS not installed. Check the installation steps: https://github.com/erlerobot/gym#installing-the-gazebo-environment"
fi

program="gazebo"
condition=$(which $program 2>/dev/null | grep -v "not found" | wc -l)
if [ $condition -eq 0 ] ; then
    echo "Gazebo is not installed. Check the installation steps: https://github.com/erlerobot/gym#installing-the-gazebo-environment"
fi

source /opt/ros/kinetic/setup.bash

# Create catkin_ws
ws="catkin_ws"
if [ -d $ws ]; then
  echo "Error: catkin_ws directory already exists" 1>&2
fi
src=$ws"/src"
mkdir -p $src
cd $src
catkin_init_workspace

# Import and build dependencies
cd ../../catkin_ws/src/
vcs import < ../../gazebo.repos
cd ../
catkin_make
bash -c 'echo source `pwd`/devel/setup.bash >> ~/.bashrc'
echo "## ROS workspace compiled ##"

# add own models path to gazebo models path
if [ -z "$GAZEBO_MODEL_PATH" ]; then
  bash -c 'echo "export GAZEBO_MODEL_PATH="`pwd`/../../assets/models >> ~/.bashrc'
  exec bash #reload bashrc
fi

echo "finish setup_kinetic!"

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

cd gym_gazebo/examples/scripts_turtlebot
python circuit2_turtlebot_lidar_qlearn.py

报错:

nuc@xy:~/gym-gazebo/examples/turtlebot$ python circuit2_turtlebot_lidar_qlearn.py 
...
Traceback (most recent call last):
  File "/home/xy/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model", line 32, in <module>
    import tf.transformations as tft
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
    from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>
    from tf2_py import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>
    from ._tf2 import *
ImportError: dynamic module does not define module export function (PyInit__tf2)
...
[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].
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文件中第一行内容更改一下即可:

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

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

nuc@xy:~/gym-gazebo/examples/turtlebot$ python circuit2_turtlebot_lidar_qlearn.py 

[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

解决办法:

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

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

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

主要参考:官方链接

猜你喜欢

转载自blog.csdn.net/qq_42091428/article/details/106239597
今日推荐