-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Support for Video Games as a Medium of Control/Recording #1193
base: main
Are you sure you want to change the base?
Conversation
import numpy as np | ||
from PIL import Image | ||
import mss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look at the failed tests, you need to add the python packages into setup.cfg in the right place. Likely we only want to support that in the PC installation but not on the robot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments in the files.
self.sct = mss.mss() | ||
self.running = True | ||
|
||
self._monitor_thread = threading.Thread(target=self.take_screenshot, args=()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look at other threaded parts. Threads are not started in the constructor but centrally in the car application, when adding the part as a threaded part - which is what you want to do for your part.
self.frame = img_arr | ||
return img | ||
|
||
def update(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method should not return but refresh the class member self.frame
.
assert self.frame is not None | ||
return self.frame | ||
|
||
def run_threaded(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to overwrite.
This PR introduces two parts:
ScreenCamera
is a part incamera.py
which takes screenshots and uses those as camera images.VirtualController
inactuator.py
is a part for an emulated Xbox controller which can be used to control a car in videogames.I used these two parts to make a (mostly) successful pilot in Forza Horizon 3: https://youtu.be/LIuH6aonYWU