时间:2019年4月30日,将2018-2019-1学期,也就是2018年秋学期的一些工作文字稿转录为博文。




课程教学实践环境:


系统Ubuntu 18.04.2 LTS + ROS Melodic(1.0)1.14.3 ~ 1943 + ROS  Crystal(2.0)0.6.1 ~ 541 etc.


仿真:Gazebo 9.8.0 + V-Rep 3.6.1 + Webots 2019a.1 etc.


实物:Cozmo/Vector + Leap Motion + Joystick + Camera + Microphone + Speaker + Phone(ios&android)+ Arduino etc.


镜像:ROS2Go ver2.0 + 实验楼ROS + Exbot ROS iso indigo&kinetic etc.


书籍:ROS机器人高效编程 + ROS机器人项目开发11例 etc.


编程:Matlab 2018a + Python 2.7 + Python 3.6 + C++ etc.


智能:Tensorflow + Caffe + OpenAI etc.


语音:科大讯飞 + 百度语音 + Sphinx etc.


2015-2019全部涉及软硬件平台更多,均在博客中有记录和介绍,此处不再赘述。


先以gym-gazebo为例,简要说明一下:


测试和调试环境:Ubuntu 18.04.2 LTS,其余如上文所述。


gym-gazebo支持ROS Melodic(1.0),gym-gazebo2支持ROS Crystal(2.0)


  1. https://github.com/erlerobot/gym-gazebo(ROS 1)
  2. https://github.com/AcutronicRobotics/gym-gazebo2 (ROS 2)




 




版本问题:将gazebo-8代码替换给gezbo-9:


Could not open file[/usr/share/gazebo-8/worlds/empty_bullet.world]







使用Gazebo的Open gym扩展,下面以ROS Melodic为例介绍:


An OpenAI gym extension for using Gazebo known as gym-gazebo


This work presents an extension of the initial OpenAI gym for robotics using ROS and Gazebo. A whitepaper about this work is available at https://arxiv.org/abs/1608.05742. Please use the following BibTex entry to cite our work:


  1. @article{zamora2016extending,
  2. title={Extending the OpenAI Gym for robotics: a toolkit for reinforcement learning using ROS and Gazebo},
  3. author={Zamora, Iker and Lopez, Nestor Gonzalez and Vilches, Victor Mayoral and Cordero, Alejandro Hernandez},
  4. journal={arXiv preprint arXiv:1608.05742},
  5. year={2016}
  6. }


论文发表和简要介绍如上。


gym-gazebo is a complex piece of software for roboticists that puts together simulation tools, robot middlewares (ROS, ROS 2), machine learning and reinforcement learning techniques. All together to create an environment whereto benchmark and develop behaviors with robots. Setting up gym-gazebo appropriately requires relevant familiarity with these tools.


Code is available “as it is” and currently it’s not supported by any specific organization. Community support is available here. Pull requests and contributions are welcomed.


gym-gazebo是一个复杂的机器人软件软件,它将模拟仿真工具,机器人中间件(ROS,ROS 2),机器学习和强化学习技术结合在一起。共同创造一个环境,用机器人来评估和开发行为。正确设置gym-gazebo需要熟悉这些工具。


目录



安装



Ubuntu 18.04


基本要求



ROS Melodic相关的依赖


  1. sudo apt-get install \
  2. python-pip python3-vcstool python3-pyqt4 \
  3. pyqt5-dev-tools \
  4. libbluetooth-dev libspnav-dev \
  5. pyqt4-dev-tools libcwiid-dev \
  6. cmake gcc g++ qt4-qmake libqt4-dev \
  7. libusb-dev libftdi-dev \
  8. python3-defusedxml python3-vcstool \
  9. ros-melodic-octomap-msgs \
  10. ros-melodic-joy \
  11. ros-melodic-geodesy \
  12. ros-melodic-octomap-ros \
  13. ros-melodic-control-toolbox \
  14. ros-melodic-pluginlib \
  15. ros-melodic-trajectory-msgs \
  16. ros-melodic-control-msgs \
  17. ros-melodic-std-srvs \
  18. ros-melodic-nodelet \
  19. ros-melodic-urdf \
  20. ros-melodic-rviz \
  21. ros-melodic-kdl-conversions \
  22. ros-melodic-eigen-conversions \
  23. ros-melodic-tf2-sensor-msgs \
  24. ros-melodic-pcl-ros \
  25. ros-melodic-navigation \
  26. ros-melodic-sophus



安装Python包:


  1. sudo pip install gym
  2. sudo apt-get install python-skimage
  3. sudo pip install h5py
  4. pip install tensorflow-gpu (if you have a gpu if not then just pip install tensorflow)
  5. sudo pip install keras


安装gym-gazebo:


  1. cd ~
  2. git clone https://github.com/erlerobot/gym-gazebo
  3. cd gym-gazebo
  4. sudo pip install -e .


运行bash文件,构建ros工作区:


  1. cd gym-gazebo/gym_gazebo/envs/installation
  2. bash setup_melodic.bash


执行示例


运行qlearn的示例:


终端1


  1. cd gym-gazebo/gym_gazebo/envs/installation/
  2. bash turtlebot_setup.bash


终端2


  1. cd gym-gazebo/examples/turtlebot
  2. python circuit_turtlebot_lidar_qlearn.py


运行dqn的示例:


终端1


  1. cd gym-gazebo/gym_gazebo/envs/installation/
  2. bash turtlebot_nn_setup.bash


终端2


  1. cd gym-gazebo/examples/turtlebot
  2. python circuit_turtlebot_lidar_qlearn.py


 


用法


建造并安装gym-gazebo


库的根目录中:


sudo pip install -e .


运行环境


  • 加载与要启动的机器人对应的环境变量。例如加载Turtlebot:

  1. cd gym_gazebo/envs/installation
  2. bash turtlebot_setup.bash


注意:所有设置脚本都可用 gym_gazebo/envs/installation


  • 运行可用的任何示例examples/。例如:

  1. cd examples/turtlebot
  2. python circuit2_turtlebot_lidar_qlearn.py


显示仿真模拟


要在模拟过程中查看Gazebo中发生的情况,请运行gazebo客户端。为了启动gzclient并能够将其连接到运行gzserver


  1. 打开一个新终端。
  2. 获取相应的设置脚本,这将更新_GAZEBO_MODEL_PATH_变量:例如source setup_turtlebot.bash
  3. 导出_gazebo_env_提供的GAZEBO_MASTER_URI。您将看到在每个脚本执行开始时打印的变量。例如export GAZEBO_MASTER_URI=http://localhost:13853

注意:现在需要此指令,因为gazebo_env为GAZEBO_MASTER_URI创建了一个随机端口,允许同时运行多个模拟实例。如果您不打算启动多个实例,可以从环境中删除以下两行:


  1. os.environ [ “ ROS_MASTER_URI ” ] = “ http:// localhost:” + self.port
  2. os.environ [ “ GAZEBO_MASTER_URI ” ] = “ http:// localhost:” + self.port_gazebo


最后,启动gzclient。


gzclient


显示奖励细节


通过运行以下脚本显示显示当前奖励历史记录的图表:


  1. cd examples/utilities
  2. python display_plot.py


提示:使用—helpflag来获得更多选项。



杀死后台进程


有时,在结束或杀死模拟gzserverrosmaster留在后台后,请确保在开始新测试之前结束它们。


我们建议创建一个别名来终止这些进程。


echo  “ alias killgazebogym =’killall -9 rosout roslaunch rosmaster gzserver nodelet robot_state_publisher gzclient’ ”  >>  〜/ .bashrc


更多详细内容查看英文原文链接!!!