Skip to content

Commit

Permalink
Patch new scale convert (#340)
Browse files Browse the repository at this point in the history
* Update conversion to Vector4

* Ignore W axis in move command
  • Loading branch information
kjy5 authored Apr 12, 2024
1 parent 598b2fb commit 51a77f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/ephys_link/platforms/new_scale_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,30 @@ def _set_can_write(self, request: CanWriteRequest) -> BooleanStateResponse:
com.dprint(f"[SUCCESS]\t Set can_write state for manipulator {request.manipulator_id}\n")
return BooleanStateResponse(state=request.can_write)

def _platform_space_to_unified_space(self, platform_position: list[float]) -> list[float]:
def _platform_space_to_unified_space(self, platform_position: Vector4) -> Vector4:
# unified <- platform
# +x <- -x
# +y <- +z
# +z <- +y
# +d <- -d

return [
self.dimensions[0] - platform_position[0],
platform_position[2],
platform_position[1],
self.dimensions[2] - platform_position[3],
]
return Vector4(
x=self.dimensions.x - platform_position.x,
y=platform_position.z,
z=platform_position.y,
w=self.dimensions.z - platform_position.w,
)

def _unified_space_to_platform_space(self, unified_position: list[float]) -> list[float]:
def _unified_space_to_platform_space(self, unified_position: Vector4) -> Vector4:
# platform <- unified
# +x <- -x
# +y <- +z
# +z <- +y
# +d <- -d

return [
self.dimensions[0] - unified_position[0],
unified_position[2],
unified_position[1],
self.dimensions[2] - unified_position[3],
]
return Vector4(
x=self.dimensions.x - unified_position.x,
y=unified_position.z,
z=unified_position.y,
w=self.dimensions.z - unified_position.w,
)
2 changes: 1 addition & 1 deletion src/ephys_link/platforms/new_scale_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async def goto_pos(self, request: GotoPositionRequest) -> PositionalResponse:

# Return error if movement did not reach target.
if not all(
abs(axis) < self._movement_tolerance for axis in vector4_to_array(final_position - request.position)
abs(axis) < self._movement_tolerance for axis in vector4_to_array(final_position - request.position)[:3]
):
com.dprint(f"[ERROR]\t\t Manipulator {self._id} did not reach target position.")
com.dprint(f"\t\t\t Expected: {request.position}, Got: {final_position}")
Expand Down

0 comments on commit 51a77f1

Please sign in to comment.