From 10bcccf6d4b5f32f8fc8a34bc0bb431ab69c29d1 Mon Sep 17 00:00:00 2001 From: Kenneth Yang Date: Thu, 15 Feb 2024 17:06:40 -0800 Subject: [PATCH 1/3] State issue when stopped --- .../UI/EphysCopilot/DrivePanelHandler.cs | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs b/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs index 3fc151fd..edf22ab7 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs @@ -21,7 +21,7 @@ private enum DriveState DrivingToNearTarget, AtNearTarget, ExitingToNearTarget, - DriveToPastTarget, + DrivingToPastTarget, AtPastTarget, ReturningToTarget, AtTarget @@ -84,15 +84,23 @@ public void DriveIncrement() State = DriveState.DrivingToNearTarget; break; case DriveState.AtNearTarget: - State = DriveState.DriveToPastTarget; + State = DriveState.DrivingToPastTarget; break; case DriveState.AtPastTarget: State = DriveState.ReturningToTarget; break; + // Driving transition case: Switch to driving transition state + case DriveState.ExitingToDura: + State = DriveState.DrivingToNearTarget; + break; + case DriveState.ExitingToNearTarget: + State = DriveState.DrivingToPastTarget; + break; + // Driving in progress: maintain state case DriveState.DrivingToNearTarget: - case DriveState.DriveToPastTarget: + case DriveState.DrivingToPastTarget: case DriveState.ReturningToTarget: break; @@ -101,8 +109,6 @@ public void DriveIncrement() case DriveState.ExitingToOutside: case DriveState.AtExitMargin: case DriveState.ExitingToMargin: - case DriveState.ExitingToDura: - case DriveState.ExitingToNearTarget: case DriveState.AtTarget: default: Debug.LogError("Cannot drive down from state: " + State); @@ -134,7 +140,7 @@ public void ExitIncrement() State = DriveState.ExitingToDura; break; case DriveState.ReturningToTarget: - case DriveState.DriveToPastTarget: + case DriveState.DrivingToPastTarget: State = DriveState.ExitingToNearTarget; break; @@ -173,7 +179,7 @@ public void CompleteMovement() case DriveState.ExitingToNearTarget: State = DriveState.AtNearTarget; break; - case DriveState.DriveToPastTarget: + case DriveState.DrivingToPastTarget: State = DriveState.AtPastTarget; break; case DriveState.ReturningToTarget: @@ -427,7 +433,7 @@ public void Drive() // Already closer than near target depth, so continue CompleteAndAdvance(); break; - case DriveState.DriveToPastTarget: + case DriveState.DrivingToPastTarget: // Update status text _statusText.text = "Driving to " + _drivePastTargetDistance * 1000f + " µm past target..."; @@ -484,7 +490,7 @@ public void Drive() case DriveState.AtPastTarget: case DriveState.AtTarget: default: - Debug.LogError("Invalid Drive state for driving: "+_driveStateManager.State); + Debug.LogError("Invalid Drive state for driving: " + _driveStateManager.State); return; } }, Debug.LogError); @@ -597,7 +603,7 @@ public void Exit() case DriveState.AtDura: case DriveState.DrivingToNearTarget: case DriveState.AtNearTarget: - case DriveState.DriveToPastTarget: + case DriveState.DrivingToPastTarget: case DriveState.AtPastTarget: case DriveState.ReturningToTarget: case DriveState.AtTarget: @@ -646,23 +652,23 @@ public void Stop() _exitButton.SetActive(true); _stopButton.SetActive(false); - // Disable drive button if exiting or at Dura and above, otherwise enable. + // Disable drive button if at Dura and above, otherwise enable. switch (_driveStateManager.State) { case DriveState.AtDura: case DriveState.ExitingToMargin: case DriveState.AtExitMargin: case DriveState.ExitingToOutside: - case DriveState.ExitingToDura: - case DriveState.ExitingToNearTarget: case DriveState.Outside: _driveButton.interactable = false; break; case DriveState.DrivingToNearTarget: case DriveState.AtNearTarget: - case DriveState.DriveToPastTarget: + case DriveState.DrivingToPastTarget: case DriveState.AtPastTarget: case DriveState.ReturningToTarget: + case DriveState.ExitingToDura: + case DriveState.ExitingToNearTarget: case DriveState.AtTarget: _driveButton.interactable = true; break; From c4def58d0355fef7c4046c505046a65a95d59c70 Mon Sep 17 00:00:00 2001 From: Kenneth Yang Date: Fri, 16 Feb 2024 14:04:10 -0800 Subject: [PATCH 2/3] Updated deprecated function --- .../Scripts/Pinpoint/Probes/ManipulatorBehaviorController.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Pinpoint/Probes/ManipulatorBehaviorController.cs b/Assets/Scripts/Pinpoint/Probes/ManipulatorBehaviorController.cs index 03d67a44..49123910 100644 --- a/Assets/Scripts/Pinpoint/Probes/ManipulatorBehaviorController.cs +++ b/Assets/Scripts/Pinpoint/Probes/ManipulatorBehaviorController.cs @@ -443,9 +443,8 @@ private void EchoPosition(Vector4 pos) CoordinateSpace.Space2World(manipulatorSpacePosition); // Set probe position (change axes to match probe) - var transformedApmldv = - _probeController.Insertion.World2T_Vector(zeroCoordinateAdjustedWorldPosition); - + var transformedApmldv = BrainAtlasManager.World2T_Vector(zeroCoordinateAdjustedWorldPosition); + // Split between 3 and 4 axis assignments if (CoordinateTransform.Prefix == "3lhm") _probeController.SetProbePosition(transformedApmldv); From e51cdec0fcb4e0ef4eee9931a6102bdef61d04c6 Mon Sep 17 00:00:00 2001 From: Kenneth Yang Date: Fri, 16 Feb 2024 15:06:16 -0800 Subject: [PATCH 3/3] More deprecated function --- Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs b/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs index edf22ab7..e78083e4 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs @@ -248,8 +248,6 @@ private float _targetDriveDistance // Converting worldT back to APMLDV (position transformed) targetInsertion.APMLDV = targetInsertion.World2T(offsetAdjustedTargetPositionWorldT); - print("Target distance: " + Vector3.Distance(targetInsertion.APMLDV, _duraAPMLDV)); - return Vector3.Distance(targetInsertion.APMLDV, _duraAPMLDV); } } @@ -261,7 +259,7 @@ private Vector4 _outsidePosition { // Create outside position APMLDV var targetAPMLDV = _duraAPMLDV; - targetAPMLDV.z = ProbeManager.ProbeController.Insertion + targetAPMLDV.z = BrainAtlasManager .World2T_Vector(InsertionSelectionPanelHandler.PRE_DEPTH_DRIVE_DV_OFFSET).z; // Convert to manipulator position