autorope / donkeycar

Open source hardware and software platform to build a small scale self driving car.
http://www.donkeycar.com
MIT License
3.05k stars 1.28k forks source link

UI update #1173

Closed DocGarbanzo closed 2 months ago

DocGarbanzo commented 2 months ago

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
  4. 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

DocGarbanzo commented 2 months ago

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

Kim0189826 commented 2 months ago

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

thanks

Ezward commented 2 months ago

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 commented 2 months ago

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

Ezward commented 2 months ago

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 ed@raspberrypi5.local 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 commented 2 months ago

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 ed@raspberrypi5.local 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.