Skip to content

Commit

Permalink
fix-encoder-pipeline (#929)
Browse files Browse the repository at this point in the history
- the complete.py template hooked up the encoder parts
  using hard-coded values or defaults and ignored
  the configurations for MM_PER_TICK and ODOM_DEBUG.
- In addition, the RotaryEncoder was given a
  hard coded value for the pin rather than use ODOM_PIN.
- Finally, the RotaryEncoder was also using a default
  value for the poll_delay so polling was incorrect
  in anything exception the default vehicle loop rate.
- This commit fixes the building of the pipeline
  in complete.py to use the correct configuration.
  It also calculates the poll_delay for the RotaryEncoder
  based on the DRIVE_LOOP_HZ configuration.
  • Loading branch information
Ezward authored Sep 2, 2021
1 parent b1af0aa commit 6479fed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions donkeycar/templates/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def drive(cfg, model_path=None, use_joystick=False, model_type=None,
if cfg.HAVE_ODOM:
if cfg.ENCODER_TYPE == "GPIO":
from donkeycar.parts.encoder import RotaryEncoder
enc = RotaryEncoder(mm_per_tick=0.306096, pin = cfg.ODOM_PIN, debug = cfg.ODOM_DEBUG)
enc = RotaryEncoder(mm_per_tick=cfg.MM_PER_TICK, pin=cfg.ODOM_PIN, poll_delay=1.0/(cfg.DRIVE_LOOP_HZ*3), debug=cfg.ODOM_DEBUG)
V.add(enc, inputs=['throttle'], outputs=['enc/speed'], threaded=True)
elif cfg.ENCODER_TYPE == "arduino":
from donkeycar.parts.encoder import ArduinoEncoder
enc = ArduinoEncoder()
enc = ArduinoEncoder(mm_per_tick=cfg.MM_PER_TICK, debug=cfg.ODOM_DEBUG)
V.add(enc, outputs=['enc/speed'], threaded=True)
else:
print("No supported encoder found")
Expand Down

0 comments on commit 6479fed

Please sign in to comment.