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

added speed return for simulator in dgym.py #673

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions donkeycar/parts/dgym.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, sim_path, host="127.0.0.1", port=9091, headless=0, env_name="
self.frame = self.env.reset()
self.action = [0.0, 0.0, 0.0]
self.running = True
self.info = { 'pos' : (0., 0., 0.)}
self.info = { 'pos' : (0., 0., 0.), 'speed' : 0.0}
self.delay = float(delay)

def update(self):
Expand All @@ -42,7 +42,7 @@ def run_threaded(self, steering, throttle, brake=None):
if self.delay > 0.0:
time.sleep(self.delay / 1000.0)
self.action = [steering, throttle, brake]
return self.frame
return self.frame, self.info['speed']

def shutdown(self):
self.running = False
Expand Down
2 changes: 1 addition & 1 deletion donkeycar/templates/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def drive(cfg, model_path=None, use_joystick=False, model_type=None, camera_type
threaded = True
inputs = ['angle', 'throttle', 'brake']

V.add(cam, inputs=inputs, outputs=['cam/image_array'], threaded=threaded)
V.add(cam, inputs=inputs, outputs=['cam/image_array', 'speed'], threaded=threaded)

if use_joystick or cfg.USE_JOYSTICK_AS_DEFAULT:
#modify max_throttle closer to 1.0 to have more power
Expand Down