Skip to content

Conversation

@mgagvani
Copy link
Contributor

This PR introduces two parts:

  1. ScreenCamera is a part in camera.py which takes screenshots and uses those as camera images.
  2. VirtualController in actuator.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

import threading
import numpy as np
from PIL import Image
import mss
Copy link
Contributor

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.

Copy link
Contributor

@DocGarbanzo DocGarbanzo left a 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=())
Copy link
Contributor

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):
Copy link
Contributor

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to overwrite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants