ROS Gazebo 模拟器中移动机器人导航的深度强化学习。使用TD3神经网络,机器人学习在模拟环境中导航到随机目标点,同时避开障碍物。通过激光读数检测障碍物,并在极坐标中为机器人提供目标。使用 PyTorch 在 ROS Gazebo 模拟器中接受训练。在 Ubuntu 20.04 上使用 python 3.8.10 和 pytorch 1.10 使用 ROS Noetic 进行测试。

本文使用借鉴了 Goal-Driven Autonomous Exploration Through Deep Reinforcement Learning 这篇论文

https://github.com/reiniscimurs/DRL-robot-navigation

1.前期准备

所需要的依赖:

ROS Noetic

PyTorch

https://pytorch.org/get-started/locally/

Tensorboard

https://github.com/tensorflow/tensorboard

2.下载源码

 git clone https://github.com/reiniscimurs/DRL-robot-navigation

3.编译工作空间

 cd ~/DRL-robot-navigation/catkin_ws
 catkin_make_isolated

PS:这里请注意,一般刚开始编译工作空间时,可能会出现各种各样的库缺失,具体缺失的内容可以根据实际报错信息,然后安装

sudo apt install ros-noetic-$ 你缺失的库 $                    

还有可能出现额外的问题,建议删除catkin_ws下除src的所有文件

4.打开终端并设置

 export ROS_HOSTNAME=localhost
 export ROS_MASTER_URI=http://localhost:11311
 export ROS_PORT_SIM=11311
 export GAZEBO_RESOURCE_PATH=~/DRL-robot-navigation/catkin_ws/src/multi_robot_scenario/launch
 source ~/.bashrc
 cd ~/DRL-robot-navigation/catkin_ws
 source devel_isolated/setup.bash

5.进行训练

 cd ~/DRL-robot-navigation/TD3
 python3 train_velodyne_td3.py

终止训练:

 killall -9 rosout roslaunch rosmaster gzserver nodelet robot_state_publisher gzclient python python3

6.tensorboard查看训练结果

 cd ~/DRL-robot-navigation/TD3
 tensorboard --logdir runs

PS:如果tensorboard无法显示相应的曲线,显示No dashboards are active for the current data set,建议更换浏览器,在谷歌浏览器中打开

7.完成训练,测试模型

 cd ~/DRL-robot-navigation/TD3
 python3 test_velodyne_td3.py

PS:训练呈现

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