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

UI update #1173

Merged
merged 13 commits into from
Apr 27, 2024
Merged

UI update #1173

merged 13 commits into from
Apr 27, 2024

Conversation

DocGarbanzo
Copy link
Contributor

@DocGarbanzo DocGarbanzo commented Apr 15, 2024

Summary

UI changes

The UI code has been in a single python and single kv file which is hard to maintain. Also, the kivy version 2.0 is by now quite outdated. The UI was crashing on RPi. Here is a refactoring that resolves these issues and adds a lot more features in addition:

  1. The new ui rewrite is now separated into each source file (py and kv) for each screen
  2. The ui design has been greatly reworked with a more modern layout and there is more explanation about the different features directly in the app.
  3. Several features have been upgraded and improved:
  • In the tub manager screen the timestamp record can now be viewed as human readable
  • In the trainer screen where the user can overwrite config variables one can now choose multiple variables at once and this setting is stored. So if one likes to have CACHE_IMAGES, MAX_EPOCHS and BATCH_SIZE available in the screen to fine-tune the training, this is now possible.
  • Config variable that are overwritten can now be saved back into the myconfig.py file to be permanent
  • In the trainer screen the database columns can be selected/deselected for a cleaner view
  • The pilot arena screen allows to load even more pilots and allows to configure the panel view by selecting the number of columns. Also very useful if only 1 pilot is chosen.
  • The pilot arena screen now also offers to run Tub plot, and the command donkey tubplot has been removed as it was not working anyway.
  • The pilot arena colors the user and model data matching with the lines in the images
  • Graphs in the UI are now produced by matplotlib
  1. The UI will now by default be installed also on the RPi. The donkey installation requires a sudo apt install libhdf5-dev before.

Other changes

We have introduced a more versatile image caching policy to support a binary caching format in addition to the no cache and the numpy array which we have now. The binary format stores the jpeg compression which gives a good compromise between performance and memory footprint. Training with 100k records and binary caching using 32GB or ram w/o swapping is possible.

To install this code

I pushed this code to test-pypi and it can be installed with pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple donkeycar-pypi\[XX\]==5.2.dev3, where XX is either pc or pi or nano. No escaping of [ or ] needed if you are on bash.

Screenshots

Tub manager

image

Trainer

image

Pilot arena

image

Car connector

image

- Allowing multiple modifiers to the config in train screen
- Allow saving overwritten config variables into the myconfig.py file
- Add window to show all training config parameters of trained pilots in the train screen
- Allow overwriting training comments in the train screen
- Allow selection of columns in the pilot panel in the train screen
- Allowing multiple pilots in the pilot screen
- Integrating tubplot into the pilot screen
- Switching the tub graph to native matplotlib in tub screen
- Refactor UI into multiple files
- Improve UI layout using dark rounded backgrounds for grouping widgets for each functionality

Improvement to image caching:
- Replace binary flag CACHE_IMAGES by 3 flags for no-caching, caching as np uint8 arrays or caching as jpeg binaries which is a good alternative if caching as uint8 images uses too much memory, but binary jpegs do still fit.
- bugfix for missing processor in image() method of TubRecord

Fix pytorch packages and model
# Conflicts:
#	donkeycar/__init__.py
#	donkeycar/parts/pytorch/torch_train.py
#	donkeycar/tests/test_torch.py
#	setup.cfg
…dependencies pull a very old version that doesn't work with tensorflow.
…s from other modules are printed and over-flooding the shell.
@DocGarbanzo DocGarbanzo marked this pull request as ready for review April 15, 2024 20:03
@DocGarbanzo DocGarbanzo requested review from zlite, a team and Ezward April 15, 2024 20:04
@DocGarbanzo
Copy link
Contributor Author

You would write: manage.py drive --model ~/mycar/models/pilot 23-05-11_22.tflite --type tflite_linear.

@Kim0189826
Copy link

You would write: manage.py drive --model ~/mycar/models/pilot 23-05-11_22.tflite --type tflite_linear.

thanks

@Ezward
Copy link
Contributor

Ezward commented Apr 20, 2024

This is what I got on a fresh RPi OS 64bit installed with RPi image on a RPi 5

ed@raspberrypi5:~ $ sudo apt install libhdf5-dev
-- snip

