Removed PID settings, changed to 2 button gearbox

This commit is contained in:
2023-10-20 23:18:18 +02:00
parent cbf1e8fba4
commit 14219f2b1e
@@ -12,13 +12,10 @@
# Port D: Not used # # Port D: Not used #
# # # #
################################################################################ ################################################################################
# # # Rebrickable: https://rebrickable.com/mocs/MOC-106368/ #
# Changelog #
# #
################################################################################ ################################################################################
# v0.0.0 25-09-2022 # # LEGO® is a trademark of the LEGO Group of companies which does not sponsor, #
# First version. # # authorize or endorse this project. #
# Based on v0.0.0 21-08-2022 of Western Star 6900 TwinSteer by Nico71 #
################################################################################ ################################################################################
from pybricks.pupdevices import Motor, Remote from pybricks.pupdevices import Motor, Remote
@@ -37,12 +34,6 @@ remote = Remote()
# Initialize the hub. # Initialize the hub.
hub = TechnicHub() hub = TechnicHub()
# Read the current settings
old_kp, old_ki, old_kd, _, _ = steering.control.pid()
# Set new values
steering.control.pid(kp=old_kp*4, kd=old_kd*0.4)
# Find the steering endpoint on the left and right. # Find the steering endpoint on the left and right.
# The middle is in between. # The middle is in between.
left_end = steering.run_until_stalled(-200, then=Stop.HOLD) left_end = steering.run_until_stalled(-200, then=Stop.HOLD)
@@ -81,13 +72,20 @@ while True:
else: else:
steering.track_target(0) steering.track_target(0)
# Check if the left middle button is pressed to change gear
if Button.LEFT in pressed:
if gear_old > 1:
gear -= 1
while Button.LEFT in pressed:
# Button debounce
wait(10)
pressed = remote.buttons.pressed()
# Check if the right middle button is pressed to change gear # Check if the right middle button is pressed to change gear
if Button.CENTER in pressed: if Button.RIGHT in pressed:
if gear_old < gear_total: if gear_old < gear_total:
gear += 1 gear += 1
else: while Button.RIGHT in pressed:
gear = 1
while Button.CENTER in pressed:
# Button debounce # Button debounce
wait(10) wait(10)
pressed = remote.buttons.pressed() pressed = remote.buttons.pressed()