Skip to content

Commit

Permalink
UI update (#1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
DocGarbanzo committed Apr 27, 2024
1 parent 5efa1b0 commit 45dc516
Show file tree
Hide file tree
Showing 29 changed files with 3,205 additions and 2,281 deletions.
2 changes: 1 addition & 1 deletion donkeycar/__init__.py
Expand Up @@ -3,7 +3,7 @@
from pyfiglet import Figlet
import logging

__version__ = '5.2.dev0'
__version__ = '5.2.dev1'

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

Expand Down
26 changes: 23 additions & 3 deletions donkeycar/config.py
Expand Up @@ -6,9 +6,9 @@
"""
import os
import types
from logging import getLogger
import logging

logger = getLogger(__name__)
logger = logging.getLogger(__name__)


class Config:
Expand All @@ -29,7 +29,16 @@ def from_object(self, obj):
for key in dir(obj):
if key.isupper():
setattr(self, key, getattr(obj, key))


def from_dict(self, d, keys=[]):
msg = 'Overwriting config with: '
for k, v in d.items():
if k.isupper():
if k in keys or not keys:
setattr(self, k, v)
msg += f'{k}:{v}, '
logger.info(msg)

def __str__(self):
result = []
for key in dir(self):
Expand All @@ -42,6 +51,17 @@ def show(self):
if attr.isupper():
print(attr, ":", getattr(self, attr))

def to_pyfile(self, path):
lines = []
for attr in dir(self):
if attr.isupper():
v = getattr(self, attr)
if isinstance(v, str):
v = f'"{v}"'
lines.append(f'{attr} = {v}{os.linesep}')
with open(path, 'w') as f:
f.writelines(lines)


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

Expand Down
3 changes: 3 additions & 0 deletions donkeycar/management/__init__.py
@@ -0,0 +1,3 @@
import logging

logger = logging.getLogger(__name__)
17 changes: 8 additions & 9 deletions donkeycar/management/base.py
Expand Up @@ -9,7 +9,6 @@
from progress.bar import IncrementalBar
import donkeycar as dk
from donkeycar.management.joystick_creator import CreateJoystick
from donkeycar.management.tub import TubManager

from donkeycar.utils import normalize_image, load_image, math

Expand Down Expand Up @@ -439,7 +438,7 @@ def run(self, args):
class ShowPredictionPlots(BaseCommand):

def plot_predictions(self, cfg, tub_paths, model_path, limit, model_type,
noshow):
noshow, dark=False):
"""
Plot model predictions for angle and throttle against data from tubs.
"""
Expand Down Expand Up @@ -472,9 +471,8 @@ def plot_predictions(self, cfg, tub_paths, model_path, limit, model_type,
tub_record, lambda x: normalize_image(x))
pilot_angle, pilot_throttle = \
model.inference_from_dict(input_dict)
y_dict = model.y_transform(tub_record)
user_angle, user_throttle \
= y_dict[output_names[0]], y_dict[output_names[1]]
user_angle = tub_record.underlying['user/angle']
user_throttle = tub_record.underlying['user/throttle']
user_angles.append(user_angle)
user_throttles.append(user_throttle)
pilot_angles.append(pilot_angle)
Expand All @@ -486,8 +484,10 @@ def plot_predictions(self, cfg, tub_paths, model_path, limit, model_type,
'pilot_angle': pilot_angles})
throttles_df = pd.DataFrame({'user_throttle': user_throttles,
'pilot_throttle': pilot_throttles})

fig = plt.figure()
if dark:
plt.style.use('dark_background')
fig = plt.figure('Tub Plot')
fig.set_layout_engine('tight')
title = f"Model Predictions\nTubs: {tub_paths}\nModel: {model_path}\n" \
f"Type: {model_type}"
fig.suptitle(title)
Expand Down Expand Up @@ -594,7 +594,7 @@ def run(self, args):

class Gui(BaseCommand):
def run(self, args):
from donkeycar.management.kivy_ui import main
from donkeycar.management.ui.ui import main
main()


Expand All @@ -606,7 +606,6 @@ def execute_from_command_line():
'createcar': CreateCar,
'findcar': FindCar,
'calibrate': CalibrateCar,
'tubclean': TubManager,
'tubplot': ShowPredictionPlots,
'tubhist': ShowHistogram,
'makemovie': MakeMovieShell,
Expand Down

0 comments on commit 45dc516

Please sign in to comment.