From 20c5ee64abaa444ee17aab15619c70d4b018fdd7 Mon Sep 17 00:00:00 2001 From: yuwatidora Date: Wed, 24 Jul 2024 13:34:06 -0400 Subject: [PATCH 1/2] edited line 463 in gym_duckietown/simulator.py and added related declarations and imports --- gym_duckietown/simulator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gym_duckietown/simulator.py b/gym_duckietown/simulator.py index 8fdbd5a4..01ec6da6 100644 --- a/gym_duckietown/simulator.py +++ b/gym_duckietown/simulator.py @@ -6,6 +6,8 @@ from dataclasses import dataclass from typing import Tuple import geometry +from numpy.random import default_rng + @dataclass class DoneRewardInfo: @@ -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) @@ -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 From 5bffea8c950e3e796b463528558ead214334b9eb Mon Sep 17 00:00:00 2001 From: Yu Wati Nyi <60333098+yuwatidora@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:13:19 -0400 Subject: [PATCH 2/2] Update README.md --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 5e8738de..18459f8e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Welcome to Duckietown! 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! @@ -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. + +``` +
line 275, in se2_from_linear_angular
+    linear = np.array(linear, dtype='float64')
+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.
+``` + + +