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

1097 refactor game controller system #1180

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Ezward
Copy link
Contributor

@Ezward Ezward commented May 28, 2024

A proof of concept for an approach to addressing issue #1097. This PR is not intended to be merged; it is here so that the changes to the code can be easily seen and commented upon.

Comments on the general approach to refactoring the game controller code should be addressed to the issue. Use this PR to make comments specific to the code.

running the POC

  • These instructions assume the developer installation has been done.
  • Change the working directory to the root of the donkeycar project folder and check out the branch 1097-refactor-game-controller-system
  • Activate the donkeycar environment, source env/bin/activate
  • to run the vehicle loop python3 donkeycar/parts/controller_events.py
  • to run the simulated loop with event logging: python3 donkeycar/parts/controller_events.py --vehicle=false

Ed and others added 6 commits May 26, 2024 15:37
- It reads the controller and puts the named button or
  axis value into memory as "/event/button/{name}" or
  "/event/axis/name".
- The controller can be given a dictionary to map low level
  button and axis names to some more generic name.  If
  no map is provided then the low level  names are used.
- The event is deleted after one pass through the event loop.
- This is part of controller rewrite.  it is the base system
  for reading raw joystick values and getting them
  into vehicle memory.
- remove() takes a list of keys to delete from memory.

- add type to Vehicle constructor
- Buttons now output press/release/click one-shot events.
  The click event includes the count of sequential fast-clicks
  that can be used to support double-click, triple-click, etc.
- The value of a button event is the time at which the
  event occured.
- The value of an axis event is the value of the axis.
- The state of a control is now written to memory a persistent
  value so that parts can use them as inputs.  This
  allows a part to use one control's value as a modifier to
  another control's event.  It also allows a part to use an control's
  state without having to listen for events and maintain the
  control's state itself.
@Ezward Ezward self-assigned this May 28, 2024
@Ezward
Copy link
Contributor Author

Ezward commented May 28, 2024

This seems like a bug in the memory.py:

value = tuple(key)
, why value = tuple(key) and not value = tuple(value)?

@Ezward Ezward mentioned this pull request May 28, 2024
5 tasks
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.

1 participant