Skip to content

Commit 30cff1d

Browse files
committed
Update
1 parent c6e4b89 commit 30cff1d

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ This repository contains code for robot exploration training with Deep Reinforce
1010
</p>
1111

1212
## Dependency
13-
14-
- [TensorFlow](https://www.tensorflow.org/install) (code is writen under TF1.X but is modified to compatible with TF2)
13+
- Python 3
14+
- [scikit-image](https://scikit-image.org/)
15+
- [tensorboardX](https://github.com/lanpa/tensorboardX)
16+
- [TensorFlow](https://www.tensorflow.org/install) (code is writen under TF1.x but it is modified to be compatible with TF2)
1517
- [pybind11](https://github.com/pybind/pybind11) (pybind11 — Seamless operability between C++11 and Python)
1618
```
1719
wget -O ~/Downloads/pybind11.zip https://github.com/pybind/pybind11/archive/master.zip
@@ -24,7 +26,6 @@ This repository contains code for robot exploration training with Deep Reinforce
2426
## Compile
2527

2628
You can use the following commands to download and compile the package.
27-
2829
```
2930
git clone https://github.com/RobustFieldAutonomyLab/DRL_robot_exploration.git
3031
cd DRL_robot_exploration
@@ -33,6 +34,25 @@ cmake ..
3334
make
3435
```
3536

37+
## How to Run?
38+
- For CNN policy
39+
```
40+
cd DRL_robot_exploration/scripts
41+
python3 tf_policy_cnn.py
42+
```
43+
- For RNN policy
44+
```
45+
cd DRL_robot_exploration/scripts
46+
python3 tf_policy_rnn.py
47+
```
48+
- To select running mode, at the beginning of the tf_policy code:
49+
```
50+
# select mode
51+
TRAIN = True
52+
PLOT = False
53+
```
54+
Set ``TRAIN=False`` to run saved policy. You can train your own policy by set ``TRAIN=True``. Set `` PLOT=True `` to turn on visualization plots.
55+
3656
## Cite
3757
3858
Please cite [our paper](https://www.researchgate.net/profile/Fanfei_Chen/publication/330200308_Self-Learning_Exploration_and_Mapping_for_Mobile_Robots_via_Deep_Reinforcement_Learning/links/5d6e7ad4a6fdccf93d381d2e/Self-Learning-Exploration-and-Mapping-for-Mobile-Robots-via-Deep-Reinforcement-Learning.pdf) if you use any of this code:
@@ -45,3 +65,7 @@ Please cite [our paper](https://www.researchgate.net/profile/Fanfei_Chen/publica
4565
year={2019},
4666
}
4767
```
68+
69+
## Reference
70+
- [DeepRL-Agents](https://github.com/awjuliani/DeepRL-Agents)
71+
- [DeepLearningFlappyBird](https://github.com/yenchenlin/DeepLearningFlappyBird)

scripts/tf_policy_cnn.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
from tensorboardX import SummaryWriter
1111
import robot_simulation as robot
1212

13-
# training environment parameters
13+
# select mode
1414
TRAIN = True
1515
PLOT = False
1616

17+
# training environment parameters
1718
ACTIONS = 50 # number of valid actions
1819
GAMMA = 0.99 # decay rate of past observations
1920
OBSERVE = 1e4 # timesteps to observe before training
@@ -72,12 +73,13 @@ def start():
7273
saver = tf.compat.v1.train.Saver()
7374
sess.run(tf.compat.v1.global_variables_initializer())
7475
copy_weights(sess)
75-
checkpoint = tf.train.get_checkpoint_state(network_dir)
76-
if checkpoint and checkpoint.model_checkpoint_path:
77-
saver.restore(sess, checkpoint.model_checkpoint_path)
78-
print("Successfully loaded:", checkpoint.model_checkpoint_path)
79-
else:
80-
print("Could not find old network weights")
76+
if not TRAIN:
77+
checkpoint = tf.train.get_checkpoint_state(network_dir)
78+
if checkpoint and checkpoint.model_checkpoint_path:
79+
saver.restore(sess, checkpoint.model_checkpoint_path)
80+
print("Successfully loaded:", checkpoint.model_checkpoint_path)
81+
else:
82+
print("Could not find old network weights")
8183

8284
# get the first state by doing nothing and preprocess the image to 80x80x4
8385
x_t = robot_explo.begin()

scripts/tf_policy_rnn.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
from tensorboardX import SummaryWriter
99
import robot_simulation as robot
1010

11-
# training environment parameters
11+
# select mode
1212
TRAIN = True
1313
PLOT = False
1414

15+
# training environment parameters
1516
ACTIONS = 50 # number of valid actions
1617
GAMMA = 0.99 # decay rate of past observations
1718
OBSERVE = 1e4 # timesteps to observe before training
@@ -106,12 +107,13 @@ def start():
106107
saver = tf.compat.v1.train.Saver()
107108
sess.run(tf.compat.v1.global_variables_initializer())
108109
copy_weights(sess)
109-
checkpoint = tf.compat.v1.train.get_checkpoint_state(network_dir)
110-
if checkpoint and checkpoint.model_checkpoint_path:
111-
saver.restore(sess, checkpoint.model_checkpoint_path)
112-
print("Successfully loaded:", checkpoint.model_checkpoint_path)
113-
else:
114-
print("Could not find old network weights")
110+
if not TRAIN:
111+
checkpoint = tf.compat.v1.train.get_checkpoint_state(network_dir)
112+
if checkpoint and checkpoint.model_checkpoint_path:
113+
saver.restore(sess, checkpoint.model_checkpoint_path)
114+
print("Successfully loaded:", checkpoint.model_checkpoint_path)
115+
else:
116+
print("Could not find old network weights")
115117

116118
# get the first state by doing nothing and preprocess the image to 84x84x1
117119
x_t = robot_explo.begin()

0 commit comments

Comments
 (0)