ed@raspberrypi5:~ $ python3 -m venv env --system-site-packages
ed@raspberrypi5:~ $ echo "source ~/env/bin/activate" >> ~/.bashrc
ed@raspberrypi5:~ $ . ~/env/bin/activate
(env) ed@raspberrypi5:~ $ pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple donkeycar-pypi\[pi\]==5.2.dev2
Looking in indexes: https://test.pypi.org/simple/, https://www.piwheels.org/simple, https://pypi.org/simple
Collecting donkeycar-pypi[pi]==5.2.dev2
  Downloading https://test-files.pythonhosted.org/packages/1e/6d/6e43800d463d6096801a661a6df217b1e44d359e8d396ccc39458ad20913/donkeycar_pypi-5.2.dev2-py3-none-any.whl (688 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 688.7/688.7 kB 5.4 MB/s eta 0:00:00
-- snip


using donkey v5.2.dev2 ...
Creating car folder: /home/ed/mycar
making dir  /home/ed/mycar
Creating data & model folders.
making dir  /home/ed/mycar/models
making dir  /home/ed/mycar/data
making dir  /home/ed/mycar/logs
Copying car application template: complete
Copying car config defaults. Adjust these before starting your car.
Copying train script. Adjust these before starting your car.
Copying calibrate script. Adjust these before starting your car.
Copying my car config overrides
Donkey setup complete.
(env) ed@raspberrypi5:~ $ cd mycar
(env) ed@raspberrypi5:~/mycar $ donkey ui
________             ______                   _________              
___  __ \_______________  /___________  __    __  ____/_____ ________
__  / / /  __ \_  __ \_  //_/  _ \_  / / /    _  /    _  __ `/_  ___/
_  /_/ // /_/ /  / / /  ,<  /  __/  /_/ /     / /___  / /_/ /_  /    
/_____/ \____//_/ /_//_/|_| \___/_\__, /      \____/  \__,_/ /_/     
                                 /____/                              

using donkey v5.2.dev2 ...
Traceback (most recent call last):
  File "/home/ed/env/bin/donkey", line 8, in <module>
    sys.exit(execute_from_command_line())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ed/env/lib/python3.11/site-packages/donkeycar/management/base.py", line 625, in execute_from_command_line
    c.run(args[2:])
  File "/home/ed/env/lib/python3.11/site-packages/donkeycar/management/base.py", line 597, in run
    from donkeycar.management.ui.ui import main
  File "/home/ed/env/lib/python3.11/site-packages/donkeycar/management/ui/ui.py", line 2, in <module>
    from kivy.logger import Logger, LOG_LEVELS
ModuleNotFoundError: No module named 'kivy'

@Ezward
Copy link
Contributor

Ezward commented Apr 20, 2024

I uninstalled 5.2.dev3 and installed 5.2.dev3 and I saw it installing kivy, matplotlib, etc. Then donkey ui launched correctly.

@Ezward
Copy link
Contributor

Ezward commented Apr 20, 2024

There is a problem with the car connector in the case where we are running donkey ui from the car. I tried using PI_USERNAME = "ed" PI_HOSTNAME = "raspberrypi5.local" and the shell asked me for password after ui launched, but would not recognize it. Yet I could do ssh [email protected] and it would ask for my password and accept it and open the secure shell. Same if I used localhost or 127.0.0.1 so I could not connect to the car if it is local.

@DocGarbanzo
Copy link
Contributor Author

There is a problem with the car connector in the case where we are running donkey ui from the car. I tried using PI_USERNAME = "ed" PI_HOSTNAME = "raspberrypi5.local" and the shell asked me for password after ui launched, but would not recognize it. Yet I could do ssh [email protected] and it would ask for my password and accept it and open the secure shell. Same if I used localhost or 127.0.0.1 so I could not connect to the car if it is local.

It does not make sense to connect from the RPi through ssh to the RP in the UI. Because you directly navigate to your ~/mycar directory where you access the tub data and store the models. I have tried to setup ssh and doing ssh from the RPi into itself using ssh-copy-id. While this works in the shell, it causes the UI to get stalled somehow. However, given that is not a realistic scenario, I don't think this is an issue. But it work if you use the remote connection as intended, ie. where you run the UI on the RPi and you transfer the data from another computer, e.g. another RPi on another car.

Copy link
Contributor

@Ezward Ezward left a comment

Choose a reason for hiding this comment

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

Looks great. The refactor of the ui code is really good. I'm sorry it so long to get to this. Thank you for your patience and for this great work.

@DocGarbanzo DocGarbanzo merged commit 45dc516 into autorope:main Apr 27, 2024
3 checks passed
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.

3 participants