Replies: 2 comments 1 reply
-
Now I remember where I got this from... def __init__(self):
self.rc_drone = None
self.target = np.array([0.0, 0.0], dtype=np.float32)
self.initialized = False
self.blank_image = np.ones((500, 500, 3), dtype=np.uint8) * 255
self.rendering_thread = Thread(target=self._rendering_thread, args=(), kwargs={}, daemon=True)
def _rendering_thread(self):
from time import sleep
while True:
sleep(0.1)
self.render()
def render(self):
image = self.blank_image.copy()
pos_x, pos_y = self.rc_drone.get_observation()
image = cv2.circle(img=image,
center=(int(pos_x * 200) + 250, int(pos_y * 200) + 250),
radius=10,
color=(255, 0, 0),
thickness=1)
image = cv2.circle(img=image,
center=(int(self.target[0] * 200) + 250, int(self.target[1] * 200) + 250),
radius=5,
color=(0, 0, 255),
thickness=-1)
cv2.imshow("Dummy RC drone", image)
if cv2.waitKey(1) & 0xFF == ord('q'):
return
```
I do not understand... if the thread is always running, would it not always display even if env.render() is NOT called?
On the otherhand, is env.render() making us of the thread? |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can ignore render() entirely, not implement it and not use it. It is a Gymnasium method for environments that don't naturally have a display, for example the dummy drone environment of the rtgym tutorial. This method is entirely optional, it is in charge of displaying a window with whatever you want to display in it. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm a bit confused why the above works in this below:
Beta Was this translation helpful? Give feedback.
All reactions