Skip to content

Commit afbbf85

Browse files
committed
WIP: Large addition of preciseflex backend api and robot_testing_script
1 parent 469b71a commit afbbf85

File tree

7 files changed

+6117
-261
lines changed

7 files changed

+6117
-261
lines changed

pylabrobot/arms/backend.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ async def get_position(self) -> tuple[float, float, float]:
1616
"""Get the current position of the arm in 3D space."""
1717
...
1818

19-
@abstractmethod
20-
async def set_speed(self, speed: float):
21-
"""Set the speed of the arm's movement."""
22-
...
23-
24-
@abstractmethod
25-
async def get_speed(self) -> float:
26-
"""Get the current speed of the arm's movement."""
27-
...
19+
# @abstractmethod
20+
# async def set_speed(self, speed: float):
21+
# """Set the speed of the arm's movement."""
22+
# ...
23+
24+
# @abstractmethod
25+
# async def get_speed(self) -> float:
26+
# """Get the current speed of the arm's movement."""
27+
# ...
2828

2929
@abstractmethod
3030
async def open_gripper(self):
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
from pylabrobot.arms.backend import ArmBackend
2+
from pylabrobot.arms.precise_flex.preciseflex_api import PreciseFlexBackendApi
3+
4+
5+
class PreciseFlexBackend(ArmBackend):
6+
"""UNTESTED - Backend for the PreciseFlex robotic arm"""
7+
def __init__(self, host: str, port: int = 10100, timeout=20) -> None:
8+
super().__init__()
9+
self.api = PreciseFlexBackendApi(host=host, port=port, timeout=timeout)
10+
11+
async def setup(self):
12+
"""Initialize the PreciseFlex backend."""
13+
await self.api.setup()
14+
await self.set_pc_mode()
15+
await self.power_on_robot()
16+
await self.attach()
17+
18+
async def stop(self):
19+
"""Stop the PreciseFlex backend."""
20+
await self.detach()
21+
await self.power_off_robot()
22+
await self.exit()
23+
await self.api.stop()
24+
25+
async def get_position(self):
26+
"""Get the current position of the robot."""
27+
return await self.api.where_c()
28+
29+
async def attach(self):
30+
"""Attach the robot."""
31+
await self.api.attach(1)
32+
33+
async def detach(self):
34+
"""Detach the robot."""
35+
await self.api.attach(0)
36+
37+
async def home(self):
38+
"""Homes robot."""
39+
await self.api.home()
40+
41+
async def home_all(self):
42+
"""Homes all robots."""
43+
await self.api.home_all()
44+
45+
async def power_on_robot(self):
46+
"""Power on the robot."""
47+
await self.api.set_power(True, self.api.timeout)
48+
49+
async def power_off_robot(self):
50+
"""Power off the robot."""
51+
await self.api.set_power(False)
52+
53+
async def set_pc_mode(self):
54+
"""Set the controller to PC mode."""
55+
await self.api.set_mode(0)
56+
57+
async def set_verbose_mode(self):
58+
"""Set the controller to verbose mode."""
59+
await self.api.set_mode(1)
60+
61+
async def select_robot(self, robot_id: int) -> None:
62+
"""Select the specified robot."""
63+
await self.api.select_robot(robot_id)
64+
65+
async def version(self) -> str:
66+
"""Get the robot's version."""
67+
return await self.api.get_version()
68+
69+
async def open_gripper(self):
70+
"""Open the gripper."""
71+
await self.api.open_gripper()
72+
73+
async def close_gripper(self):
74+
"""Close the gripper."""
75+
await self.api.close_gripper()
76+
77+
async def exit(self):
78+
"""Exit the PreciseFlex backend."""
79+
await self.api.exit()
80+
81+
82+
if __name__ == "__main__":
83+
84+
async def main():
85+
arm = PreciseFlexBackend("192.168.0.1")
86+
await arm.setup()
87+
position = await arm.get_position()
88+
print(position)
89+
await arm.open_gripper()
90+
vals = await arm.get_motion_profile_values(1)
91+
print(vals)
92+
93+
asyncio.run(main())

pylabrobot/arms/precise_flex/error_codes.py

Lines changed: 1945 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)