@@ -167,20 +167,14 @@ private void UpdateSpaceAndTransform()
167167 CoordinateSpace = new ManipulatorSpace ( Dimensions ) ;
168168 CoordinateTransform = NumAxes switch
169169 {
170- 4
171- => IsRightHanded
172- ? new FourAxisRightHandedManipulatorTransform (
173- _probeController . Insertion . Yaw
174- )
175- : new FourAxisLeftHandedManipulatorTransform (
176- _probeController . Insertion . Yaw
177- ) ,
178- 3
179- => new ThreeAxisLeftHandedTransform (
180- _probeController . Insertion . Yaw ,
181- _probeController . Insertion . Pitch
182- ) ,
183- _ => CoordinateTransform
170+ 4 => IsRightHanded
171+ ? new FourAxisRightHandedManipulatorTransform ( _probeController . Insertion . Yaw )
172+ : new FourAxisLeftHandedManipulatorTransform ( _probeController . Insertion . Yaw ) ,
173+ 3 => new ThreeAxisLeftHandedTransform (
174+ _probeController . Insertion . Yaw ,
175+ _probeController . Insertion . Pitch
176+ ) ,
177+ _ => CoordinateTransform ,
184178 } ;
185179 }
186180
@@ -269,7 +263,7 @@ public void IncrementBrainSurfaceOffset(float increment)
269263 }
270264
271265 /// <summary>
272- /// Move manipulator by a given delta in world space
266+ /// Move manipulator by a given delta in world space at the automatic movement speed.
273267 /// </summary>
274268 /// <param name="worldSpaceDelta">Delta (X, Y, Z, D) to move by in world space coordinates</param>
275269 /// <returns>True on successful movement, false otherwise.</returns>
@@ -278,7 +272,7 @@ public async Awaitable<bool> MoveByWorldSpaceDelta(Vector4 worldSpaceDelta)
278272 // Convert to manipulator axes (world -> space -> transform).
279273 var manipulatorSpaceDelta = CoordinateSpace . World2Space_Vector ( worldSpaceDelta ) ;
280274 var manipulatorTransformDelta = CoordinateTransform . U2T ( manipulatorSpaceDelta ) ;
281- var manipulatorSpaceDepth = worldSpaceDelta . w ;
275+ var manipulatorSpaceDepthDelta = worldSpaceDelta . w ;
282276
283277 // Get manipulator position.
284278 var positionResponse = await CommunicationManager . Instance . GetPosition ( ManipulatorID ) ;
@@ -291,7 +285,8 @@ public async Awaitable<bool> MoveByWorldSpaceDelta(Vector4 worldSpaceDelta)
291285 + new Vector4 (
292286 manipulatorTransformDelta . x ,
293287 manipulatorTransformDelta . y ,
294- manipulatorTransformDelta . z
288+ manipulatorTransformDelta . z ,
289+ manipulatorSpaceDepthDelta
295290 ) ;
296291
297292 // Move manipulator.
@@ -300,9 +295,13 @@ public async Awaitable<bool> MoveByWorldSpaceDelta(Vector4 worldSpaceDelta)
300295 ) ;
301296 if ( CommunicationManager . HasError ( setPositionResponse . Error ) )
302297 return false ;
298+
299+ // 3-axis manipulators need to set depth separately if requested.
303300
304- // Process depth movement.
305- var targetDepth = positionResponse . Position . w + manipulatorSpaceDepth ;
301+ if ( NumAxes != 3 ) return true ;
302+
303+ // Process depth movement after regular movement.
304+ var targetDepth = setPositionResponse . Position . w + manipulatorSpaceDepthDelta ;
306305
307306 // Move manipulator.
308307 var setDepthResponse = await CommunicationManager . Instance . SetDepth (
@@ -312,7 +311,6 @@ public async Awaitable<bool> MoveByWorldSpaceDelta(Vector4 worldSpaceDelta)
312311 return ! CommunicationManager . HasError ( setDepthResponse . Error ) ;
313312 }
314313
315-
316314 #endregion
317315
318316 #region Private Methods
@@ -418,7 +416,7 @@ private async Awaitable UpdateProbePositionFromManipulator()
418416 _probeController . Insertion . Roll . ToString ( CultureInfo . InvariantCulture ) ,
419417 tipPos . x . ToString ( CultureInfo . InvariantCulture ) ,
420418 tipPos . y . ToString ( CultureInfo . InvariantCulture ) ,
421- tipPos . z . ToString ( CultureInfo . InvariantCulture )
419+ tipPos . z . ToString ( CultureInfo . InvariantCulture ) ,
422420 }
423421 ) ;
424422
0 commit comments