Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch new scale convert #340

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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