dora-piper 0.3.6__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/__init__.py ADDED
@@ -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."
dora_piper/main.py ADDED
@@ -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,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,6 @@
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,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.9.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ dora-piper=dora_piper.main:main
3
+