dora-piper 0.3.6__py3-none-any.whl → 0.3.8__py3-none-any.whl
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/main.py +76 -30
- {dora_piper-0.3.6.dist-info → dora_piper-0.3.8.dist-info}/METADATA +3 -2
- dora_piper-0.3.8.dist-info/RECORD +6 -0
- dora_piper-0.3.6.dist-info/RECORD +0 -6
- {dora_piper-0.3.6.dist-info → dora_piper-0.3.8.dist-info}/WHEEL +0 -0
- {dora_piper-0.3.6.dist-info → dora_piper-0.3.8.dist-info}/entry_points.txt +0 -0
dora_piper/main.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
from piper_sdk import C_PiperInterface
|
|
2
2
|
from dora import Node
|
|
3
3
|
import pyarrow as pa
|
|
4
|
+
import numpy as np
|
|
4
5
|
import os
|
|
5
6
|
import time
|
|
6
7
|
|
|
7
|
-
TEACH_MODE = (
|
|
8
|
-
os.getenv("TEACH_MODE", "False") == "True"
|
|
9
|
-
or os.getenv("TEACH_MODE", "False") == "true"
|
|
10
|
-
)
|
|
8
|
+
TEACH_MODE = os.getenv("TEACH_MODE", "False") in ["True", "true"]
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
def enable_fun(piper: C_PiperInterface):
|
|
@@ -32,8 +30,6 @@ def enable_fun(piper: C_PiperInterface):
|
|
|
32
30
|
and piper.GetArmLowSpdInfoMsgs().motor_6.foc_status.driver_enable_status
|
|
33
31
|
)
|
|
34
32
|
print("使能状态:", enable_flag)
|
|
35
|
-
piper.EnableArm(7)
|
|
36
|
-
piper.GripperCtrl(0, 1000, 0x01, 0)
|
|
37
33
|
print("--------------------")
|
|
38
34
|
# 检查是否超过超时时间
|
|
39
35
|
if elapsed_time > timeout:
|
|
@@ -44,8 +40,7 @@ def enable_fun(piper: C_PiperInterface):
|
|
|
44
40
|
time.sleep(1)
|
|
45
41
|
if elapsed_time_flag:
|
|
46
42
|
print("程序自动使能超时,退出程序")
|
|
47
|
-
|
|
48
|
-
exit(0)
|
|
43
|
+
raise ConnectionError("程序自动使能超时,退出程序")
|
|
49
44
|
|
|
50
45
|
|
|
51
46
|
def main():
|
|
@@ -54,35 +49,25 @@ def main():
|
|
|
54
49
|
piper = C_PiperInterface(CAN_BUS)
|
|
55
50
|
piper.ConnectPort()
|
|
56
51
|
|
|
57
|
-
if TEACH_MODE
|
|
52
|
+
if not TEACH_MODE:
|
|
58
53
|
# piper.MotionCtrl_3(0, 0, 0, 0x00)#位置速度模式
|
|
59
54
|
piper.EnableArm(7)
|
|
60
55
|
enable_fun(piper=piper)
|
|
61
|
-
piper.
|
|
56
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
57
|
+
piper.JointCtrl(0, 0, 0, 0, 0, 0)
|
|
58
|
+
piper.GripperCtrl(abs(0), 1000, 0x01, 0)
|
|
59
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
60
|
+
time.sleep(5)
|
|
61
|
+
|
|
62
62
|
factor = 57324.840764 # 1000*180/3.14
|
|
63
|
-
time.sleep(2)
|
|
64
63
|
node = Node()
|
|
65
64
|
|
|
66
65
|
for event in node:
|
|
67
66
|
if event["type"] == "INPUT":
|
|
68
|
-
if event["id"]
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
67
|
+
if event["id"] == "joint_action":
|
|
68
|
+
if TEACH_MODE:
|
|
69
|
+
continue
|
|
84
70
|
# 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
71
|
if time.time() - elapsed_time > 0.05:
|
|
87
72
|
elapsed_time = time.time()
|
|
88
73
|
else:
|
|
@@ -95,15 +80,76 @@ def main():
|
|
|
95
80
|
joint_3 = round(position[3] * factor)
|
|
96
81
|
joint_4 = round(position[4] * factor)
|
|
97
82
|
joint_5 = round(position[5] * factor)
|
|
98
|
-
joint_6 = round(position[6] * 1000 *
|
|
83
|
+
joint_6 = round(position[6] * 1000 * 100)
|
|
99
84
|
|
|
100
85
|
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
101
86
|
piper.JointCtrl(joint_0, joint_1, joint_2, joint_3, joint_4, joint_5)
|
|
102
87
|
piper.GripperCtrl(abs(joint_6), 1000, 0x01, 0)
|
|
103
88
|
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
89
|
+
|
|
90
|
+
elif event["id"] == "eef_action":
|
|
91
|
+
if TEACH_MODE:
|
|
92
|
+
continue
|
|
93
|
+
# Do not push to many commands to fast. Limiting it to 20Hz
|
|
94
|
+
if time.time() - elapsed_time > 0.05:
|
|
95
|
+
elapsed_time = time.time()
|
|
96
|
+
else:
|
|
97
|
+
continue
|
|
98
|
+
|
|
99
|
+
position = event["value"].to_numpy()
|
|
100
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
101
|
+
piper.EndPoseCtrl(
|
|
102
|
+
position[0] * 1000 * 1000,
|
|
103
|
+
position[1] * 1000 * 1000,
|
|
104
|
+
position[2] * 1000 * 1000,
|
|
105
|
+
position[3] * 1000 / (2 * np.pi) * 360,
|
|
106
|
+
position[4] * 1000 / (2 * np.pi) * 360,
|
|
107
|
+
position[5] * 1000 / (2 * np.pi) * 360,
|
|
108
|
+
)
|
|
109
|
+
piper.GripperCtrl(abs(position[6] * 1000 * 100), 1000, 0x01, 0)
|
|
110
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
111
|
+
|
|
112
|
+
else:
|
|
113
|
+
joint = piper.GetArmJointMsgs()
|
|
114
|
+
|
|
115
|
+
joint_value = []
|
|
116
|
+
joint_value += [joint.joint_state.joint_1.real / factor]
|
|
117
|
+
joint_value += [joint.joint_state.joint_2.real / factor]
|
|
118
|
+
joint_value += [joint.joint_state.joint_3.real / factor]
|
|
119
|
+
joint_value += [joint.joint_state.joint_4.real / factor]
|
|
120
|
+
joint_value += [joint.joint_state.joint_5.real / factor]
|
|
121
|
+
joint_value += [joint.joint_state.joint_6.real / factor]
|
|
122
|
+
|
|
123
|
+
gripper = piper.GetArmGripperMsgs()
|
|
124
|
+
joint_value += [gripper.gripper_state.grippers_angle / 1000 / 100]
|
|
125
|
+
|
|
126
|
+
node.send_output("jointstate", pa.array(joint_value, type=pa.float32()))
|
|
127
|
+
|
|
128
|
+
position = piper.GetArmEndPoseMsgs()
|
|
129
|
+
position_value = []
|
|
130
|
+
position_value += [position.end_pose.X_axis * 0.001 * 0.001]
|
|
131
|
+
position_value += [position.end_pose.Y_axis * 0.001 * 0.001]
|
|
132
|
+
position_value += [position.end_pose.Z_axis * 0.001 * 0.001]
|
|
133
|
+
position_value += [position.end_pose.RX_axis * 0.001 / 360 * 2 * np.pi]
|
|
134
|
+
position_value += [position.end_pose.RY_axis * 0.001 / 360 * 2 * np.pi]
|
|
135
|
+
position_value += [position.end_pose.RZ_axis * 0.001 / 360 * 2 * np.pi]
|
|
136
|
+
|
|
137
|
+
node.send_output("pose", pa.array(position_value, type=pa.float32()))
|
|
138
|
+
node.send_output(
|
|
139
|
+
"gripper",
|
|
140
|
+
pa.array(
|
|
141
|
+
[gripper.gripper_state.grippers_angle / 1000 / 100],
|
|
142
|
+
type=pa.float32(),
|
|
143
|
+
),
|
|
144
|
+
)
|
|
145
|
+
|
|
104
146
|
elif event["type"] == "STOP":
|
|
105
147
|
|
|
106
|
-
|
|
148
|
+
if not TEACH_MODE:
|
|
149
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
150
|
+
piper.JointCtrl(0, 0, 0, 0, 0, 0)
|
|
151
|
+
piper.GripperCtrl(abs(0), 1000, 0x01, 0)
|
|
152
|
+
piper.MotionCtrl_2(0x01, 0x01, 50, 0x00)
|
|
107
153
|
time.sleep(5)
|
|
108
154
|
break
|
|
109
155
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dora-piper
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.8
|
|
4
4
|
Summary: Dora Node for using Agilex piper
|
|
5
5
|
Author: Haixuan Xavier Tao
|
|
6
6
|
Author-email: tao.xavier@outlook.com
|
|
@@ -14,7 +14,8 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
16
|
Requires-Dist: dora-rs (>=0.3.6,<0.4.0)
|
|
17
|
-
Requires-Dist:
|
|
17
|
+
Requires-Dist: numpy (<2.0.0)
|
|
18
|
+
Requires-Dist: piper_sdk (>=0.0.8,<0.0.9)
|
|
18
19
|
Description-Content-Type: text/markdown
|
|
19
20
|
|
|
20
21
|
# Dora Node (Experimental) to communicate with Agilex Piper SDK
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
dora_piper/__init__.py,sha256=Gy4qL4vCeTyA5HR1Yp3ioL4-ClJyW8oi_38CzMuMsBM,358
|
|
2
|
+
dora_piper/main.py,sha256=K_wKIIgVEtPoef2FLiVz5HRCKMJK05F-Y0JdgMoY42M,6294
|
|
3
|
+
dora_piper-0.3.8.dist-info/METADATA,sha256=jgeo4eeMgOd7GqTOe_9gHOLVUSNjPzpoD_MGBBSyy_c,1079
|
|
4
|
+
dora_piper-0.3.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
5
|
+
dora_piper-0.3.8.dist-info/entry_points.txt,sha256=PuWCNzfJelov0oX-TmquNxlsUikVwvAE9hjlQKyC2T8,51
|
|
6
|
+
dora_piper-0.3.8.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
dora_piper/__init__.py,sha256=Gy4qL4vCeTyA5HR1Yp3ioL4-ClJyW8oi_38CzMuMsBM,358
|
|
2
|
-
dora_piper/main.py,sha256=29bsNt0LPScEbnjshekP_gxj2DIZg1cddbCQvs6TfB4,4238
|
|
3
|
-
dora_piper-0.3.6.dist-info/METADATA,sha256=VPnYEZ1R2TQ0oKmIDGJMnq7LC-tJ92WU2BlqAWBc5io,1049
|
|
4
|
-
dora_piper-0.3.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
5
|
-
dora_piper-0.3.6.dist-info/entry_points.txt,sha256=PuWCNzfJelov0oX-TmquNxlsUikVwvAE9hjlQKyC2T8,51
|
|
6
|
-
dora_piper-0.3.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|