Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Request to gym-duckietown master branch #282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Welcome to <b>Duckietown</b>!
5. [Poor performance, low frame rate](#Poor-performance-low-frame-rate)
6. [RL training doesn't converge](#RL-training-doesnt-converge)
7. [Unknown encoder 'libx264' when using gym.wrappers.Monitor](#Unknown-encoder-libx264-when-using-gymwrappersMonitor)
8. [Error: cannot import name 'gluNewQuadric' from 'pyglet.gl'](#Error:-cannot-import-name-'gluNewQuadric'-from-'pyglet.gl')

Thanks @na018 for contributing this!

Expand Down Expand Up @@ -339,3 +340,33 @@ conda install -c conda-forge ffmpeg
```

Alternatively, screencasting programs such as [Kazam](https://launchpad.net/kazam) can be used to record the graphical output of a single window.

### Error: cannot import name 'gluNewQuadric' from 'pyglet.gl'

Create a virtual environment as advised in https://docs.duckietown.com/daffy/devmanual-software/intermediate/simulation/index.html

```
$ cd ~ && virtualenv dt-sim
$ source dt-sim/bin/activate
$ pip3 install duckietown-gym-daffy
```

cd into gym-duckietown and try running `./manual_control.py --env-name Duckietown-udem1-v0`.
If you run into the error below,

```
ImportError: cannot import name 'gluNewQuadric' from 'pyglet.gl'
```
downgrade pyglet `pip3 install pyglet==1.5.11`.

If your gym_duckietown/simulator.py uses numpy's deprecated function `tile_idx=self.np_random.randint(0,len(self.driveable_tiles))` in line 463, you may run into the error below. If so, make the needed changes by using `tile_idx=self.rng.integers(0,len(self.driveable_tiles))` instead.
For it to work, you will have to add `from numpy.random import default_rng` in line 9, and `self.rng=default_rng()` in line 183.

```
<pre>line 275, in se2_from_linear_angular
linear = np.array(linear, dtype=&apos;float64&apos;)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.</pre>
```



9 changes: 7 additions & 2 deletions gym_duckietown/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from dataclasses import dataclass
from typing import Tuple
import geometry
from numpy.random import default_rng


@dataclass
class DoneRewardInfo:
Expand Down Expand Up @@ -178,7 +180,9 @@ def __init__(
:param distortion: If true, distorts the image with fish-eye approximation
:param randomize_maps_on_reset: If true, randomizes the map on reset (Slows down training)
"""
# first initialize the RNG
self.rng = default_rng()

# first initialize the RNG
self.seed_value = seed
self.seed(seed=self.seed_value)

Expand Down Expand Up @@ -460,7 +464,8 @@ def reset(self):
tile = self.start_tile
else:
# Select a random drivable tile to start on
tile_idx = self.np_random.randint(0, len(self.drivable_tiles))
#tile_idx = self.np_random.randint(0, len(self.drivable_tiles))
tile_idx = self.rng.integers(0, len(self.drivable_tiles))
tile = self.drivable_tiles[tile_idx]

# Keep trying to find a valid spawn position on this tile
Expand Down