kuavo-humanoid-sdk 1.1.5__py3-none-any.whl → 1.1.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 kuavo-humanoid-sdk might be problematic. Click here for more details.

Files changed (50) hide show
  1. kuavo_humanoid_sdk/__init__.py +0 -2
  2. kuavo_humanoid_sdk/interfaces/data_types.py +0 -90
  3. kuavo_humanoid_sdk/kuavo/__init__.py +0 -3
  4. kuavo_humanoid_sdk/kuavo/core/core.py +20 -238
  5. kuavo_humanoid_sdk/kuavo/core/ros/control.py +27 -1087
  6. kuavo_humanoid_sdk/kuavo/core/ros/param.py +4 -142
  7. kuavo_humanoid_sdk/kuavo/core/ros/state.py +19 -556
  8. kuavo_humanoid_sdk/kuavo/core/ros_env.py +1 -229
  9. kuavo_humanoid_sdk/kuavo/dexterous_hand.py +2 -6
  10. kuavo_humanoid_sdk/kuavo/leju_claw.py +2 -6
  11. kuavo_humanoid_sdk/kuavo/robot.py +27 -150
  12. kuavo_humanoid_sdk/kuavo/robot_arm.py +7 -53
  13. kuavo_humanoid_sdk/kuavo/robot_head.py +0 -10
  14. kuavo_humanoid_sdk/kuavo/robot_info.py +2 -7
  15. kuavo_humanoid_sdk/kuavo/robot_state.py +4 -41
  16. kuavo_humanoid_sdk/msg/kuavo_msgs/msg/__init__.py +0 -7
  17. kuavo_humanoid_sdk/msg/kuavo_msgs/srv/__init__.py +0 -5
  18. kuavo_humanoid_sdk/msg/kuavo_msgs/srv/_playmusic.py +20 -26
  19. kuavo_humanoid_sdk/msg/motion_capture_ik/msg/__init__.py +9 -0
  20. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/msg/_armHandPose.py +2 -2
  21. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/msg/_handPose.py +2 -2
  22. kuavo_humanoid_sdk/msg/motion_capture_ik/msg/_headBodyPose.py +145 -0
  23. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/msg/_ikSolveError.py +13 -13
  24. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/msg/_ikSolveParam.py +2 -2
  25. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/msg/_robotArmQVVD.py +2 -2
  26. kuavo_humanoid_sdk/msg/motion_capture_ik/msg/_robotHandPosition.py +225 -0
  27. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/msg/_twoArmHandPose.py +13 -13
  28. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/msg/_twoArmHandPoseCmd.py +30 -34
  29. kuavo_humanoid_sdk/msg/motion_capture_ik/srv/__init__.py +4 -0
  30. kuavo_humanoid_sdk/msg/{kuavo_msgs/srv/_setMmCtrlFrame.py → motion_capture_ik/srv/_changeArmCtrlMode.py} +37 -35
  31. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/srv/_changeArmCtrlModeKuavo.py +5 -5
  32. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/srv/_fkSrv.py +13 -13
  33. kuavo_humanoid_sdk/msg/{kuavo_msgs → motion_capture_ik}/srv/_twoArmHandPoseCmdSrv.py +37 -38
  34. {kuavo_humanoid_sdk-1.1.5.dist-info → kuavo_humanoid_sdk-1.1.6.dist-info}/METADATA +1 -2
  35. {kuavo_humanoid_sdk-1.1.5.dist-info → kuavo_humanoid_sdk-1.1.6.dist-info}/RECORD +37 -46
  36. kuavo_humanoid_sdk/common/global_config.py +0 -16
  37. kuavo_humanoid_sdk/common/websocket_kuavo_sdk.py +0 -23
  38. kuavo_humanoid_sdk/kuavo/core/audio.py +0 -36
  39. kuavo_humanoid_sdk/kuavo/core/ros/audio.py +0 -176
  40. kuavo_humanoid_sdk/kuavo/core/ros/tools.py +0 -158
  41. kuavo_humanoid_sdk/kuavo/core/ros/vision.py +0 -283
  42. kuavo_humanoid_sdk/kuavo/robot_audio.py +0 -39
  43. kuavo_humanoid_sdk/kuavo/robot_tool.py +0 -62
  44. kuavo_humanoid_sdk/kuavo/robot_vision.py +0 -90
  45. kuavo_humanoid_sdk/kuavo_strategy/__init__.py +0 -2
  46. kuavo_humanoid_sdk/kuavo_strategy/grasp_box/grasp_box_strategy.py +0 -418
  47. kuavo_humanoid_sdk/kuavo_strategy/kuavo_strategy.py +0 -63
  48. kuavo_humanoid_sdk/msg/kuavo_msgs/srv/_SpeechSynthesis.py +0 -270
  49. {kuavo_humanoid_sdk-1.1.5.dist-info → kuavo_humanoid_sdk-1.1.6.dist-info}/WHEEL +0 -0
  50. {kuavo_humanoid_sdk-1.1.5.dist-info → kuavo_humanoid_sdk-1.1.6.dist-info}/top_level.txt +0 -0
