carm 0.1.20251010__py3-none-any.whl → 0.1.20260204__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.
- carm/carm.py +106 -27
- carm/carm_dds.py +3 -3
- carm-0.1.20260204.dist-info/METADATA +49 -0
- carm-0.1.20260204.dist-info/RECORD +9 -0
- {carm-0.1.20251010.dist-info → carm-0.1.20260204.dist-info}/WHEEL +1 -1
- carm-0.1.20251010.dist-info/METADATA +0 -11
- carm-0.1.20251010.dist-info/RECORD +0 -9
- {carm-0.1.20251010.dist-info → carm-0.1.20260204.dist-info}/entry_points.txt +0 -0
- {carm-0.1.20251010.dist-info → carm-0.1.20260204.dist-info}/top_level.txt +0 -0
carm/carm.py
CHANGED
|
@@ -8,12 +8,6 @@ class Carm:
|
|
|
8
8
|
def __init__(self, addr = "ws://100.84.147.120:8090"):
|
|
9
9
|
self.state = None
|
|
10
10
|
self.last_msg = None
|
|
11
|
-
self.ws = websocket.WebSocketApp(
|
|
12
|
-
addr, # 测试用的公开WebSocket服务
|
|
13
|
-
on_open = lambda ws: self.__on_open(ws),
|
|
14
|
-
on_close = lambda ws, code, close_msg: self.__on_close(ws, code, close_msg),
|
|
15
|
-
on_message= lambda ws, msg: self.__on_message(ws, msg),
|
|
16
|
-
)
|
|
17
11
|
|
|
18
12
|
self.ops = {
|
|
19
13
|
"webSendRobotState": lambda msg: self.__cbk_status(msg),
|
|
@@ -21,11 +15,18 @@ class Carm:
|
|
|
21
15
|
"onCarmError": lambda msg: print("Error:", msg)
|
|
22
16
|
}
|
|
23
17
|
self.res_pool = {}
|
|
24
|
-
self.
|
|
25
|
-
|
|
26
|
-
self.reader = threading.Thread(target=self.__recv_loop, daemon=True).start()
|
|
18
|
+
self.task_event = threading.Event()
|
|
27
19
|
self.open_ready = threading.Event()
|
|
28
|
-
|
|
20
|
+
|
|
21
|
+
while not self.open_ready.wait(1):
|
|
22
|
+
self.ws = websocket.WebSocketApp(
|
|
23
|
+
addr, # 测试用的公开WebSocket服务
|
|
24
|
+
on_open = lambda ws: self.__on_open(ws),
|
|
25
|
+
on_close = lambda ws, code, close_msg: self.__on_close(ws, code, close_msg),
|
|
26
|
+
on_message= lambda ws, msg: self.__on_message(ws, msg),
|
|
27
|
+
)
|
|
28
|
+
self.reader = threading.Thread(target=self.__recv_loop, daemon=True).start()
|
|
29
|
+
|
|
29
30
|
self.limit = self.get_limits()["params"]
|
|
30
31
|
|
|
31
32
|
self.set_ready()
|
|
@@ -254,6 +255,33 @@ class Carm:
|
|
|
254
255
|
"""
|
|
255
256
|
return self.state["arm"][0]["reality"]["torque"]
|
|
256
257
|
|
|
258
|
+
@property
|
|
259
|
+
def plan_joint_pos(self):
|
|
260
|
+
"""
|
|
261
|
+
获取当前关节位置.
|
|
262
|
+
Returns:
|
|
263
|
+
list: The joint position of the arm.
|
|
264
|
+
"""
|
|
265
|
+
return self.state["arm"][0]["plan"]["pose"]
|
|
266
|
+
|
|
267
|
+
@property
|
|
268
|
+
def plan_joint_vel(self):
|
|
269
|
+
"""
|
|
270
|
+
获取当前关节速度.
|
|
271
|
+
Returns:
|
|
272
|
+
list: The joint velocity of the arm.
|
|
273
|
+
"""
|
|
274
|
+
return self.state["arm"][0]["plan"]["vel"]
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def plan_joint_tau(self):
|
|
278
|
+
"""
|
|
279
|
+
获取当前关节力矩.
|
|
280
|
+
Returns:
|
|
281
|
+
list: The joint torque of the arm.
|
|
282
|
+
"""
|
|
283
|
+
return self.state["arm"][0]["plan"]["torque"]
|
|
284
|
+
|
|
257
285
|
@property
|
|
258
286
|
def cart_pose(self):
|
|
259
287
|
"""
|
|
@@ -263,6 +291,16 @@ class Carm:
|
|
|
263
291
|
"""
|
|
264
292
|
return self.state["arm"][0]["pose"]
|
|
265
293
|
|
|
294
|
+
|
|
295
|
+
@property
|
|
296
|
+
def plan_cart_pose(self):
|
|
297
|
+
"""
|
|
298
|
+
获取当前规划的笛卡尔位置.
|
|
299
|
+
Returns:
|
|
300
|
+
list: The cartesian position of the arm.
|
|
301
|
+
"""
|
|
302
|
+
return self.forwardK(self.plan_joint_pos)
|
|
303
|
+
|
|
266
304
|
@property
|
|
267
305
|
def gripper_state(self):
|
|
268
306
|
"""
|
|
@@ -279,7 +317,7 @@ class Carm:
|
|
|
279
317
|
joints[i] = self.__clip(v, lower[i], upper[i])
|
|
280
318
|
return joints
|
|
281
319
|
|
|
282
|
-
def track_joint(self, pos, end_effector =
|
|
320
|
+
def track_joint(self, pos, end_effector = None):
|
|
283
321
|
"""
|
|
284
322
|
关节轨迹跟踪.
|
|
285
323
|
Args:
|
|
@@ -295,12 +333,14 @@ class Carm:
|
|
|
295
333
|
"point_type":{"space":0},
|
|
296
334
|
"data":{"way_point": pos}}
|
|
297
335
|
|
|
298
|
-
if end_effector
|
|
299
|
-
req["data"]["
|
|
336
|
+
if not end_effector is None:
|
|
337
|
+
#req["data"]["grp_point"] = end_effector
|
|
338
|
+
tau = (0.1 - end_effector) * 20
|
|
339
|
+
self.set_end_effector(end_effector, tau)
|
|
300
340
|
|
|
301
341
|
return self.request(req)
|
|
302
342
|
|
|
303
|
-
def track_pose(self, pos, end_effector =
|
|
343
|
+
def track_pose(self, pos, end_effector =None):
|
|
304
344
|
"""
|
|
305
345
|
笛卡尔轨迹跟踪.
|
|
306
346
|
Args:
|
|
@@ -315,9 +355,11 @@ class Carm:
|
|
|
315
355
|
"point_type":{"space":1},
|
|
316
356
|
"data":{"way_point": pos}}
|
|
317
357
|
|
|
318
|
-
if end_effector
|
|
319
|
-
req["data"]["
|
|
320
|
-
|
|
358
|
+
if not end_effector is None:
|
|
359
|
+
#req["data"]["grp_point"] = end_effector
|
|
360
|
+
tau = (0.1 - end_effector) * 20
|
|
361
|
+
self.set_end_effector(end_effector, tau)
|
|
362
|
+
|
|
321
363
|
return self.request(req)
|
|
322
364
|
|
|
323
365
|
def move_joint(self, pos, tm=-1, sync=True, user=0, tool=0):
|
|
@@ -402,10 +444,8 @@ class Carm:
|
|
|
402
444
|
return res
|
|
403
445
|
|
|
404
446
|
def __wait_task(self, task_key):
|
|
405
|
-
|
|
406
|
-
self.
|
|
407
|
-
event.wait()
|
|
408
|
-
self.task_pool.pop(task_key)
|
|
447
|
+
self.task_event= threading.Event()
|
|
448
|
+
self.task_event.wait()
|
|
409
449
|
|
|
410
450
|
def move_joint_traj(self, target_traj, gripper_pos = [], stamps = [], is_sync=True):
|
|
411
451
|
if len(stamps) != len(target_traj): # as soon as possible
|
|
@@ -463,6 +503,42 @@ class Carm:
|
|
|
463
503
|
"arm_index":0,
|
|
464
504
|
"data":data})
|
|
465
505
|
|
|
506
|
+
def forwardK(self, joint_pos, user=0, tool=0):
|
|
507
|
+
"""
|
|
508
|
+
正解
|
|
509
|
+
Args:
|
|
510
|
+
joint_pos (list): The joint position to move.
|
|
511
|
+
user (int, optional): The user index.
|
|
512
|
+
tool (int, optional): The tool index.
|
|
513
|
+
Returns:
|
|
514
|
+
dict: The response from the arm.
|
|
515
|
+
"""
|
|
516
|
+
is_list = True
|
|
517
|
+
if not type(joint_pos[0]) is list:
|
|
518
|
+
joint_pos = [joint_pos, ]
|
|
519
|
+
is_list = False
|
|
520
|
+
data = {"user":user,"tool":tool,"point_cnt":len(joint_pos)}
|
|
521
|
+
for i in range(len(joint_pos)):
|
|
522
|
+
data[f"joint{i+1}"] = joint_pos[i]
|
|
523
|
+
ret = self.request({"command":"getKinematics",
|
|
524
|
+
"task_id":"forward",
|
|
525
|
+
"arm_index":0,
|
|
526
|
+
"data":data})
|
|
527
|
+
|
|
528
|
+
try:
|
|
529
|
+
if ret["recv"] == "Task_Recieve":
|
|
530
|
+
if is_list:
|
|
531
|
+
points = []
|
|
532
|
+
for i in range(len(joint_pos)):
|
|
533
|
+
points.append(ret["data"][f"point{i+1}"])
|
|
534
|
+
return points
|
|
535
|
+
else:
|
|
536
|
+
return ret["data"]["point1"]
|
|
537
|
+
else:
|
|
538
|
+
return None
|
|
539
|
+
except:
|
|
540
|
+
return None
|
|
541
|
+
|
|
466
542
|
def request(self, req):
|
|
467
543
|
event = threading.Event()
|
|
468
544
|
task_key = str(uuid.uuid4())
|
|
@@ -478,22 +554,25 @@ class Carm:
|
|
|
478
554
|
self.ws.send(json.dumps(msg))
|
|
479
555
|
|
|
480
556
|
def __cbk_status(self, message):
|
|
481
|
-
self.state = message
|
|
482
|
-
|
|
483
557
|
if not "arm" in message:
|
|
484
558
|
return
|
|
559
|
+
|
|
560
|
+
self.state = message
|
|
561
|
+
|
|
562
|
+
if message["errMsg"] != "":
|
|
563
|
+
print(message["errMsg"] )
|
|
485
564
|
|
|
486
565
|
arm_json = message["arm"][0]
|
|
487
|
-
if "
|
|
566
|
+
if "task" not in arm_json:
|
|
488
567
|
return
|
|
568
|
+
running = arm_json["task"]["exe_flag"]
|
|
489
569
|
|
|
490
|
-
|
|
491
|
-
|
|
570
|
+
if not running:
|
|
571
|
+
self.task_event.set()
|
|
492
572
|
|
|
493
573
|
|
|
494
574
|
def __cbk_taskfinish(self, message):
|
|
495
575
|
task = message["task_key"]
|
|
496
|
-
self.task_pool[task]["event"].set()
|
|
497
576
|
|
|
498
577
|
def __on_open(self, ws):
|
|
499
578
|
self.open_ready.set()
|
carm/carm_dds.py
CHANGED
|
@@ -29,7 +29,7 @@ class ArmDriver:
|
|
|
29
29
|
if type(position) != tuple:
|
|
30
30
|
position = np.frombuffer(msg["position"],dtype=np.float64).tolist()
|
|
31
31
|
|
|
32
|
-
if position > 7:
|
|
32
|
+
if len(position) > 7:
|
|
33
33
|
self.arm.track_pose(position[:7], position[7])
|
|
34
34
|
else:
|
|
35
35
|
self.arm.track_pose(position)
|
|
@@ -49,7 +49,7 @@ class ArmDriver:
|
|
|
49
49
|
if type(position) != tuple:
|
|
50
50
|
position = np.frombuffer(msg["position"],dtype=np.float64).tolist()
|
|
51
51
|
|
|
52
|
-
if position > 6:
|
|
52
|
+
if len(position) > 6:
|
|
53
53
|
self.arm.track_joint(position[:6], position[6])
|
|
54
54
|
else:
|
|
55
55
|
self.arm.track_joint(position)
|
|
@@ -139,4 +139,4 @@ def main():
|
|
|
139
139
|
if __name__ == "__main__":
|
|
140
140
|
main()
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: carm
|
|
3
|
+
Version: 0.1.20260204
|
|
4
|
+
Summary: Python interface for cvte arm.
|
|
5
|
+
Author-email: Yong Zhao <zhaoyong11933@cvte.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
8
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
9
|
+
Requires-Python: >=3.6
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: websocket-client
|
|
12
|
+
|
|
13
|
+
# pycarm
|
|
14
|
+
|
|
15
|
+
Python interface for cvte arm.
|
|
16
|
+
|
|
17
|
+
# Install
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pip install carm
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
# Usage
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
import carm
|
|
27
|
+
|
|
28
|
+
arm = carm.Carm("ws://localhost:8090")
|
|
29
|
+
|
|
30
|
+
print("version:",carm.version)
|
|
31
|
+
print("limits:", carm.limit)
|
|
32
|
+
print("state:", carm.state)
|
|
33
|
+
|
|
34
|
+
carm.track_joint(carm.joint_pos)
|
|
35
|
+
|
|
36
|
+
carm.move_joint(carm.joint_pos)
|
|
37
|
+
|
|
38
|
+
carm.track_pose(carm.cart_pose)
|
|
39
|
+
|
|
40
|
+
carm.move_pose(carm.cart_pose)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
# Version update to pypy
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
python3 -m build
|
|
47
|
+
python3 -m twine upload --repository pypi dist/*
|
|
48
|
+
```
|
|
49
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
carm/__init__.py,sha256=lfNjXYpO8FjQVunCqiaUzjsNUnyuhcyO8Je0ixh1RJY,24
|
|
2
|
+
carm/carm.py,sha256=I8gMTZb2PMcjht97XcMV95xGVio8JAacqAznL3rD6y4,20406
|
|
3
|
+
carm/carm_dds.py,sha256=eHKOvMkdB-GdHweCN3RA2V2eJ06y3HBdgWNZYehXL2g,5720
|
|
4
|
+
carm/carm_ros2.py,sha256=nox040kSIjpwT9s-crH9D0yGYvFPNfkWNrzj4tqf4I8,3766
|
|
5
|
+
carm-0.1.20260204.dist-info/METADATA,sha256=fScH0VNJuQGvn4K6mKS3UgCQVCFystLfq1UU0jjUzCg,900
|
|
6
|
+
carm-0.1.20260204.dist-info/WHEEL,sha256=WnJ8fYhv8N4SYVK2lLYNI6N0kVATA7b0piVUNvqIIJE,91
|
|
7
|
+
carm-0.1.20260204.dist-info/entry_points.txt,sha256=qsJWC39p-s4UO3KZ8BfV2hikeMX693mahkYbR3w67Lk,76
|
|
8
|
+
carm-0.1.20260204.dist-info/top_level.txt,sha256=nZ1bTssUAnAqc2CMka3erGx_2LsdZrSkqtjNf9Ce_d8,5
|
|
9
|
+
carm-0.1.20260204.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: carm
|
|
3
|
-
Version: 0.1.20251010
|
|
4
|
-
Summary: Python interface for cvte arm.
|
|
5
|
-
Author-email: Yong Zhao <zhaoyong11933@cvte.com>
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
8
|
-
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
9
|
-
Requires-Python: >=3.6
|
|
10
|
-
Requires-Dist: websocket-client
|
|
11
|
-
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
carm/__init__.py,sha256=lfNjXYpO8FjQVunCqiaUzjsNUnyuhcyO8Je0ixh1RJY,24
|
|
2
|
-
carm/carm.py,sha256=jep6tWFUYl-8jw-qixC_awV5gdTEyicBU2K7oU7qNGs,17973
|
|
3
|
-
carm/carm_dds.py,sha256=DfejpbrW_qWq36ZQpyWVRdfDsUCkScHXOx2fP-8i3kY,5711
|
|
4
|
-
carm/carm_ros2.py,sha256=nox040kSIjpwT9s-crH9D0yGYvFPNfkWNrzj4tqf4I8,3766
|
|
5
|
-
carm-0.1.20251010.dist-info/METADATA,sha256=QeLknGXuES8_Ld8fsX5AOVUKlgUztdVXoOr4lzJiGGM,389
|
|
6
|
-
carm-0.1.20251010.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
7
|
-
carm-0.1.20251010.dist-info/entry_points.txt,sha256=qsJWC39p-s4UO3KZ8BfV2hikeMX693mahkYbR3w67Lk,76
|
|
8
|
-
carm-0.1.20251010.dist-info/top_level.txt,sha256=nZ1bTssUAnAqc2CMka3erGx_2LsdZrSkqtjNf9Ce_d8,5
|
|
9
|
-
carm-0.1.20251010.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|