kuavo-humanoid-sdk 1.1.2a924__py3-none-any.whl → 1.1.3a1239__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.
- kuavo_humanoid_sdk/common/global_config.py +15 -0
- kuavo_humanoid_sdk/common/websocket_kuavo_sdk.py +23 -0
- kuavo_humanoid_sdk/interfaces/data_types.py +46 -0
- kuavo_humanoid_sdk/kuavo/__init__.py +3 -0
- kuavo_humanoid_sdk/kuavo/core/audio.py +32 -0
- kuavo_humanoid_sdk/kuavo/core/core.py +17 -6
- kuavo_humanoid_sdk/kuavo/core/ros/audio.py +93 -0
- kuavo_humanoid_sdk/kuavo/core/ros/control.py +645 -19
- kuavo_humanoid_sdk/kuavo/core/ros/param.py +142 -4
- kuavo_humanoid_sdk/kuavo/core/ros/state.py +329 -15
- kuavo_humanoid_sdk/kuavo/core/ros/tools.py +158 -0
- kuavo_humanoid_sdk/kuavo/core/ros/vision.py +276 -0
- kuavo_humanoid_sdk/kuavo/core/ros_env.py +229 -1
- kuavo_humanoid_sdk/kuavo/dexterous_hand.py +6 -2
- kuavo_humanoid_sdk/kuavo/leju_claw.py +6 -2
- kuavo_humanoid_sdk/kuavo/robot.py +43 -22
- kuavo_humanoid_sdk/kuavo/robot_audio.py +39 -0
- kuavo_humanoid_sdk/kuavo/robot_info.py +7 -2
- kuavo_humanoid_sdk/kuavo/robot_state.py +6 -2
- kuavo_humanoid_sdk/kuavo/robot_tool.py +62 -0
- kuavo_humanoid_sdk/kuavo/robot_vision.py +90 -0
- kuavo_humanoid_sdk/msg/kuavo_msgs/msg/_AprilTagDetection.py +306 -0
- kuavo_humanoid_sdk/msg/kuavo_msgs/msg/_AprilTagDetectionArray.py +437 -0
- kuavo_humanoid_sdk/msg/kuavo_msgs/msg/__init__.py +9 -0
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/msg/_armHandPose.py +2 -2
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/msg/_handPose.py +2 -2
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/msg/_ikSolveError.py +13 -13
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/msg/_ikSolveParam.py +2 -2
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/msg/_robotArmQVVD.py +2 -2
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/msg/_twoArmHandPose.py +13 -13
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/msg/_twoArmHandPoseCmd.py +15 -15
- kuavo_humanoid_sdk/msg/kuavo_msgs/srv/_SpeechSynthesis.py +270 -0
- kuavo_humanoid_sdk/msg/kuavo_msgs/srv/__init__.py +5 -0
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/srv/_changeArmCtrlModeKuavo.py +5 -5
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/srv/_fkSrv.py +13 -13
- kuavo_humanoid_sdk/msg/{motion_capture_ik/srv/_changeArmCtrlMode.py → kuavo_msgs/srv/_playmusic.py} +97 -98
- kuavo_humanoid_sdk/msg/{motion_capture_ik → kuavo_msgs}/srv/_twoArmHandPoseCmdSrv.py +23 -23
- {kuavo_humanoid_sdk-1.1.2a924.dist-info → kuavo_humanoid_sdk-1.1.3a1239.dist-info}/METADATA +2 -1
- {kuavo_humanoid_sdk-1.1.2a924.dist-info → kuavo_humanoid_sdk-1.1.3a1239.dist-info}/RECORD +41 -33
- kuavo_humanoid_sdk/msg/motion_capture_ik/msg/__init__.py +0 -9
- kuavo_humanoid_sdk/msg/motion_capture_ik/msg/_headBodyPose.py +0 -145
- kuavo_humanoid_sdk/msg/motion_capture_ik/msg/_robotHandPosition.py +0 -225
- kuavo_humanoid_sdk/msg/motion_capture_ik/srv/__init__.py +0 -4
- {kuavo_humanoid_sdk-1.1.2a924.dist-info → kuavo_humanoid_sdk-1.1.3a1239.dist-info}/WHEEL +0 -0
- {kuavo_humanoid_sdk-1.1.2a924.dist-info → kuavo_humanoid_sdk-1.1.3a1239.dist-info}/top_level.txt +0 -0
|
@@ -4,7 +4,8 @@ from typing import Tuple
|
|
|
4
4
|
from kuavo_humanoid_sdk.interfaces.end_effector import EndEffector
|
|
5
5
|
from kuavo_humanoid_sdk.interfaces.data_types import EndEffectorSide, EndEffectorState, KuavoDexHandTouchState
|
|
6
6
|
from kuavo_humanoid_sdk.kuavo.core.dex_hand_control import DexHandControl
|
|
7
|
-
from kuavo_humanoid_sdk.kuavo.core.ros.state import KuavoRobotStateCore
|
|
7
|
+
from kuavo_humanoid_sdk.kuavo.core.ros.state import KuavoRobotStateCore, KuavoRobotStateCoreWebsocket
|
|
8
|
+
from kuavo_humanoid_sdk.common.global_config import GlobalConfig
|
|
8
9
|
|
|
9
10
|
class DexterousHand(EndEffector):
|
|
10
11
|
def __init__(self):
|
|
@@ -12,7 +13,10 @@ class DexterousHand(EndEffector):
|
|
|
12
13
|
'r_thumb', 'r_thumb_aux', 'r_index', 'r_middle', 'r_ring', 'r_pinky',]
|
|
13
14
|
super().__init__(joint_names=joint_names)
|
|
14
15
|
self.dex_hand_control = DexHandControl()
|
|
15
|
-
|
|
16
|
+
if GlobalConfig.use_websocket:
|
|
17
|
+
self._rb_state = KuavoRobotStateCoreWebsocket()
|
|
18
|
+
else:
|
|
19
|
+
self._rb_state = KuavoRobotStateCore()
|
|
16
20
|
|
|
17
21
|
def control(self, target_positions:list, target_velocities:list=None, target_torques:list=None)->bool:
|
|
18
22
|
"""Set the position of the hand.
|
|
@@ -5,13 +5,17 @@ from typing import Tuple
|
|
|
5
5
|
from kuavo_humanoid_sdk.interfaces.end_effector import EndEffector
|
|
6
6
|
from kuavo_humanoid_sdk.interfaces.data_types import EndEffectorSide, EndEffectorState
|
|
7
7
|
from kuavo_humanoid_sdk.kuavo.core.leju_claw_control import LejuClawControl
|
|
8
|
-
from kuavo_humanoid_sdk.kuavo.core.ros.state import KuavoRobotStateCore
|
|
8
|
+
from kuavo_humanoid_sdk.kuavo.core.ros.state import KuavoRobotStateCore, KuavoRobotStateCoreWebsocket
|
|
9
|
+
from kuavo_humanoid_sdk.common.global_config import GlobalConfig
|
|
9
10
|
|
|
10
11
|
class LejuClaw(EndEffector):
|
|
11
12
|
def __init__(self):
|
|
12
13
|
super().__init__(joint_names=['left_claw', 'right_claw'])
|
|
13
14
|
self.leju_claw_control = LejuClawControl()
|
|
14
|
-
|
|
15
|
+
if GlobalConfig.use_websocket:
|
|
16
|
+
self._rb_state = KuavoRobotStateCoreWebsocket()
|
|
17
|
+
else:
|
|
18
|
+
self._rb_state = KuavoRobotStateCore()
|
|
15
19
|
|
|
16
20
|
def control(self, target_positions: list, target_velocities:list=None, target_torques: list=None)->bool:
|
|
17
21
|
"""Control the claws to grip.
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
# coding: utf-8
|
|
3
|
-
from kuavo_humanoid_sdk.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
from kuavo_humanoid_sdk.common.logger import SDKLogger, disable_sdk_logging
|
|
3
|
+
from kuavo_humanoid_sdk.common.global_config import GlobalConfig
|
|
4
|
+
|
|
5
|
+
from kuavo_humanoid_sdk.kuavo.core.ros_env import KuavoROSEnv, KuavoROSEnvWebsocket
|
|
6
|
+
from kuavo_humanoid_sdk.interfaces.robot import RobotBase
|
|
7
|
+
from kuavo_humanoid_sdk.common.logger import SDKLogger, disable_sdk_logging
|
|
8
|
+
from kuavo_humanoid_sdk.interfaces.data_types import KuavoPose, KuavoIKParams
|
|
9
|
+
from kuavo_humanoid_sdk.kuavo.core.core import KuavoRobotCore
|
|
10
|
+
|
|
11
|
+
from typing import Tuple
|
|
12
|
+
from kuavo_humanoid_sdk.kuavo.robot_info import KuavoRobotInfo
|
|
13
|
+
from kuavo_humanoid_sdk.kuavo.robot_arm import KuavoRobotArm
|
|
14
|
+
from kuavo_humanoid_sdk.kuavo.robot_head import KuavoRobotHead
|
|
16
15
|
|
|
17
16
|
"""
|
|
18
17
|
Kuavo SDK - Python Interface for Kuavo Robot Control
|
|
@@ -45,19 +44,30 @@ class KuavoSDK:
|
|
|
45
44
|
pass
|
|
46
45
|
|
|
47
46
|
@staticmethod
|
|
48
|
-
def Init(options:int=Options.Normal, log_level: str = "INFO"
|
|
47
|
+
def Init(options:int=Options.Normal, log_level: str = "INFO",
|
|
48
|
+
websocket_mode: bool = False, websocket_host='127.0.0.1', websocket_port=9090, websocket_timeout=5)-> bool:
|
|
49
49
|
"""Initialize the SDK.
|
|
50
|
-
|
|
51
50
|
Args:
|
|
52
51
|
log_level (str): The logging level to use. Can be "ERROR", "WARN", "INFO", "DEBUG".
|
|
53
52
|
Defaults to "INFO".
|
|
54
|
-
|
|
53
|
+
websocket_mode (bool): Whether to use websocket mode for ROS communication. If True,
|
|
54
|
+
the SDK will connect to ROS through websocket instead of direct ROS connection.
|
|
55
|
+
Defaults to False.
|
|
56
|
+
websocket_host (str): The host address of the rosbridge websocket server when using
|
|
57
|
+
websocket mode. Defaults to "127.0.0.1".
|
|
58
|
+
websocket_port (int): The port number of the rosbridge websocket server when using
|
|
59
|
+
websocket mode. Defaults to 9090.
|
|
60
|
+
websocket_timeout (int): The timeout for the websocket connection. Defaults to 5.
|
|
55
61
|
Returns:
|
|
56
62
|
bool: True if initialization is successful, False otherwise.
|
|
57
63
|
|
|
58
64
|
Raises:
|
|
59
65
|
RuntimeError: If the initialization fails.
|
|
60
66
|
"""
|
|
67
|
+
GlobalConfig.use_websocket = websocket_mode
|
|
68
|
+
GlobalConfig.websocket_host = websocket_host
|
|
69
|
+
GlobalConfig.websocket_port = websocket_port
|
|
70
|
+
GlobalConfig.websocket_timeout = websocket_timeout
|
|
61
71
|
SDKLogger.setLevel(log_level.upper())
|
|
62
72
|
# Initialize core components, connect ROS Topics...
|
|
63
73
|
kuavo_core = KuavoRobotCore()
|
|
@@ -65,12 +75,18 @@ class KuavoSDK:
|
|
|
65
75
|
debug = True
|
|
66
76
|
else:
|
|
67
77
|
debug = False
|
|
68
|
-
|
|
69
78
|
# Check if IK option is enabled
|
|
70
|
-
if
|
|
71
|
-
if
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
if GlobalConfig.use_websocket:
|
|
80
|
+
if options & KuavoSDK.Options.WithIK:
|
|
81
|
+
if not KuavoROSEnvWebsocket.check_rosnode_exists('/arms_ik_node'):
|
|
82
|
+
print("\033[31m\nError:WithIK option is enabled but ik_node is not running, please run `roslaunch motion_capture_ik ik_node.launch`\033[0m")
|
|
83
|
+
exit(1)
|
|
84
|
+
else:
|
|
85
|
+
if options & KuavoSDK.Options.WithIK:
|
|
86
|
+
if not KuavoROSEnv.check_rosnode_exists('/arms_ik_node'):
|
|
87
|
+
print("\033[31m\nError:WithIK option is enabled but ik_node is not running, please run `roslaunch motion_capture_ik ik_node.launch`\033[0m")
|
|
88
|
+
exit(1)
|
|
89
|
+
|
|
74
90
|
|
|
75
91
|
if not kuavo_core.initialize(debug=debug):
|
|
76
92
|
SDKLogger.error("[SDK] Failed to initialize core components.")
|
|
@@ -86,11 +102,16 @@ class KuavoSDK:
|
|
|
86
102
|
class KuavoRobot(RobotBase):
|
|
87
103
|
def __init__(self):
|
|
88
104
|
super().__init__(robot_type="kuavo")
|
|
105
|
+
|
|
106
|
+
if not GlobalConfig.use_websocket:
|
|
107
|
+
kuavo_ros_env = KuavoROSEnv()
|
|
108
|
+
if not kuavo_ros_env.Init():
|
|
109
|
+
raise RuntimeError("Failed to initialize ROS environment")
|
|
110
|
+
|
|
89
111
|
self._robot_info = KuavoRobotInfo()
|
|
90
112
|
self._robot_arm = KuavoRobotArm()
|
|
91
113
|
self._robot_head = KuavoRobotHead()
|
|
92
114
|
self._kuavo_core = KuavoRobotCore()
|
|
93
|
-
|
|
94
115
|
def stance(self)->bool:
|
|
95
116
|
"""Put the robot into 'stance' mode.
|
|
96
117
|
|
|
@@ -0,0 +1,39 @@
|
|
|
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)
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
# coding: utf-8
|
|
3
3
|
from typing import Tuple
|
|
4
4
|
from kuavo_humanoid_sdk.interfaces.robot_info import RobotInfoBase
|
|
5
|
-
from kuavo_humanoid_sdk.kuavo.core.ros.param import RosParameter, make_robot_param
|
|
5
|
+
from kuavo_humanoid_sdk.kuavo.core.ros.param import RosParameter, RosParamWebsocket, make_robot_param
|
|
6
|
+
from kuavo_humanoid_sdk.common.global_config import GlobalConfig
|
|
6
7
|
|
|
7
8
|
class KuavoRobotInfo(RobotInfoBase):
|
|
8
9
|
def __init__(self, robot_type: str = "kuavo"):
|
|
@@ -10,7 +11,11 @@ class KuavoRobotInfo(RobotInfoBase):
|
|
|
10
11
|
|
|
11
12
|
# Load robot parameters from ROS parameter server
|
|
12
13
|
kuavo_ros_param = make_robot_param()
|
|
13
|
-
|
|
14
|
+
if GlobalConfig.use_websocket:
|
|
15
|
+
self._ros_param = RosParamWebsocket()
|
|
16
|
+
else:
|
|
17
|
+
self._ros_param = RosParameter()
|
|
18
|
+
|
|
14
19
|
self._robot_version = kuavo_ros_param['robot_version']
|
|
15
20
|
self._end_effector_type = kuavo_ros_param['end_effector_type']
|
|
16
21
|
self._arm_joint_dof = kuavo_ros_param['arm_dof']
|
|
@@ -4,11 +4,15 @@ import time
|
|
|
4
4
|
from typing import Tuple
|
|
5
5
|
from kuavo_humanoid_sdk.interfaces.data_types import (
|
|
6
6
|
KuavoImuData, KuavoJointData, KuavoOdometry, KuavoArmCtrlMode,EndEffectorState)
|
|
7
|
-
from kuavo_humanoid_sdk.kuavo.core.ros.state import KuavoRobotStateCore
|
|
7
|
+
from kuavo_humanoid_sdk.kuavo.core.ros.state import KuavoRobotStateCore, KuavoRobotStateCoreWebsocket
|
|
8
|
+
from kuavo_humanoid_sdk.common.global_config import GlobalConfig
|
|
8
9
|
|
|
9
10
|
class KuavoRobotState:
|
|
10
11
|
def __init__(self, robot_type: str = "kuavo"):
|
|
11
|
-
|
|
12
|
+
if GlobalConfig.use_websocket:
|
|
13
|
+
self._rs_core = KuavoRobotStateCoreWebsocket()
|
|
14
|
+
else:
|
|
15
|
+
self._rs_core = KuavoRobotStateCore()
|
|
12
16
|
|
|
13
17
|
@property
|
|
14
18
|
def imu_data(self) -> KuavoImuData:
|
|
@@ -0,0 +1,62 @@
|
|
|
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)
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
|