Skip to content

Commit 6d86109

Browse files
committed
Add uMp-3 support for jackhammer with auto-detect depth axis
1 parent f461723 commit 6d86109

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/ephys_link/back_end/platform_handler.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,23 @@ async def jackhammer(
270270
# Closed-loop constants
271271
MAX_BACKWARD_UM = 250.0
272272

273+
# Auto-detect axis if -1: uMp-4 uses W (axis 3), uMp-3 uses X (axis 0)
274+
# Auto-detect depth axis if -1
275+
if axis == -1:
276+
axis = self._bindings.get_depth_axis()
277+
278+
# Helper to get depth based on manipulator type
279+
def get_depth(pos) -> float:
280+
"""Get depth value based on axis (mm)."""
281+
if axis == 3:
282+
return pos.w
283+
elif axis == 0:
284+
return pos.x
285+
elif axis == 1:
286+
return pos.y
287+
else:
288+
return pos.z
289+
273290
try:
274291
if closed_loop:
275292
# Get starting position

src/ephys_link/back_end/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async def platform_event_handler(self, event: str, _: str, data: Any) -> str: #
248248
parsed = loads(str(data))
249249
result = await self._platform_handler.jackhammer(
250250
manipulator_id=parsed.get("manipulator_id", parsed.get("ManipulatorId", "")),
251-
axis=parsed.get("axis", parsed.get("Axis", 3)),
251+
axis=parsed.get("axis", parsed.get("Axis", -1)),
252252
iterations=parsed.get("iterations", parsed.get("Iterations", 10)),
253253
phase1_steps=parsed.get("phase1_steps", parsed.get("Phase1Steps", 10)),
254254
phase1_pulses=parsed.get("phase1_pulses", parsed.get("Phase1Pulses", 15)),

src/ephys_link/bindings/ump_binding.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ async def get_shank_count(self, manipulator_id: str) -> NoReturn:
9898
@override
9999
def get_movement_tolerance() -> float:
100100
return 0.001
101+
102+
def get_depth_axis(self) -> int:
103+
"""Get the depth axis index (0 for uMp-3, 3 for uMp-4)."""
104+
return 0 if self._is_ump_3() else 3
101105

102106
@override
103107
async def set_position(self, manipulator_id: str, position: Vector4, speed: float) -> Vector4:

src/ephys_link/utils/base_binding.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ async def stop(self, manipulator_id: str) -> None:
147147
manipulator_id: Manipulator ID.
148148
"""
149149

150+
def get_depth_axis(self) -> int:
151+
"""Get the depth axis index for jackhammer."""
152+
return 3 # Default to W axis
150153

151154
async def jackhammer(
152155
self,

0 commit comments

Comments
 (0)