Skip to content

Commit 45dc516

Browse files
authored
UI update (#1173)
1 parent 5efa1b0 commit 45dc516

29 files changed

+3205
-2281
lines changed

donkeycar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pyfiglet import Figlet
44
import logging
55

6-
__version__ = '5.2.dev0'
6+
__version__ = '5.2.dev1'
77

88
logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper())
99

donkeycar/config.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"""
77
import os
88
import types
9-
from logging import getLogger
9+
import logging
1010

11-
logger = getLogger(__name__)
11+
logger = logging.getLogger(__name__)
1212

1313

1414
class Config:
@@ -29,7 +29,16 @@ def from_object(self, obj):
2929
for key in dir(obj):
3030
if key.isupper():
3131
setattr(self, key, getattr(obj, key))
32-
32+
33+
def from_dict(self, d, keys=[]):
34+
msg = 'Overwriting config with: '
35+
for k, v in d.items():
36+
if k.isupper():
37+
if k in keys or not keys:
38+
setattr(self, k, v)
39+
msg += f'{k}:{v}, '
40+
logger.info(msg)
41+
3342
def __str__(self):
3443
result = []
3544
for key in dir(self):
@@ -42,6 +51,17 @@ def show(self):
4251
if attr.isupper():
4352
print(attr, ":", getattr(self, attr))
4453

54+
def to_pyfile(self, path):
55+
lines = []
56+
for attr in dir(self):
57+
if attr.isupper():
58+
v = getattr(self, attr)
59+
if isinstance(v, str):
60+
v = f'"{v}"'
61+
lines.append(f'{attr} = {v}{os.linesep}')
62+
with open(path, 'w') as f:
63+
f.writelines(lines)
64+
4565

4666
def load_config(config_path=None, myconfig="myconfig.py"):
4767

donkeycar/management/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import logging
2+
3+
logger = logging.getLogger(__name__)

donkeycar/management/base.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from progress.bar import IncrementalBar
1010
import donkeycar as dk
1111
from donkeycar.management.joystick_creator import CreateJoystick
12-
from donkeycar.management.tub import TubManager
1312

1413
from donkeycar.utils import normalize_image, load_image, math
1514

@@ -439,7 +438,7 @@ def run(self, args):
439438
class ShowPredictionPlots(BaseCommand):
440439

441440
def plot_predictions(self, cfg, tub_paths, model_path, limit, model_type,
442-
noshow):
441+
noshow, dark=False):
443442
"""
444443
Plot model predictions for angle and throttle against data from tubs.
445444
"""
@@ -472,9 +471,8 @@ def plot_predictions(self, cfg, tub_paths, model_path, limit, model_type,
472471
tub_record, lambda x: normalize_image(x))
473472
pilot_angle, pilot_throttle = \
474473
model.inference_from_dict(input_dict)
475-
y_dict = model.y_transform(tub_record)
476-
user_angle, user_throttle \
477-
= y_dict[output_names[0]], y_dict[output_names[1]]
474+
user_angle = tub_record.underlying['user/angle']
475+
user_throttle = tub_record.underlying['user/throttle']
478476
user_angles.append(user_angle)
479477
user_throttles.append(user_throttle)
480478
pilot_angles.append(pilot_angle)
@@ -486,8 +484,10 @@ def plot_predictions(self, cfg, tub_paths, model_path, limit, model_type,
486484
'pilot_angle': pilot_angles})
487485
throttles_df = pd.DataFrame({'user_throttle': user_throttles,
488486
'pilot_throttle': pilot_throttles})
489-
490-
fig = plt.figure()
487+
if dark:
488+
plt.style.use('dark_background')
489+
fig = plt.figure('Tub Plot')
490+
fig.set_layout_engine('tight')
491491
title = f"Model Predictions\nTubs: {tub_paths}\nModel: {model_path}\n" \
492492
f"Type: {model_type}"
493493
fig.suptitle(title)
@@ -594,7 +594,7 @@ def run(self, args):
594594

595595
class Gui(BaseCommand):
596596
def run(self, args):
597-
from donkeycar.management.kivy_ui import main
597+
from donkeycar.management.ui.ui import main
598598
main()
599599

600600

@@ -606,7 +606,6 @@ def execute_from_command_line():
606606
'createcar': CreateCar,
607607
'findcar': FindCar,
608608
'calibrate': CalibrateCar,
609-
'tubclean': TubManager,
610609
'tubplot': ShowPredictionPlots,
611610
'tubhist': ShowHistogram,
612611
'makemovie': MakeMovieShell,

0 commit comments

Comments
 (0)