dora-piper 0.3.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dora-piper might be problematic. Click here for more details.
- dora_piper-0.3.6/PKG-INFO +29 -0
- dora_piper-0.3.6/README.md +9 -0
- dora_piper-0.3.6/dora_piper/__init__.py +11 -0
- dora_piper-0.3.6/dora_piper/main.py +112 -0
- dora_piper-0.3.6/pyproject.toml +21 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: dora-piper
|
|
3
|
+
Version: 0.3.6
|
|
4
|
+
Summary: Dora Node for using Agilex piper
|
|
5
|
+
Author: Haixuan Xavier Tao
|
|
6
|
+
Author-email: tao.xavier@outlook.com
|
|
7
|
+
Requires-Python: >=3.7,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Dist: dora-rs (>=0.3.6,<0.4.0)
|
|
17
|
+
Requires-Dist: piper_sdk (>=0.0.7,<0.0.8)
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Dora Node (Experimental) to communicate with Agilex Piper SDK
|
|
21
|
+
|
|
22
|
+
This node is used to communicate with piper.
|
|
23
|
+
|
|
24
|
+
Make sure to follow both the setup script and installation script from https://github.com/agilexrobotics/piper_sdk
|
|
25
|
+
|
|
26
|
+
# To setup the arm
|
|
27
|
+
|
|
28
|
+
Make sure that the can bus is activated for both arm and leader arms are not connected.
|
|
29
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Dora Node (Experimental) to communicate with Agilex Piper SDK
|
|
2
|
+
|
|
3
|
+
This node is used to communicate with piper.
|
|
4
|
+
|
|
5
|
+
Make sure to follow both the setup script and installation script from https://github.com/agilexrobotics/piper_sdk
|
|
6
|
+
|
|
7
|
+
# To setup the arm
|
|
8
|
+
|
|
9
|
+
Make sure that the can bus is activated for both arm and leader arms are not connected.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
# Define the path to the README file relative to the package directory
|
|
4
|
+
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md")
|
|
5
|
+
|
|
6
|
+
# Read the content of the README file
|
|
7
|
+
try:
|
|
8
|
+
with open(readme_path, "r", encoding="utf-8") as f:
|
|
9
|
+
__doc__ = f.read()
|
|
10
|
+
except FileNotFoundError:
|
|
11
|
+
__doc__ = "README file not found."
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
from piper_sdk import C_PiperInterface
|
|
2
|
+
from dora import Node
|
|
3
|
+
import pyarrow as pa
|
|
4
|
+
import os
|
|
5
|
+
import time
|
|
6
|
+
|
|
7
|
+
TEACH_MODE = (
|
|
8
|
+
os.getenv("TEACH_MODE", "False") == "True"
|
|
9
|
+
or os.getenv("TEACH_MODE", "False") == "true"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def enable_fun(piper: C_PiperInterface):
|
|
14
|
+
"""
|
|
15
|
+
使能机械臂并检测使能状态,尝试5s,如果使能超时则退出程序
|
|
16
|
+
"""
|
|
17
|
+
enable_flag = False
|
|
18
|
+
# 设置超时时间(秒)
|
|
19
|
+
timeout = 5
|
|
20
|
+
# 记录进入循环前的时间
|
|
21
|
+
start_time = time.time()
|
|
22
|
+
elapsed_time_flag = False
|
|
23
|
+
while not (enable_flag):
|
|
24
|
+
elapsed_time = time.time() - start_time
|
|
25
|
+
print("--------------------")
|
|
26
|
+
enable_flag = (
|
|
27
|
+
piper.GetArmLowSpdInfoMsgs().motor_1.foc_status.driver_enable_status
|
|
28
|
+
and piper.GetArmLowSpdInfoMsgs().motor_2.foc_status.driver_enable_status
|
|
29
|
+
and piper.GetArmLowSpdInfoMsgs().motor_3.foc_status.driver_enable_status
|
|
30
|
+
and piper.GetArmLowSpdInfoMsgs().motor_4.foc_status.driver_enable_status
|
|
31
|
+
and piper.GetArmLowSpdInfoMsgs().motor_5.foc_status.driver_enable_status
|
|
32
|
+
and piper.GetArmLowSpdInfoMsgs().motor_6.foc_status.driver_enable_status
|
|
33
|
+
)
|
|
34
|
+
print("使能状态:", enable_flag)
|
|
35
|
+
piper.EnableArm(7)
|
|
36
|
+
piper.GripperCtrl(0, 1000, 0x01, 0)
|
|
37
|
+
print("--------------------")
|
|
38
|
+
# 检查是否超过超时时间
|
|
39
|
+
if elapsed_time > timeout:
|
|
40
|
+
print("超时....")
|
|
41
|
+
elapsed_time_flag = True
|
|
42
|
+
enable_flag = True
|
|
43
|
+
break
|
|
44
|
+
time.sleep(1)
|
|
45
|
+
if elapsed_time_flag:
|
|
46
|
+
print("程序自动使能超时,退出程序")
|
|
47
|
+
print("If you have this issue, you should probably restart your computer")
|
|
48
|
+
exit(0)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def main():
|
|
52
|
+
elapsed_time = time.time()
|
|
53
|
+
CAN_BUS = os.getenv("CAN_BUS", "")
|
|
54
|
+
piper = C_PiperInterface(CAN_BUS)
|
|
55
|
+
piper.ConnectPort()
|
|
56
|
+
|
|
57
|
+
if TEACH_MODE is False:
|
|
58
|
+
# piper.MotionCtrl_3(0, 0, 0, 0x00)#位置速度模式
|
|
59
|
+
piper.EnableArm(7)
|
|
60
|
+
enable_fun(piper=piper)
|
|
61
|
+
piper.GripperCtrl(0, 1000, 0x01, 0)
|
|
62
|
+
factor = 57324.840764 # 1000*180/3.14
|
|
63
|
+
time.sleep(2)
|
|
64
|
+
node = Node()
|
|
65
|
+
|
|
66
|
+
for event in node:
|
|
67
|
+
if event["type"] == "INPUT":
|
|
68
|
+
if event["id"] != "action":
|
|
69
|
+
joint = piper.GetArmJointMsgs()
|
|
70
|
+
gripper = piper.GetArmGripperMsgs()
|
|
71
|
+
|
|
72
|
+
joint_value = []
|
|
73
|
+
joint_value += [joint.joint_state.joint_1.real / factor]
|
|
74
|
+
joint_value += [joint.joint_state.joint_2.real / factor]
|
|
75
|
+
joint_value += [joint.joint_state.joint_3.real / factor]
|
|
76
|
+
joint_value += [joint.joint_state.joint_4.real / factor]
|
|
77
|
+
joint_value += [joint.joint_state.joint_5.real / factor]
|
|
78
|
+
joint_value += [joint.joint_state.joint_6.real / factor]
|
|
79
|
+
joint_value += [gripper.gripper_state.grippers_angle / 1000 / 1000 / 4]
|
|
80
|
+
|
|
81
|
+
node.send_output("jointstate", pa.array(joint_value, type=pa.float32()))
|
|
82
|
+
else:
|
|
83
|
+
|
|
84
|
+
# Do not push to many commands to fast. Limiting it to 20Hz
|
|
85
|
+
# This is due to writing on a moving arm might fail the can bus.
|
|
86
|
+
if time.time() - elapsed_time > 0.05:
|
|
87
|
+
elapsed_time = time.time()
|
|
88
|
+
else:
|
|
89
|
+
continue
|
|
90
|
+
|
|
91
|
+
position = event["value"].to_numpy()
|
|
92
|
+
joint_0 = round(position[0] * factor)
|
|
93
|
+
joint_1 = round(position[1] * factor)
|
|
94
|
+
joint_2 = round(position[2] * factor)
|
|
95
|
+
joint_3 = round(position[3] * factor)
|
|
96
|
+
joint_4 = round(position[4] * factor)
|
|
97
|
+
joint_5 = round(position[5] * factor)
|
|
98
|
+
joint_6 = round(position[6] * 1000 * 1000 * 12)
|
|
99
|
+
|
|
100
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
101
|
+
piper.JointCtrl(joint_0, joint_1, joint_2, joint_3, joint_4, joint_5)
|
|
102
|
+
piper.GripperCtrl(abs(joint_6), 1000, 0x01, 0)
|
|
103
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
104
|
+
elif event["type"] == "STOP":
|
|
105
|
+
|
|
106
|
+
# Waiting for the arm to stop moving before stopping the node
|
|
107
|
+
time.sleep(5)
|
|
108
|
+
break
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if __name__ == "__main__":
|
|
112
|
+
main()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "dora-piper"
|
|
3
|
+
version = "0.3.6"
|
|
4
|
+
authors = ["Haixuan Xavier Tao <tao.xavier@outlook.com>"]
|
|
5
|
+
description = "Dora Node for using Agilex piper"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
|
|
8
|
+
packages = [{ include = "dora_piper" }]
|
|
9
|
+
|
|
10
|
+
[tool.poetry.dependencies]
|
|
11
|
+
dora-rs = "^0.3.6"
|
|
12
|
+
python = "^3.7"
|
|
13
|
+
piper_sdk = "^0.0.7"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
[tool.poetry.scripts]
|
|
17
|
+
dora-piper = "dora_piper.main:main"
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["poetry-core>=1.8.0"]
|
|
21
|
+
build-backend = "poetry.core.masonry.api"
|