add KI
This commit is contained in:
@@ -69,9 +69,9 @@ class FlightController:
|
||||
# Remember which side it was on
|
||||
self.last_target_side = 1 if err_x > 0 else -1
|
||||
|
||||
# Rotation (Yaw) - FULL SPEED CAPABLE
|
||||
# Rotation (Yaw) - SMOOTHER
|
||||
if abs(err_x) > Config.FACE_DEADZONE:
|
||||
yv = int(np.clip(Config.YAW_GAIN * err_x, -100, 100))
|
||||
yv = int(np.clip(Config.YAW_GAIN * err_x, -50, 50))
|
||||
|
||||
# Forward/Backward pursuit - EXTREME SPEED
|
||||
alignment_factor = max(0.4, 1.0 - (abs(err_x) / Config.FACE_ROT_ONLY))
|
||||
@@ -85,18 +85,18 @@ class FlightController:
|
||||
elapsed = time.time() - self.lost_time
|
||||
|
||||
if elapsed < 10.0: # Search longer and faster
|
||||
yv = 80 * self.last_target_side
|
||||
self.status = f"LOST TARGET: RAPID SCAN {'RIGHT' if self.last_target_side > 0 else 'LEFT'}"
|
||||
yv = 40 * self.last_target_side
|
||||
self.status = f"LOST TARGET: SCANNING {'RIGHT' if self.last_target_side > 0 else 'LEFT'}"
|
||||
else:
|
||||
self.status = "TARGET LOST: AGGRESSIVE PATROL"
|
||||
yv = 60
|
||||
yv = 30
|
||||
|
||||
elif self.smooth_face is not None:
|
||||
# Face found but not locked
|
||||
(x, y, w, h) = self.smooth_face
|
||||
err_x = (x + w // 2) - (Config.WIDTH // 2)
|
||||
if abs(err_x) > Config.FACE_DEADZONE:
|
||||
yv = int(np.clip(Config.YAW_GAIN * err_x, -80, 80))
|
||||
yv = int(np.clip(Config.YAW_GAIN * err_x, -40, 40))
|
||||
self.status = "AWAITING LOCK"
|
||||
else:
|
||||
# Patrol mode - faster
|
||||
@@ -105,8 +105,8 @@ class FlightController:
|
||||
self.status = "PATROL: DASH"
|
||||
fb = 40
|
||||
else:
|
||||
self.status = "PATROL: FAST SPIN"
|
||||
yv = 60
|
||||
self.status = "PATROL: SCAN"
|
||||
yv = 30
|
||||
|
||||
return self._smooth(lr, fb, ud, yv)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user