From 58ecd61538d5490508749d1c039ab4792455b426 Mon Sep 17 00:00:00 2001 From: Gold87 <91761103+Gold872@users.noreply.github.com> Date: Sat, 31 May 2025 21:54:51 -0400 Subject: [PATCH] Improve realsense autonomy interference logic --- lib/src/isolates/realsense.dart | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/src/isolates/realsense.dart b/lib/src/isolates/realsense.dart index 6fe196b..89e4b5b 100644 --- a/lib/src/isolates/realsense.dart +++ b/lib/src/isolates/realsense.dart @@ -10,10 +10,18 @@ import "package:video/utils.dart"; import "package:video/video.dart"; extension on CameraDetails { - bool get interferesWithAutonomy => hasResolutionHeight() - || hasResolutionWidth() - || hasFps() - || hasStatus(); + bool interferesWithAutonomy(CameraDetails current) { + if (hasResolutionWidth() && resolutionWidth != current.resolutionWidth) { + return true; + } + if (hasResolutionHeight() && resolutionHeight != current.resolutionHeight) { + return true; + } + if (hasFps() && fps != current.fps) { + return true; + } + return false; + } } /// An isolate to read RGB, depth, and colorized frames from the RealSense. @@ -33,7 +41,7 @@ class RealSenseIsolate extends CameraIsolate { void onData(VideoCommand data) { if (data.details.status == CameraStatus.CAMERA_DISABLED) { stop(); - } else if (data.details.interferesWithAutonomy) { + } else if (data.details.interferesWithAutonomy(details)) { sendLog(LogLevel.error, "That would break autonomy"); } else { super.onData(data);