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

1104 fix user angle in deep learning #1105

Merged
merged 3 commits into from
Feb 27, 2023
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
11 changes: 3 additions & 8 deletions donkeycar/parts/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ class Pipe:
"""
Just pipe all inputs to the output, so they can be renamed.
"""
def __init__(self):
self.running = True

def run(self, *args):
if self.running:
return args

def shutdown(self):
self.running = False
# seems to be a python bug that takes a single argument
# return makes it into two element tuple with empty last element.
return args if len(args) > 1 else args[0]
20 changes: 12 additions & 8 deletions donkeycar/templates/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from donkeycar.parts.kinematics import Bicycle, InverseBicycle, BicycleUnnormalizeAngularVelocity
from donkeycar.parts.explode import ExplodeDict
from donkeycar.parts.transform import Lambda
from donkeycar.parts.logger import LoggerPart
from donkeycar.parts.pipe import Pipe
from donkeycar.utils import *

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -132,6 +132,11 @@ def drive(cfg, model_path=None, use_joystick=False, model_type=None,
has_input_controller = hasattr(cfg, "CONTROLLER_TYPE") and cfg.CONTROLLER_TYPE != "mock"
ctr = add_user_controller(V, cfg, use_joystick)

#
# convert 'user/steering' to 'user/angle' to be backward compatible with deep learning data
#
V.add(Pipe(), inputs=['user/steering'], outputs=['user/angle'])

#
# explode the buttons input map into individual output key/values in memory
#
Expand Down Expand Up @@ -387,7 +392,7 @@ def run(self, *components):
#
# collect model inference outputs
#
outputs = ['pilot/steering', 'pilot/throttle']
outputs = ['pilot/angle', 'pilot/throttle']

if cfg.TRAIN_LOCALIZER:
outputs.append("pilot/loc")
Expand Down Expand Up @@ -437,11 +442,10 @@ def run(self, *components):
# based on the choice of user or autopilot drive mode
#
V.add(DriveMode(cfg.AI_THROTTLE_MULT),
inputs=['user/mode', 'user/steering', 'user/throttle',
'pilot/steering', 'pilot/throttle'],
inputs=['user/mode', 'user/angle', 'user/throttle',
'pilot/angle', 'pilot/throttle'],
outputs=['steering', 'throttle'])

V.add(LoggerPart(['steering', 'throttle']), inputs=['steering', 'throttle'])

if (cfg.CONTROLLER_TYPE != "pigpio_rc") and (cfg.CONTROLLER_TYPE != "MM1"):
if isinstance(ctr, JoystickController):
Expand Down Expand Up @@ -471,10 +475,10 @@ def run(self, *components):
# add tub to save data
#
if cfg.USE_LIDAR:
inputs = ['cam/image_array', 'lidar/dist_array', 'user/steering', 'user/throttle', 'user/mode']
inputs = ['cam/image_array', 'lidar/dist_array', 'user/angle', 'user/throttle', 'user/mode']
types = ['image_array', 'nparray','float', 'float', 'str']
else:
inputs=['cam/image_array','user/steering', 'user/throttle', 'user/mode']
inputs=['cam/image_array','user/angle', 'user/throttle', 'user/mode']
types=['image_array','float', 'float','str']

if cfg.HAVE_ODOM:
Expand Down Expand Up @@ -512,7 +516,7 @@ def run(self, *components):
types += ['nparray']

if cfg.RECORD_DURING_AI:
inputs += ['pilot/steering', 'pilot/throttle']
inputs += ['pilot/angle', 'pilot/throttle']
types += ['float', 'float']

if cfg.HAVE_PERFMON:
Expand Down