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); diff --git a/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs b/Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs index 3fc151fd..e78083e4 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: @@ -242,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); } } @@ -255,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 @@ -427,7 +431,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 +488,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 +601,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 +650,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;