@@ -1,283 +0,0 @@
1
- #! /usr/bin/env python3
2
- # coding: utf-8
3
-
4
- import copy
5
- import time
6
- from collections import deque
7
- from typing import Tuple, Optional
8
-
9
- from kuavo_humanoid_sdk.kuavo.core.ros.param import make_robot_param, EndEffectorType
10
- from kuavo_humanoid_sdk.common.logger import SDKLogger
11
- from kuavo_humanoid_sdk.interfaces.data_types import (AprilTagData)
12
-
13
- try:
14
- import rospy
15
- from std_msgs.msg import Float64
16
- from nav_msgs.msg import Odometry
17
- from sensor_msgs.msg import JointState
18
- from apriltag_ros.msg import AprilTagDetectionArray
19
- from geometry_msgs.msg import TransformStamped, PoseStamped
20
- import tf2_ros
21
- import tf2_geometry_msgs
22
- except ImportError:
23
- pass
24
-
25
- class KuavoRobotVisionCore:
26
- """Handles vision-related data processing for Kuavo humanoid robot.
27
-
28
- Attributes:
29
- tf_buffer (tf2_ros.Buffer): TF2 transform buffer
30
- tf_listener (tf2_ros.TransformListener): TF2 transform listener
31
- tf_broadcaster (tf2_ros.TransformBroadcaster): TF2 transform broadcaster
32
- """
33
-
34
- def __init__(self):
35
- """Initializes vision system components including TF and AprilTag subscribers."""
36
- if not hasattr(self, '_initialized'):
37
- # Initialize TF components
38
- self.tf_buffer = tf2_ros.Buffer()
39
- self.tf_listener = tf2_ros.TransformListener(self.tf_buffer)
40
- self.tf_broadcaster = tf2_ros.TransformBroadcaster()
41
-
42
- # 添加TF2监听器
43
- self._tf_buffer = tf2_ros.Buffer()
44
- self._tf_listener = tf2_ros.TransformListener(self._tf_buffer)
45
-
46
- # FIRST: Initialize data structures before creating subscribers
47
- """ data """
48
- self._apriltag_data_from_camera = AprilTagData(
49
- id = [],
50
- size = [],
51
- pose = []
52
- )
53
-
54
- self._apriltag_data_from_base = AprilTagData(
55
- id = [],
56
- size = [],
57
- pose = []
58
- )
59
-
60
- self._apriltag_data_from_odom = AprilTagData(
61
- id = [],
62
- size = [],
63
- pose = []
64
- )
65
-
66
- # THEN: Create subscribers after all data structures are initialized
67
- self._apriltag_data_camera_sub = rospy.Subscriber('/tag_detections', AprilTagDetectionArray, self._apriltag_data_callback_camera)
68
- self._apriltag_data_base_sub = rospy.Subscriber('/robot_tag_info', AprilTagDetectionArray, self._apriltag_data_callback_base)
69
-
70
- # Mark as initialized
71
- self._initialized = True
72
-
73
- def _apriltag_data_callback_camera(self, data):
74
- """Callback for processing AprilTag detections from camera.
75
-
76
- Args:
77
- data (AprilTagDetectionArray): Raw detection data from camera
78
- """
79
- # 清空之前的数据
80
- self._apriltag_data_from_camera.id = []
81
- self._apriltag_data_from_camera.size = []
82
- self._apriltag_data_from_camera.pose = []
83
-
84
- # 处理每个标签检测
85
- for detection in data.detections:
86
- # 添加ID
87
- for id in detection.id:
88
- self._apriltag_data_from_camera.id.append(id)
89
-
90
- # 添加尺寸 (从size数组中获取)
91
- if detection.size and len(detection.size) > 0:
92
- self._apriltag_data_from_camera.size.append(detection.size[0])
93
- else:
94
- self._apriltag_data_from_camera.size.append(0.0)
95
-
96
- # 添加姿态
97
- self._apriltag_data_from_camera.pose.append(detection.pose.pose.pose)
98
- # # debug
99
- # rospy.loginfo("Apriltag data from camera: %s", self._apriltag_data_from_camera)
100
-
101
- def _apriltag_data_callback_base(self, data):
102
- """Callback for processing AprilTag detections from base link.
103
-
104
- Args:
105
- data (AprilTagDetectionArray): Raw detection data from base frame
106
- """
107
- # 清空之前的数据
108
- self._apriltag_data_from_base.id = []
109
- self._apriltag_data_from_base.size = []
110
- self._apriltag_data_from_base.pose = []
111
-
112
- # 处理每个标签检测
113
- for detection in data.detections:
114
- # 添加ID
115
- for id in detection.id:
116
- self._apriltag_data_from_base.id.append(id)
117
-
118
- # 添加尺寸 (从size数组中获取)
119
- if detection.size and len(detection.size) > 0:
120
- self._apriltag_data_from_base.size.append(detection.size[0])
121
- else:
122
- self._apriltag_data_from_base.size.append(0.0)
123
-
124
- # 添加姿态
125
- self._apriltag_data_from_base.pose.append(detection.pose.pose.pose)
126
-
127
- # # debug
128
- # rospy.loginfo("Apriltag data from base: %s", self._apriltag_data_from_base)
129
-
130
- # 在基础数据处理完后,尝试进行odom坐标系的变换
131
- self._transform_base_to_odom()
132
-
133
- def _transform_base_to_odom(self):
134
- """Transforms AprilTag poses from base_link to odom coordinate frame.
135
-
136
- Performs:
137
- - Coordinate transformation using TF2
138
- - TF broadcasting for transformed poses
139
- - Data validation and error handling
140
-
141
- Raises:
142
- tf2_ros.LookupException: If transform is not available
143
- tf2_ros.ConnectivityException: If transform chain is broken
144
- tf2_ros.ExtrapolationException: If transform time is out of range
145
- """
146
- # 添加节点状态检查
147
- if rospy.is_shutdown():
148
- return
149
-
150
- # 清空之前的数据
151
- self._apriltag_data_from_odom.id = []
152
- self._apriltag_data_from_odom.size = []
153
- self._apriltag_data_from_odom.pose = []
154
-
155
- # 如果base数据为空,则不处理
156
- if not self._apriltag_data_from_base.id:
157
- # SDKLogger.warn("No base tag data, skip transform")
158
- return
159
-
160
- try:
161
- # 获取从base_link到odom的变换
162
- transform = self._tf_buffer.lookup_transform(
163
- "odom",
164
- "base_link",
165
- rospy.Time(0),
166
- rospy.Duration(1.0)
167
- )
168
-
169
- # 复制ID和尺寸信息
170
- self._apriltag_data_from_odom.id = self._apriltag_data_from_base.id.copy()
171
- self._apriltag_data_from_odom.size = self._apriltag_data_from_base.size.copy()
172
-
173
- # 对每个姿态进行变换
174
- for idx, (tag_id, pose) in enumerate(zip(self._apriltag_data_from_base.id, self._apriltag_data_from_base.pose)):
175
- # 创建PoseStamped消息
176
- pose_stamped = PoseStamped()
177
- pose_stamped.header.frame_id = "base_link"
178
- pose_stamped.header.stamp = rospy.Time.now()
179
- pose_stamped.pose = pose
180
-
181
- # 执行变换
182
- transformed_pose = tf2_geometry_msgs.do_transform_pose(pose_stamped, transform)
183
-
184
- # 将变换后的姿态添加到odom数据中
185
- self._apriltag_data_from_odom.pose.append(transformed_pose.pose)
186
-
187
- # 创建并广播TF
188
- transform_stamped = TransformStamped()
189
- transform_stamped.header.stamp = rospy.Time.now()
190
- transform_stamped.header.frame_id = "odom"
191
- transform_stamped.child_frame_id = f"tag_odom_{tag_id}"
192
- transform_stamped.transform.translation.x = transformed_pose.pose.position.x
193
- transform_stamped.transform.translation.y = transformed_pose.pose.position.y
194
- transform_stamped.transform.translation.z = transformed_pose.pose.position.z
195
- transform_stamped.transform.rotation = transformed_pose.pose.orientation
196
-
197
- # 发送变换前再次检查节点状态
198
- if not rospy.is_shutdown():
199
- self.tf_broadcaster.sendTransform(transform_stamped)
200
-
201
- except (tf2_ros.LookupException,
202
- tf2_ros.ConnectivityException,
203
- tf2_ros.ExtrapolationException,
204
- rospy.ROSException) as e: # 添加ROSException捕获
205
- SDKLogger.warn(f"TF变换异常: {str(e)}")
206
-
207
- @property
208
- def apriltag_data_from_camera(self) -> AprilTagData:
209
- """AprilTag detection data in camera coordinate frame.
210
-
211
- Returns:
212
- AprilTagData: Contains lists of tag IDs, sizes and poses
213
- """
214
- return self._apriltag_data_from_camera
215
-
216
- @property
217
- def apriltag_data_from_base(self) -> AprilTagData:
218
- """AprilTag detection data in base_link coordinate frame.
219
-
220
- Returns:
221
- AprilTagData: Contains lists of tag IDs, sizes and poses
222
- """
223
- return self._apriltag_data_from_base
224
-
225
- @property
226
- def apriltag_data_from_odom(self) -> AprilTagData:
227
- """AprilTag detection data in odom coordinate frame.
228
-
229
- Returns:
230
- AprilTagData: Contains lists of tag IDs, sizes and transformed poses
231
- """
232
- return self._apriltag_data_from_odom
233
-
234
- def _get_data_by_id(self, target_id: int, data_source: str = "base") -> Optional[dict]:
235
- """Retrieves AprilTag data by specific ID from selected source.
236
-
237
- Args:
238
- target_id (int): AprilTag ID to search for
239
- data_source (str): Data source selector, valid options:
240
- "camera", "base", "odom"
241
-
242
- Returns:
243
- Optional[dict]: Dictionary containing 'sizes' and 'poses' lists if found,
244
- None if no matching data
245
-
246
- Raises:
247
- ValueError: If invalid data_source is specified
248
- """
249
- data_map = {
250
- "camera": self._apriltag_data_from_camera,
251
- "base": self._apriltag_data_from_base,
252
- "odom": self._apriltag_data_from_odom
253
- }
254
-
255
- if data_source not in data_map:
256
- # SDKLogger.error(f"Invalid data source: {data_source}, must be one of {list(data_map.keys())}")
257
- return None
258
-
259
- data = data_map[data_source]
260
-
261
- # 查找所有匹配的索引
262
- indices = [i for i, tag_id in enumerate(data.id) if tag_id == target_id]
263
-
264
- if not indices:
265
- # SDKLogger.debug(f"No data found for tag ID {target_id} in {data_source} source")
266
- return None
267
-
268
- return {
269
- "sizes": [data.size[i] for i in indices],
270
- "poses": [data.pose[i] for i in indices]
271
- }
272
-
273
- # if __name__ == "__main__":
274
-
275
- # kuavo_robot_vision_core = KuavoRobotVisionCore()
276
- # time.sleep(5)
277
- # print("apriltag_data_from_camera:")
278
- # print(kuavo_robot_vision_core.apriltag_data_from_camera)
279
- # print("apriltag_data_from_base:")
280
- # print(kuavo_robot_vision_core.apriltag_data_from_base)
281
- # print("apriltag_data_from_odom:")
282
- # print(kuavo_robot_vision_core.apriltag_data_from_odom)
283
- # rospy.spin()
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env python3
2
- # coding: utf-8
3
- from kuavo_humanoid_sdk.kuavo.core.audio import KuavoRobotAudioCore
4
-
5
- class KuavoRobotAudio:
6
- """Audio system interface for controlling audio playback functionality of Kuavo humanoid robot.
7
-
8
- Provides functionality to play music files.
9
- """
10
-
11
- def __init__(self):
12
- """Initialize the audio system."""
13
- self.audio = KuavoRobotAudioCore()
14
-
15
- def play_audio(self, file_name: str, volume: float = 0.5, speed: float = 1.0) -> bool:
16
- """Play the specified audio file.
17
-
18
- Args:
19
- file_name (str): Name of the audio file to play
20
-
21
- Returns:
22
- bool: True if the play request was successfully sent, False otherwise
23
- """
24
- return self.audio.play_audio(file_name, volume, speed)
25
-
26
- def stop_music(self):
27
- """Stop the currently playing audio."""
28
- return self.audio.stop_music()
29
-
30
- def text_to_speech(self, text: str, volume: float = 0.5) -> bool:
31
- """Synthesize and play the specified text.
32
-
33
- Args:
34
- text (str): Text to be played
35
-
36
- Returns:
37
- bool: True if the play request was successfully sent, False otherwise
38
- """
39
- return self.audio.text_to_speech(text, volume)
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env python3
2
- # coding: utf-8
3
- import math
4
- from kuavo_humanoid_sdk.common.logger import SDKLogger
5
- from kuavo_humanoid_sdk.interfaces.data_types import (PoseQuaternion, HomogeneousMatrix)
6
- from kuavo_humanoid_sdk.kuavo.core.ros.tools import KuavoRobotToolsCore
7
- from typing import Union
8
-
9
- class KuavoRobotTools:
10
- """Robot tools class providing coordinate frame transformation interfaces.
11
-
12
- This class encapsulates coordinate transformation queries between different robot frames,
13
- supporting multiple return data formats.
14
- """
15
-
16
- def __init__(self):
17
- """Initialize robot tools instance."""
18
- self.tools_core = KuavoRobotToolsCore()
19
-
20
- def get_tf_transform(self, target_frame: str, source_frame: str,
21
- return_type: str = "pose_quaternion") -> Union[PoseQuaternion, HomogeneousMatrix, None]:
22
- """Get transformation between specified coordinate frames.
23
-
24
- Args:
25
- target_frame (str): Name of target coordinate frame
26
- source_frame (str): Name of source coordinate frame
27
- return_type (str, optional): Return data format type. Valid values:
28
- "pose_quaternion" - quaternion pose format,
29
- "homogeneous" - homogeneous matrix format. Defaults to "pose_quaternion".
30
-
31
- Returns:
32
- Union[PoseQuaternion, HomogeneousMatrix, None]:
33
- Transformation data in specified format, or None if failed
34
-
35
- Raises:
36
- ValueError: If invalid return_type is provided
37
- """
38
- return self.tools_core._get_tf_tree_transform(target_frame, source_frame, return_type=return_type)
39
-
40
- def get_base_to_odom(self, return_type: str = "pose_quaternion") -> Union[PoseQuaternion, HomogeneousMatrix, None]:
41
- """Get transformation from base_link to odom frame.
42
-
43
- Args:
44
- return_type (str, optional): Return format type. Same as get_tf_transform.
45
- Defaults to "pose_quaternion".
46
-
47
- Returns:
48
- Union[PoseQuaternion, HomogeneousMatrix, None]: Transformation data or None
49
- """
50
- return self.get_tf_transform("odom", "base_link", return_type)
51
-
52
- def get_camera_to_base(self, return_type: str = "homogeneous") -> Union[PoseQuaternion, HomogeneousMatrix, None]:
53
- """Get transformation from camera_link to base_link frame.
54
-
55
- Args:
56
- return_type (str, optional): Return format type. Same as get_tf_transform.
57
- Defaults to "homogeneous".
58
-
59
- Returns:
60
- Union[PoseQuaternion, HomogeneousMatrix, None]: Transformation data or None
61
- """
62
- return self.get_tf_transform("base_link", "camera_link", return_type)
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env python3
2
- # coding: utf-8
3
- import math
4
- from kuavo_humanoid_sdk.common.logger import SDKLogger
5
- from kuavo_humanoid_sdk.interfaces.data_types import (AprilTagData)
6
- from kuavo_humanoid_sdk.kuavo.core.ros.vision import KuavoRobotVisionCore
7
-
8
- try:
9
- from apriltag_ros.msg import AprilTagDetectionArray
10
- except ImportError:
11
- pass
12
-
13
- class KuavoRobotVision:
14
- """Vision system interface for Kuavo humanoid robot.
15
-
16
- Provides access to AprilTag detection data from different coordinate frames.
17
-
18
- """
19
-
20
- def __init__(self, robot_type: str = "kuavo"):
21
- """Initialize the vision system.
22
-
23
- Args:
24
- robot_type (str, optional): Robot type identifier. Defaults to "kuavo".
25
- """
26
- if not hasattr(self, '_initialized'):
27
- self._vision_core = KuavoRobotVisionCore()
28
-
29
- def get_data_by_id(self, target_id: int, data_source: str = "base") -> dict:
30
- """Get AprilTag detection data for a specific ID from specified source.
31
-
32
- Args:
33
- target_id (int): AprilTag ID to retrieve
34
- data_source (str, optional): Data source frame. Can be "base", "camera",
35
- or "odom". Defaults to "base".
36
-
37
- Returns:
38
- dict: Detection data containing position, orientation and metadata
39
- """
40
- return self._vision_core._get_data_by_id(target_id, data_source)
41
-
42
- def get_data_by_id_from_camera(self, target_id: int) -> dict:
43
- """Get AprilTag data from camera coordinate frame.
44
-
45
- Args:
46
- target_id (int): AprilTag ID to retrieve
47
-
48
- Returns:
49
- dict: See get_data_by_id() for return format
50
- """
51
- return self._vision_core._get_data_by_id(target_id, "camera")
52
-
53
- def get_data_by_id_from_base(self, target_id: int) -> dict:
54
- """Get AprilTag data from base coordinate frame.
55
-
56
- Args:
57
- target_id (int): AprilTag ID to retrieve
58
-
59
- Returns:
60
- dict: See get_data_by_id() for return format
61
- """
62
- return self._vision_core._get_data_by_id(target_id, "base")
63
-
64
- def get_data_by_id_from_odom(self, target_id: int) -> dict:
65
- """Get AprilTag data from odom coordinate frame.
66
-
67
- Args:
68
- target_id (int): AprilTag ID to retrieve
69
-
70
- Returns:
71
- dict: See get_data_by_id() for return format
72
- """
73
- return self._vision_core._get_data_by_id(target_id, "odom")
74
-
75
- @property
76
- def apriltag_data_from_camera(self) -> AprilTagData:
77
- """AprilTagData: All detected AprilTags in camera frame (property)"""
78
- return self._vision_core.apriltag_data_from_camera
79
-
80
- @property
81
- def apriltag_data_from_base(self) -> AprilTagData:
82
- """AprilTagData: All detected AprilTags in camera frame (property)"""
83
- return self._vision_core.apriltag_data_from_base
84
-
85
- @property
86
- def apriltag_data_from_odom(self) -> AprilTagData:
87
- """AprilTagData: All detected AprilTags in camera frame (property)"""
88
- return self._vision_core.apriltag_data_from_odom
89
-
90
-
@@ -1,2 +0,0 @@
1
- from .kuavo_strategy import *
2
- from .grasp_box.grasp_box_strategy import *