carm 0.0.20250911__py3-none-any.whl → 0.1.20251017__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 +43 -13
- carm/carm_dds.py +27 -14
- carm/carm_ros2.py +3 -3
- carm-0.1.20251017.dist-info/METADATA +47 -0
- carm-0.1.20251017.dist-info/RECORD +9 -0
- carm-0.0.20250911.dist-info/METADATA +0 -11
- carm-0.0.20250911.dist-info/RECORD +0 -9
- {carm-0.0.20250911.dist-info → carm-0.1.20251017.dist-info}/WHEEL +0 -0
- {carm-0.0.20250911.dist-info → carm-0.1.20251017.dist-info}/entry_points.txt +0 -0
- {carm-0.0.20250911.dist-info → carm-0.1.20251017.dist-info}/top_level.txt +0 -0
carm/carm.py
CHANGED
|
@@ -21,7 +21,7 @@ class Carm:
|
|
|
21
21
|
"onCarmError": lambda msg: print("Error:", msg)
|
|
22
22
|
}
|
|
23
23
|
self.res_pool = {}
|
|
24
|
-
self.
|
|
24
|
+
self.task_event = threading.Event()
|
|
25
25
|
|
|
26
26
|
self.reader = threading.Thread(target=self.__recv_loop, daemon=True).start()
|
|
27
27
|
self.open_ready = threading.Event()
|
|
@@ -279,7 +279,7 @@ class Carm:
|
|
|
279
279
|
joints[i] = self.__clip(v, lower[i], upper[i])
|
|
280
280
|
return joints
|
|
281
281
|
|
|
282
|
-
def track_joint(self, pos, end_effector =
|
|
282
|
+
def track_joint(self, pos, end_effector = None):
|
|
283
283
|
"""
|
|
284
284
|
关节轨迹跟踪.
|
|
285
285
|
Args:
|
|
@@ -295,12 +295,14 @@ class Carm:
|
|
|
295
295
|
"point_type":{"space":0},
|
|
296
296
|
"data":{"way_point": pos}}
|
|
297
297
|
|
|
298
|
-
if end_effector
|
|
299
|
-
req["data"]["
|
|
298
|
+
if not end_effector is None:
|
|
299
|
+
#req["data"]["grp_point"] = end_effector
|
|
300
|
+
tau = (0.1 - end_effector) * 20
|
|
301
|
+
self.set_end_effector(end_effector, tau)
|
|
300
302
|
|
|
301
303
|
return self.request(req)
|
|
302
304
|
|
|
303
|
-
def track_pose(self, pos, end_effector =
|
|
305
|
+
def track_pose(self, pos, end_effector =None):
|
|
304
306
|
"""
|
|
305
307
|
笛卡尔轨迹跟踪.
|
|
306
308
|
Args:
|
|
@@ -315,9 +317,11 @@ class Carm:
|
|
|
315
317
|
"point_type":{"space":1},
|
|
316
318
|
"data":{"way_point": pos}}
|
|
317
319
|
|
|
318
|
-
if end_effector
|
|
319
|
-
req["data"]["
|
|
320
|
-
|
|
320
|
+
if not end_effector is None:
|
|
321
|
+
#req["data"]["grp_point"] = end_effector
|
|
322
|
+
tau = (0.1 - end_effector) * 20
|
|
323
|
+
self.set_end_effector(end_effector, tau)
|
|
324
|
+
|
|
321
325
|
return self.request(req)
|
|
322
326
|
|
|
323
327
|
def move_joint(self, pos, tm=-1, sync=True, user=0, tool=0):
|
|
@@ -402,10 +406,8 @@ class Carm:
|
|
|
402
406
|
return res
|
|
403
407
|
|
|
404
408
|
def __wait_task(self, task_key):
|
|
405
|
-
|
|
406
|
-
self.
|
|
407
|
-
event.wait()
|
|
408
|
-
self.task_pool.pop(task_key)
|
|
409
|
+
self.task_event= threading.Event()
|
|
410
|
+
self.task_event.wait()
|
|
409
411
|
|
|
410
412
|
def move_joint_traj(self, target_traj, gripper_pos = [], stamps = [], is_sync=True):
|
|
411
413
|
if len(stamps) != len(target_traj): # as soon as possible
|
|
@@ -425,6 +427,20 @@ class Carm:
|
|
|
425
427
|
def move_pvt(self, target_traj, gripper_pos = [], stamps = [], is_sync=True):
|
|
426
428
|
pass # TODO
|
|
427
429
|
|
|
430
|
+
def set_redundancy_tau(self, redundancy_tau, end_effector=None):
|
|
431
|
+
"""
|
|
432
|
+
设置冗余关节的力矩
|
|
433
|
+
Args:
|
|
434
|
+
redundancy_tau (list): The redundancy joint torque.
|
|
435
|
+
end_effector (int, optional): The end effector index.
|
|
436
|
+
Returns:
|
|
437
|
+
dict: The response from the arm.
|
|
438
|
+
"""
|
|
439
|
+
return self.request({"command":"setRedundancyTau",
|
|
440
|
+
"arm_index":0,
|
|
441
|
+
"is_master":True,
|
|
442
|
+
"redundancy_tau":redundancy_tau})
|
|
443
|
+
|
|
428
444
|
def invK(self, cart_pose, ref_joints, user=0, tool=0):
|
|
429
445
|
"""
|
|
430
446
|
逆解
|
|
@@ -464,11 +480,25 @@ class Carm:
|
|
|
464
480
|
self.ws.send(json.dumps(msg))
|
|
465
481
|
|
|
466
482
|
def __cbk_status(self, message):
|
|
483
|
+
if not "arm" in message:
|
|
484
|
+
return
|
|
485
|
+
|
|
467
486
|
self.state = message
|
|
487
|
+
|
|
488
|
+
if message["errMsg"] != "":
|
|
489
|
+
print(message["errMsg"] )
|
|
490
|
+
|
|
491
|
+
arm_json = message["arm"][0]
|
|
492
|
+
if "task" not in arm_json:
|
|
493
|
+
return
|
|
494
|
+
running = arm_json["task"]["exe_flag"]
|
|
495
|
+
|
|
496
|
+
if not running:
|
|
497
|
+
self.task_event.set()
|
|
498
|
+
|
|
468
499
|
|
|
469
500
|
def __cbk_taskfinish(self, message):
|
|
470
501
|
task = message["task_key"]
|
|
471
|
-
self.task_pool[task]["event"].set()
|
|
472
502
|
|
|
473
503
|
def __on_open(self, ws):
|
|
474
504
|
self.open_ready.set()
|
carm/carm_dds.py
CHANGED
|
@@ -13,10 +13,7 @@ class ArmDriver:
|
|
|
13
13
|
self.args = args
|
|
14
14
|
|
|
15
15
|
self.arm = carm.Carm(args.addr)
|
|
16
|
-
|
|
17
|
-
self.arm.set_control_mode(3)
|
|
18
|
-
else:
|
|
19
|
-
self.arm.set_control_mode(1)
|
|
16
|
+
self.arm.set_control_mode(args.mode)
|
|
20
17
|
|
|
21
18
|
self.arm.set_speed_level(args.speed)
|
|
22
19
|
|
|
@@ -28,8 +25,14 @@ class ArmDriver:
|
|
|
28
25
|
self.sub_end = messenger.subscribe(args.end_cmd_topic, 0, lambda msg:self.end_callback(msg))
|
|
29
26
|
|
|
30
27
|
def end_callback(self, msg):
|
|
31
|
-
position =
|
|
32
|
-
|
|
28
|
+
position = msg["position"]
|
|
29
|
+
if type(position) != tuple:
|
|
30
|
+
position = np.frombuffer(msg["position"],dtype=np.float64).tolist()
|
|
31
|
+
|
|
32
|
+
if len(position) > 7:
|
|
33
|
+
self.arm.track_pose(position[:7], position[7])
|
|
34
|
+
else:
|
|
35
|
+
self.arm.track_pose(position)
|
|
33
36
|
|
|
34
37
|
if self.args.enable_ik:
|
|
35
38
|
ret = self.arm.invK(position, ref_joints=self.arm.joint_pos)
|
|
@@ -41,9 +44,15 @@ class ArmDriver:
|
|
|
41
44
|
self.pub_joint_ik.publish({"header": msg["header"], "position": pos})
|
|
42
45
|
|
|
43
46
|
|
|
44
|
-
def joint_callback(self, msg):
|
|
45
|
-
position =
|
|
46
|
-
|
|
47
|
+
def joint_callback(self, msg):
|
|
48
|
+
position = msg["position"]
|
|
49
|
+
if type(position) != tuple:
|
|
50
|
+
position = np.frombuffer(msg["position"],dtype=np.float64).tolist()
|
|
51
|
+
|
|
52
|
+
if len(position) > 6:
|
|
53
|
+
self.arm.track_joint(position[:6], position[6])
|
|
54
|
+
else:
|
|
55
|
+
self.arm.track_joint(position)
|
|
47
56
|
|
|
48
57
|
def loop(self):
|
|
49
58
|
while True:
|
|
@@ -52,8 +61,12 @@ class ArmDriver:
|
|
|
52
61
|
nanosec = int((stamp - sec) * 1e9)
|
|
53
62
|
header = {"stamp": {"sec": sec, "nanosec": nanosec},"frame_id": "base_link"}
|
|
54
63
|
|
|
55
|
-
end_msg = {"header": header,
|
|
56
|
-
|
|
64
|
+
end_msg = {"header": header,
|
|
65
|
+
"position": self.arm.cart_pose + [self.arm.gripper_state["gripper_pos"],]}
|
|
66
|
+
joints_msg = {"header": header,
|
|
67
|
+
"position": self.arm.joint_pos + [self.arm.gripper_state["gripper_pos"],],
|
|
68
|
+
"velocity": self.arm.joint_vel + [self.arm.gripper_state["gripper_vel"],],
|
|
69
|
+
"effort": self.arm.joint_tau + [self.arm.gripper_state["gripper_tau"],]}
|
|
57
70
|
|
|
58
71
|
self.pub_joint.publish(joints_msg)
|
|
59
72
|
self.pub_end.publish(end_msg)
|
|
@@ -92,13 +105,13 @@ def main():
|
|
|
92
105
|
parser.add_argument("--cmd", type=str, default="", help="Send command instead of start driver, support enable,disable,remote")
|
|
93
106
|
parser.add_argument("--device", type=str, default="carm", help="device name, used as topic prefix")
|
|
94
107
|
parser.add_argument("--dds", type=str, default="svar_messenger_ros2", help="the dds plugin, default is ros2, options: svar_zbus, svar_lcm")
|
|
95
|
-
parser.add_argument("--
|
|
108
|
+
parser.add_argument("--mode", type=int, default=1, help="The arm control mode: POSITION:1, MIT:2, MASTER:3")
|
|
96
109
|
parser.add_argument("--joint_topic", type=str, default="", help="the joints status topic")
|
|
97
110
|
parser.add_argument("--end_topic", type=str, default="", help="the joints status topic")
|
|
98
111
|
parser.add_argument("--joint_cmd_topic", type=str, default="", help="the joints cmd topic")
|
|
99
112
|
parser.add_argument("--joint_cmd_ik_topic", type=str, default="", help="the joints cmd ik topic, this means both end_cmd_topic will be transformed with ik")
|
|
100
113
|
parser.add_argument("--end_cmd_topic", type=str, default="", help="the end cmd topic")
|
|
101
|
-
parser.add_argument("--speed", type=float, default=
|
|
114
|
+
parser.add_argument("--speed", type=float, default=50.0, help="the speed level")
|
|
102
115
|
|
|
103
116
|
args = parser.parse_args()
|
|
104
117
|
|
|
@@ -126,4 +139,4 @@ def main():
|
|
|
126
139
|
if __name__ == "__main__":
|
|
127
140
|
main()
|
|
128
141
|
|
|
129
|
-
|
|
142
|
+
|
carm/carm_ros2.py
CHANGED
|
@@ -46,9 +46,9 @@ class ArmDriver(Node):
|
|
|
46
46
|
while True:
|
|
47
47
|
joint_msg = JointState() # list of string
|
|
48
48
|
joint_msg.header.stamp = self.get_clock().now().to_msg()
|
|
49
|
-
joint_msg.position = self.arm.joint_pos
|
|
50
|
-
joint_msg.velocity = self.arm.joint_vel
|
|
51
|
-
joint_msg.effort = self.arm.joint_tau
|
|
49
|
+
joint_msg.position = np.array(self.arm.joint_pos).tolist()
|
|
50
|
+
joint_msg.velocity = np.array(self.arm.joint_vel).tolist()
|
|
51
|
+
joint_msg.effort = np.array(self.arm.joint_tau).tolist()
|
|
52
52
|
joint_msg.position.append(self.arm.gripper_state["gripper_pos"])
|
|
53
53
|
self.pub_joint.publish(joint_msg)
|
|
54
54
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: carm
|
|
3
|
+
Version: 0.1.20251017
|
|
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
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
carm/__init__.py,sha256=lfNjXYpO8FjQVunCqiaUzjsNUnyuhcyO8Je0ixh1RJY,24
|
|
2
|
+
carm/carm.py,sha256=ZlLIm2fp0LgcVtSFHJTTbXTSFfFF4VfcNeLTOQH0s1g,18202
|
|
3
|
+
carm/carm_dds.py,sha256=eHKOvMkdB-GdHweCN3RA2V2eJ06y3HBdgWNZYehXL2g,5720
|
|
4
|
+
carm/carm_ros2.py,sha256=nox040kSIjpwT9s-crH9D0yGYvFPNfkWNrzj4tqf4I8,3766
|
|
5
|
+
carm-0.1.20251017.dist-info/METADATA,sha256=ZB4PIprra2K5ouRua9MIt6x6IGPCZm-w5OWDV7cCohE,850
|
|
6
|
+
carm-0.1.20251017.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
7
|
+
carm-0.1.20251017.dist-info/entry_points.txt,sha256=qsJWC39p-s4UO3KZ8BfV2hikeMX693mahkYbR3w67Lk,76
|
|
8
|
+
carm-0.1.20251017.dist-info/top_level.txt,sha256=nZ1bTssUAnAqc2CMka3erGx_2LsdZrSkqtjNf9Ce_d8,5
|
|
9
|
+
carm-0.1.20251017.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: carm
|
|
3
|
-
Version: 0.0.20250911
|
|
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=yVKWmDov9c69l7ye1jcWwBWluWgarEUbFhU6tSfaVoA,17159
|
|
3
|
-
carm/carm_dds.py,sha256=9IkexhHYrjNx2nzplEa4Kj0KdLayzACPChtIF1G29BM,5137
|
|
4
|
-
carm/carm_ros2.py,sha256=IxQD4pglxCH2Vbfj6mm2DlV8KgkqMnS0k1-mIICV8I8,3709
|
|
5
|
-
carm-0.0.20250911.dist-info/METADATA,sha256=hpgdZE1IgDYSIAC3HU-RMdfVtbVGgYlhcLWKuWyslJA,389
|
|
6
|
-
carm-0.0.20250911.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
7
|
-
carm-0.0.20250911.dist-info/entry_points.txt,sha256=qsJWC39p-s4UO3KZ8BfV2hikeMX693mahkYbR3w67Lk,76
|
|
8
|
-
carm-0.0.20250911.dist-info/top_level.txt,sha256=nZ1bTssUAnAqc2CMka3erGx_2LsdZrSkqtjNf9Ce_d8,5
|
|
9
|
-
carm-0.0.20250911.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|