Skip to content

Commit

Permalink
all locations working, added timeout to move_joints
Browse files Browse the repository at this point in the history
  • Loading branch information
caseystone committed Jun 18, 2024
1 parent 2b8dd25 commit 396471d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
29 changes: 16 additions & 13 deletions src/platecrane_driver/platecrane_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from pathlib import Path
import time

from platecrane_driver.serial_port import SerialPort # use when running through WEI REST clients
from platecrane_driver.resource_defs import locations, plate_definitions
from platecrane_driver.resource_types import PlateResource
# from platecrane_driver.serial_port import SerialPort # use when running through WEI REST clients
# from platecrane_driver.resource_defs import locations, plate_definitions
# from platecrane_driver.resource_types import PlateResource

# from serial_port import SerialPort # use when running through the driver
# from resource_defs import locations, plate_definitions
# from resource_types import PlateResource
from serial_port import SerialPort # use when running through the driver
from resource_defs import locations, plate_definitions
from resource_types import PlateResource


# TODOs:
Expand Down Expand Up @@ -173,11 +173,11 @@ def get_position(self) -> list:
"""
Requests and stores plate_crane position.
Coordinates:
Z: Vertical axis
R: Base turning axis
Y: Extension axis
Z: Vertical axis
P: Gripper turning axis
Y: Extension axis
:param [ParamName]: [ParamDescription], defaults to [DefaultParamVal]
:type [ParamName]: [ParamType](, optional)
...
Expand All @@ -193,12 +193,15 @@ def get_position(self) -> list:

try:
# collect coordinates of current position
current_position = list(self.__serial_port.send_command(command).split(" "))
# time.sleep(2)
current_position = list(self.__serial_port.send_command(command,1).split(" "))
print(current_position)
current_position = [eval(x.strip(",")) for x in current_position]
print(current_position)
except Exception:
print("Overlapping serial responses detected. Waiting 5 seconds to resend latest command")
time.sleep(5)
current_position = list(self.__serial_port.send_command(command).split(" "))
current_position = list(self.__serial_port.send_command(command,1).split(" "))
current_position = [eval(x.strip(",")) for x in current_position]

return current_position
Expand Down Expand Up @@ -342,7 +345,7 @@ def move_joint_angles(self, R: int, Z: int, P: int, Y: int) -> None:
command = "MOVE TEMP\r\n"

try:
self.__serial_port.send_command(command)
self.__serial_port.send_command(command, 2)

except Exception as err:
print(err)
Expand Down Expand Up @@ -654,7 +657,7 @@ def pick_plate_direct(

else: # if source_type == nest:
self.gripper_open()

self.move_joint_angles(
R=locations[source].joint_angles[0],
Z=locations[source].joint_angles[1] + grip_height_in_steps,
Expand Down
26 changes: 13 additions & 13 deletions src/platecrane_driver/resource_defs.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#from resource_types import Location, PlateResource
from platecrane_driver.resource_types import Location, PlateResource # through WEI
from resource_types import Location, PlateResource
# from platecrane_driver.resource_types import Location, PlateResource # through WEI

# Locations accessible by the PlateCrane EX
locations = {
"Safe": Location(name="Safe", joint_angles=[182220, 2500, 460, -308], location_type="nest", safe_approach_height=0),
"Stack1": Location(name="Stack1", joint_angles=[164672, -32623, 472, 5389], location_type="stack", safe_approach_height=0),
"Stack2": Location(name="Stack2", joint_angles=[182220, -32623, 460, 5420], location_type="stack", safe_approach_height=0),
"Stack3": Location(name="Stack3", joint_angles=[199708, -32623, 514, 5484], location_type="stack", safe_approach_height=0),
"Stack4": Location(name="Stack4", joint_angles=[217401, -32623, 546, 5473], location_type="stack", safe_approach_height=0),
"Stack5": Location(name="Stack5", joint_angles=[235104, -32623, 532, 5453], location_type="stack", safe_approach_height=0),
"LidNest1": Location(name="LidNest1", joint_angles=[168355, -31500, 484, -306], location_type="nest", safe_approach_height=0),
"LidNest2": Location(name="LidNest2", joint_angles=[199805, -31500, 484, -306], location_type="nest", safe_approach_height=0),
"LidNest3": Location(name="LidNest3", joint_angles=[231449, -31500, 484, -306], location_type="nest", safe_approach_height=0),
"Stack1": Location(name="Stack1", joint_angles=[164672, -32703, 472, 5389], location_type="stack", safe_approach_height=0),
"Stack2": Location(name="Stack2", joint_angles=[182220, -32703, 460, 5420], location_type="stack", safe_approach_height=0),
"Stack3": Location(name="Stack3", joint_angles=[199708, -32703, 514, 5484], location_type="stack", safe_approach_height=0),
"Stack4": Location(name="Stack4", joint_angles=[217401, -32703, 546, 5473], location_type="stack", safe_approach_height=0),
"Stack5": Location(name="Stack5", joint_angles=[235104, -32703, 532, 5453], location_type="stack", safe_approach_height=0),
"LidNest1": Location(name="LidNest1", joint_angles=[168355, -31800, 484, -306], location_type="nest", safe_approach_height=0),
"LidNest2": Location(name="LidNest2", joint_angles=[199805, -31800, 484, -306], location_type="nest", safe_approach_height=0),
"LidNest3": Location(name="LidNest3", joint_angles=[231449, -31800, 484, -306], location_type="nest", safe_approach_height=0),
"Solo.Position1": Location(name="Solo.Position1", joint_angles=[36703, -27951, -1000, 3630], location_type="nest", safe_approach_height=0),
"Solo.Position2": Location(name="Solo.Position2", joint_angles=[53182, -27951, -413, 834], location_type="nest", safe_approach_height=0),
"Hidex.Nest": Location(name="Hidex.Nest", joint_angles=[102327, -31090, -5830, 2378], location_type="nest", safe_approach_height=-27033),
"Sealer.Nest": Location(name="Sealer.Nest", joint_angles=[117468, 1220, -4748, 4550], location_type="nest", safe_approach_height=0),
"Peeler.Nest": Location(name="Peeler.Nest", joint_angles=[292611, -30758, -4469, 4257], location_type="nest", safe_approach_height=0),
"Sealer.Nest": Location(name="Sealer.Nest", joint_angles=[117305, 920, -4766, 4550], location_type="nest", safe_approach_height=0),
"Peeler.Nest": Location(name="Peeler.Nest", joint_angles=[292635, -31058, -4521, 4235], location_type="nest", safe_approach_height=0),
"Liconic.Nest": Location(name="Liconic.Nest", joint_angles=[265603, -19900, -5413, 4953], location_type="nest", safe_approach_height=0),
}

#19831
# Dimensions of labware used on the BIO_Workcells
plate_definitions = {
"flat_bottom_96well": PlateResource(plate_height = 14, grip_height=3, plate_height_with_lid=16, lid_height=10, lid_grip_height=4, lid_removal_grip_height=12),
"tip_box_180uL": PlateResource(plate_height = 0, grip_height=0, plate_height_with_lid=0, lid_height=0, lid_grip_height=0, lid_removal_grip_height=0),
"pcr_96well": PlateResource(plate_height = 0, grip_height=0, plate_height_with_lid=0, lid_height=0, lid_grip_height=0, lid_removal_grip_height=0),
}

# R, Z, P, Y

0 comments on commit 396471d

Please sign in to comment.