mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-06 15:05:13 +00:00
Dev backward (#228)
* Workbench example, adjust log level, and ci check (#220)
* TestLatency Return Value Example & gitignore update
* Adjust log level & Add workbench virtual example & Add not action decorator & Add check_mode &
* Add CI Check
* CI Check Fix 1
* CI Check Fix 2
* CI Check Fix 3
* CI Check Fix 4
* CI Check Fix 5
* Upgrade to py 3.11.14; ros 0.7; unilabos 0.10.16
* Update to ROS2 Humble 0.7
* Fix Build 1
* Fix Build 2
* Fix Build 3
* Fix Build 4
* Fix Build 5
* Fix Build 6
* Fix Build 7
* ci(deps): bump actions/configure-pages from 4 to 5 (#222)
Bumps [actions/configure-pages](https://github.com/actions/configure-pages) from 4 to 5.
- [Release notes](https://github.com/actions/configure-pages/releases)
- [Commits](https://github.com/actions/configure-pages/compare/v4...v5)
---
updated-dependencies:
- dependency-name: actions/configure-pages
dependency-version: '5'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* ci(deps): bump actions/upload-artifact from 4 to 6 (#224)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v6)
---
updated-dependencies:
- dependency-name: actions/upload-artifact
dependency-version: '6'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* ci(deps): bump actions/upload-pages-artifact from 3 to 4 (#225)
Bumps [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-pages-artifact/releases)
- [Commits](https://github.com/actions/upload-pages-artifact/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/upload-pages-artifact
dependency-version: '4'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* ci(deps): bump actions/checkout from 4 to 6 (#223)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)
---
updated-dependencies:
- dependency-name: actions/checkout
dependency-version: '6'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Fix Build 8
* Fix Build 9
* Fix Build 10
* Fix Build 11
* Fix Build 12
* Fix Build 13
* v0.10.17
(cherry picked from commit 176de521b4)
* CI Check use production mode
* Fix OT2 & ReAdd Virtual Devices
* add msg goal
* transfer liquid handles
* gather query
* add unilabos_class
* Support root node change pos
* save class name when deserialize & protocol execute test
* fix upload workflow json
* workflow upload & set liquid fix & add set liquid with plate
* speed up registry load
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: hanhua@dp.tech <2509856570@qq.com>
This commit is contained in:
@@ -5,7 +5,8 @@ import threading
|
||||
import time
|
||||
import traceback
|
||||
import uuid
|
||||
from typing import TYPE_CHECKING, Optional, Dict, Any, List, ClassVar, Set, TypedDict, Union
|
||||
from typing import TYPE_CHECKING, Optional, Dict, Any, List, ClassVar, Set, Union
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from action_msgs.msg import GoalStatus
|
||||
from geometry_msgs.msg import Point
|
||||
@@ -62,6 +63,18 @@ class TestResourceReturn(TypedDict):
|
||||
devices: List[DeviceSlot]
|
||||
|
||||
|
||||
class TestLatencyReturn(TypedDict):
|
||||
"""test_latency方法的返回值类型"""
|
||||
|
||||
avg_rtt_ms: float
|
||||
avg_time_diff_ms: float
|
||||
max_time_error_ms: float
|
||||
task_delay_ms: float
|
||||
raw_delay_ms: float
|
||||
test_count: int
|
||||
status: str
|
||||
|
||||
|
||||
class HostNode(BaseROS2DeviceNode):
|
||||
"""
|
||||
主机节点类,负责管理设备、资源和控制器
|
||||
@@ -795,6 +808,7 @@ class HostNode(BaseROS2DeviceNode):
|
||||
goal_msg = convert_to_ros_msg(action_client._action_type.Goal(), action_kwargs)
|
||||
|
||||
self.lab_logger().info(f"[Host Node] Sending goal for {action_id}: {str(goal_msg)[:1000]}")
|
||||
self.lab_logger().trace(f"[Host Node] Sending goal for {action_id}: {action_kwargs}")
|
||||
self.lab_logger().trace(f"[Host Node] Sending goal for {action_id}: {goal_msg}")
|
||||
action_client.wait_for_server()
|
||||
goal_uuid_obj = UUID(uuid=list(u.bytes))
|
||||
@@ -853,8 +867,13 @@ class HostNode(BaseROS2DeviceNode):
|
||||
# 适配后端的一些额外处理
|
||||
return_value = return_info.get("return_value")
|
||||
if isinstance(return_value, dict):
|
||||
unilabos_samples = return_info.get("unilabos_samples")
|
||||
if isinstance(unilabos_samples, list):
|
||||
unilabos_samples = return_value.pop("unilabos_samples", None)
|
||||
if isinstance(unilabos_samples, list) and unilabos_samples:
|
||||
self.lab_logger().info(
|
||||
f"[Host Node] Job {job_id[:8]} returned {len(unilabos_samples)} sample(s): "
|
||||
f"{[s.get('name', s.get('id', 'unknown')) if isinstance(s, dict) else str(s)[:20] for s in unilabos_samples[:5]]}"
|
||||
f"{'...' if len(unilabos_samples) > 5 else ''}"
|
||||
)
|
||||
return_info["unilabos_samples"] = unilabos_samples
|
||||
suc = return_info.get("suc", False)
|
||||
if not suc:
|
||||
@@ -881,7 +900,7 @@ class HostNode(BaseROS2DeviceNode):
|
||||
# 清理 _goals 中的记录
|
||||
if job_id in self._goals:
|
||||
del self._goals[job_id]
|
||||
self.lab_logger().debug(f"[Host Node] Removed goal {job_id[:8]} from _goals")
|
||||
self.lab_logger().trace(f"[Host Node] Removed goal {job_id[:8]} from _goals")
|
||||
|
||||
# 存储结果供 HTTP API 查询
|
||||
try:
|
||||
@@ -1326,10 +1345,20 @@ class HostNode(BaseROS2DeviceNode):
|
||||
self.lab_logger().debug(f"[Host Node-Resource] List parameters: {request}")
|
||||
return response
|
||||
|
||||
def test_latency(self):
|
||||
def test_latency(self) -> TestLatencyReturn:
|
||||
"""
|
||||
测试网络延迟的action实现
|
||||
通过5次ping-pong机制校对时间误差并计算实际延迟
|
||||
|
||||
Returns:
|
||||
TestLatencyReturn: 包含延迟测试结果的字典,包括:
|
||||
- avg_rtt_ms: 平均往返时间(毫秒)
|
||||
- avg_time_diff_ms: 平均时间差(毫秒)
|
||||
- max_time_error_ms: 最大时间误差(毫秒)
|
||||
- task_delay_ms: 实际任务延迟(毫秒),-1表示无法计算
|
||||
- raw_delay_ms: 原始时间差(毫秒),-1表示无法计算
|
||||
- test_count: 有效测试次数
|
||||
- status: 测试状态,"success"表示成功,"all_timeout"表示全部超时
|
||||
"""
|
||||
import uuid as uuid_module
|
||||
|
||||
@@ -1392,7 +1421,15 @@ class HostNode(BaseROS2DeviceNode):
|
||||
|
||||
if not ping_results:
|
||||
self.lab_logger().error("❌ 所有ping-pong测试都失败了")
|
||||
return {"status": "all_timeout"}
|
||||
return {
|
||||
"avg_rtt_ms": -1.0,
|
||||
"avg_time_diff_ms": -1.0,
|
||||
"max_time_error_ms": -1.0,
|
||||
"task_delay_ms": -1.0,
|
||||
"raw_delay_ms": -1.0,
|
||||
"test_count": 0,
|
||||
"status": "all_timeout",
|
||||
}
|
||||
|
||||
# 统计分析
|
||||
rtts = [r["rtt_ms"] for r in ping_results]
|
||||
@@ -1400,7 +1437,7 @@ class HostNode(BaseROS2DeviceNode):
|
||||
|
||||
avg_rtt_ms = sum(rtts) / len(rtts)
|
||||
avg_time_diff_ms = sum(time_diffs) / len(time_diffs)
|
||||
max_time_diff_error_ms = max(abs(min(time_diffs)), abs(max(time_diffs)))
|
||||
max_time_diff_error_ms: float = max(abs(min(time_diffs)), abs(max(time_diffs)))
|
||||
|
||||
self.lab_logger().info("-" * 50)
|
||||
self.lab_logger().info("[测试统计]")
|
||||
@@ -1440,7 +1477,7 @@ class HostNode(BaseROS2DeviceNode):
|
||||
|
||||
self.lab_logger().info("=" * 60)
|
||||
|
||||
return {
|
||||
res: TestLatencyReturn = {
|
||||
"avg_rtt_ms": avg_rtt_ms,
|
||||
"avg_time_diff_ms": avg_time_diff_ms,
|
||||
"max_time_error_ms": max_time_diff_error_ms,
|
||||
@@ -1451,9 +1488,14 @@ class HostNode(BaseROS2DeviceNode):
|
||||
"test_count": len(ping_results),
|
||||
"status": "success",
|
||||
}
|
||||
return res
|
||||
|
||||
def test_resource(
|
||||
self, resource: ResourceSlot = None, resources: List[ResourceSlot] = None, device: DeviceSlot = None, devices: List[DeviceSlot] = None
|
||||
self,
|
||||
resource: ResourceSlot = None,
|
||||
resources: List[ResourceSlot] = None,
|
||||
device: DeviceSlot = None,
|
||||
devices: List[DeviceSlot] = None,
|
||||
) -> TestResourceReturn:
|
||||
if resources is None:
|
||||
resources = []
|
||||
@@ -1514,7 +1556,9 @@ class HostNode(BaseROS2DeviceNode):
|
||||
|
||||
# 构建服务地址
|
||||
srv_address = f"/srv{namespace}/s2c_resource_tree"
|
||||
self.lab_logger().trace(f"[Host Node-Resource] Host -> {device_id} ResourceTree {action} operation started -------")
|
||||
self.lab_logger().trace(
|
||||
f"[Host Node-Resource] Host -> {device_id} ResourceTree {action} operation started -------"
|
||||
)
|
||||
|
||||
# 创建服务客户端
|
||||
sclient = self.create_client(SerialCommand, srv_address)
|
||||
@@ -1549,7 +1593,9 @@ class HostNode(BaseROS2DeviceNode):
|
||||
time.sleep(0.05)
|
||||
|
||||
response = future.result()
|
||||
self.lab_logger().trace(f"[Host Node-Resource] Host -> {device_id} ResourceTree {action} operation completed -------")
|
||||
self.lab_logger().trace(
|
||||
f"[Host Node-Resource] Host -> {device_id} ResourceTree {action} operation completed -------"
|
||||
)
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user