Update
This commit is contained in:
parent
8a4d596090
commit
3e343a5c68
1 changed files with 7 additions and 6 deletions
13
rally.py
13
rally.py
|
|
@ -24,8 +24,8 @@ DECAY_MODE = motor.SLOW_DECAY
|
||||||
UPDATE_RATE = 100 # Hz
|
UPDATE_RATE = 100 # Hz
|
||||||
SLEEP_TIME = 1 / UPDATE_RATE
|
SLEEP_TIME = 1 / UPDATE_RATE
|
||||||
BASE_THROTTLE = 0.9 # Base throttle for both motors
|
BASE_THROTTLE = 0.9 # Base throttle for both motors
|
||||||
Kp_sync = 0.05 # Proportional gain for sync correction
|
Kp_sync = 0.08 # Proportional gain for sync correction
|
||||||
Kd_sync = 0.001
|
Kd_sync = 0.008
|
||||||
prev_error = 0
|
prev_error = 0
|
||||||
|
|
||||||
# Create a digitalinout object for the user switch
|
# Create a digitalinout object for the user switch
|
||||||
|
|
@ -93,11 +93,12 @@ while True:
|
||||||
|
|
||||||
if avg >= target_dist:
|
if avg >= target_dist:
|
||||||
print("Target reached!!!")
|
print("Target reached!!!")
|
||||||
mot_left.throttle = left_throttle
|
mot_left.throttle = 0
|
||||||
mot_right.throttle = right_throttle
|
mot_right.throttle = 0
|
||||||
break
|
break
|
||||||
|
|
||||||
mot_right.throttle = 1
|
mot_right.throttle = - right_throttle
|
||||||
mot_left.throttle = - 1
|
mot_left.throttle = - left_throttle
|
||||||
|
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
print("Finished!!!")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue