# 基于DQN的gym\_gazebo运行代码演示

## 基于DQN的gym\_gazebo运行代码演示

* [ ] [基于DQN的gym\_gazebo运行代码演示](https://porter.gitbook.io/deep-learning-series/di-si-zhang-ros-ji-qi-ren/pages/-LeCM0DPyEPujCPbpi0M#基于dqn的gym_gazebo运行代码演示)
* [ ] [下载算法包](https://porter.gitbook.io/deep-learning-series/di-si-zhang-ros-ji-qi-ren/pages/-LeCM0DPyEPujCPbpi0M#下载算法包)
* [ ] [运行脚本](https://porter.gitbook.io/deep-learning-series/di-si-zhang-ros-ji-qi-ren/pages/-LeCM0DPyEPujCPbpi0M#运行脚本)
* [ ] [终端效果](https://porter.gitbook.io/deep-learning-series/di-si-zhang-ros-ji-qi-ren/pages/-LeCM0DPyEPujCPbpi0M#终端效果)
* [ ] [export　端口环境添加](https://porter.gitbook.io/deep-learning-series/di-si-zhang-ros-ji-qi-ren/pages/-LeCM0DPyEPujCPbpi0M#export　端口环境添加)
* [ ] [运行ＧＵＩ效果](https://porter.gitbook.io/deep-learning-series/di-si-zhang-ros-ji-qi-ren/pages/-LeCM0DPyEPujCPbpi0M#运行ｇｕｉ效果)
* [x] Edit By Porter, 积水成渊,蛟龙生焉。&#x20;

## 下载算法包

```bash
git clone https://github.com/ipa-bfb-sc/CSN-RL
cd ./CSN-RL
```

## 运行脚本

```bash
cd ~/文档/GitHub_Projects/CSN-RLqqq/DQN
python3 ./DQN_CirTurtleBot.py
```

## 终端效果

```bash
porter@porter-Aspire:~/文档/GitHub_Projects/CSN-RLqqq/DQN$ python3 ./DQN_C
DQN_CartPole.py      DQN_CirTurtleBot.py  
porter@porter-Aspire:~/文档/GitHub_Projects/CSN-RLqqq/DQN$ python3 ./DQN_CirTurtleBot.py 
Using TensorFlow backend.
ROS_MASTER_URI=http://localhost:12935

GAZEBO_MASTER_URI=http://localhost:12936

Gazebo launched!
Unable to register with master node [http://localhost:12935]: master may not be running yet. Will keep trying.
... logging to /home/porter/.ros/log/9b695694-7000-11e9-a24a-f0761cd1b3e0/roslaunch-porter-Aspire-32299.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://porter-Aspire:36739/

SUMMARY
========
```

![CSN\_RL\_DQN\_run](/files/-LeCM13t1C_8oBXB1Tr1)

## export　端口环境添加

此时不会出gazebo，要查看实时的效果，运行如下命令

```bash
porter@porter-Aspire:~$ export ROS_MASTER_URI=http://localhost:12935
porter@porter-Aspire:~$ export GAZEBO_MASTER_URI=http://localhost:12936
porter@porter-Aspire:~$ gzclient
```

![CSN\_RL\_DQN\_export](/files/-LeCM13zTRogMm7thwO-)

如果不成功，执行

```bash
porter@porter-Aspire:~$ cd /home/porter/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/devel
porter@porter-Aspire:~/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/devel$  source setup.bash
porter@porter-Aspire:~$ export ROS_MASTER_URI=http://localhost:12935
porter@porter-Aspire:~$ export GAZEBO_MASTER_URI=http://localhost:12936
porter@porter-Aspire:~$ gzclient
```

## 运行ＧＵＩ效果

![CSN\_RL\_DQN\_CirTurtleBot](/files/-LeCM140rmrQo79IukOL)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://porter.gitbook.io/deep-learning-series/di-si-zhang-ros-ji-qi-ren/ji-yu-dqn-de-gymgazebo-yun-hang-dai-ma-yan-shi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
