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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion donkeycar/__init__.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import logging

logger = logging.getLogger(__name__)
17 changes: 8 additions & 9 deletions donkeycar/management/base.py
Original file line number Diff line number Diff line change
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
Loading
Loading