mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
修复protocolnode的兼容性
This commit is contained in:
@@ -6024,156 +6024,18 @@ workstation:
|
||||
title: WashSolid
|
||||
type: object
|
||||
type: WashSolid
|
||||
auto-create_ros_action_server:
|
||||
feedback: {}
|
||||
goal: {}
|
||||
goal_default:
|
||||
action_name: null
|
||||
action_value_mapping: null
|
||||
handles: {}
|
||||
result: {}
|
||||
schema:
|
||||
description: create_ros_action_server的参数schema
|
||||
properties:
|
||||
feedback: {}
|
||||
goal:
|
||||
properties:
|
||||
action_name:
|
||||
type: string
|
||||
action_value_mapping:
|
||||
type: string
|
||||
required:
|
||||
- action_name
|
||||
- action_value_mapping
|
||||
type: object
|
||||
result: {}
|
||||
required:
|
||||
- goal
|
||||
title: create_ros_action_server参数
|
||||
type: object
|
||||
type: UniLabJsonCommand
|
||||
auto-execute_single_action:
|
||||
feedback: {}
|
||||
goal: {}
|
||||
goal_default:
|
||||
action_kwargs: null
|
||||
action_name: null
|
||||
device_id: null
|
||||
handles: {}
|
||||
result: {}
|
||||
schema:
|
||||
description: execute_single_action的参数schema
|
||||
properties:
|
||||
feedback: {}
|
||||
goal:
|
||||
properties:
|
||||
action_kwargs:
|
||||
type: string
|
||||
action_name:
|
||||
type: string
|
||||
device_id:
|
||||
type: string
|
||||
required:
|
||||
- device_id
|
||||
- action_name
|
||||
- action_kwargs
|
||||
type: object
|
||||
result: {}
|
||||
required:
|
||||
- goal
|
||||
title: execute_single_action参数
|
||||
type: object
|
||||
type: UniLabJsonCommandAsync
|
||||
auto-initialize_device:
|
||||
feedback: {}
|
||||
goal: {}
|
||||
goal_default:
|
||||
device_config: null
|
||||
device_id: null
|
||||
handles: {}
|
||||
result: {}
|
||||
schema:
|
||||
description: initialize_device的参数schema
|
||||
properties:
|
||||
feedback: {}
|
||||
goal:
|
||||
properties:
|
||||
device_config:
|
||||
type: string
|
||||
device_id:
|
||||
type: string
|
||||
required:
|
||||
- device_id
|
||||
- device_config
|
||||
type: object
|
||||
result: {}
|
||||
required:
|
||||
- goal
|
||||
title: initialize_device参数
|
||||
type: object
|
||||
type: UniLabJsonCommand
|
||||
module: unilabos.ros.nodes.presets.workstation:ROS2WorkstationNode
|
||||
module: unilabos.devices.workstation.workstation_base:ProtocolNode
|
||||
status_types: {}
|
||||
type: ros2
|
||||
type: python
|
||||
config_info: []
|
||||
description: Workstation
|
||||
handles: []
|
||||
icon: ''
|
||||
init_param_schema:
|
||||
config:
|
||||
properties:
|
||||
action_value_mappings:
|
||||
type: object
|
||||
children:
|
||||
type: object
|
||||
device_id:
|
||||
type: string
|
||||
driver_instance:
|
||||
type: string
|
||||
hardware_interface:
|
||||
type: object
|
||||
print_publish:
|
||||
default: true
|
||||
type: string
|
||||
protocol_type:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
resource_tracker:
|
||||
type: string
|
||||
status_types:
|
||||
type: object
|
||||
required:
|
||||
- protocol_type
|
||||
- children
|
||||
- driver_instance
|
||||
- device_id
|
||||
- status_types
|
||||
- action_value_mappings
|
||||
- hardware_interface
|
||||
type: object
|
||||
data:
|
||||
properties: {}
|
||||
required: []
|
||||
type: object
|
||||
version: 1.0.0
|
||||
workstation.example:
|
||||
category:
|
||||
- work_station
|
||||
class:
|
||||
action_value_mappings: {}
|
||||
module: unilabos.devices.workstation.workstation_base:WorkstationExample
|
||||
status_types: {}
|
||||
type: ros2
|
||||
config_info: []
|
||||
description: Example Workstation
|
||||
handles: []
|
||||
icon: ''
|
||||
init_param_schema:
|
||||
config:
|
||||
properties:
|
||||
station_resource:
|
||||
type: object
|
||||
type: string
|
||||
required:
|
||||
- station_resource
|
||||
type: object
|
||||
|
||||
@@ -19,6 +19,9 @@ from unilabos.utils.type_check import NoAliasDumper
|
||||
|
||||
DEFAULT_PATHS = [Path(__file__).absolute().parent]
|
||||
|
||||
class ROSMsgNotFound(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@singleton
|
||||
class Registry:
|
||||
@@ -308,7 +311,7 @@ class Registry:
|
||||
return type_class
|
||||
else:
|
||||
logger.error(f"[UniLab Registry] 无法找到类型 '{type_name}' 用于设备 {device_id} 的 {field_name}")
|
||||
sys.exit(1)
|
||||
raise ROSMsgNotFound(f"类型 '{type_name}' 未找到,用于设备 {device_id} 的 {field_name}")
|
||||
|
||||
def _get_json_schema_type(self, type_str: str) -> str:
|
||||
"""
|
||||
@@ -495,7 +498,10 @@ class Registry:
|
||||
if isinstance(status_type, tuple) or status_type in ["Any", "None", "Unknown"]:
|
||||
status_type = "String" # 替换成ROS的String,便于显示
|
||||
device_config["class"]["status_types"][status_name] = status_type
|
||||
target_type = self._replace_type_with_class(status_type, device_id, f"状态 {status_name}")
|
||||
try:
|
||||
target_type = self._replace_type_with_class(status_type, device_id, f"状态 {status_name}")
|
||||
except ROSMsgNotFound:
|
||||
continue
|
||||
if target_type in [
|
||||
dict,
|
||||
list,
|
||||
@@ -568,9 +574,12 @@ class Registry:
|
||||
action_type_str: str = action_config["type"]
|
||||
# 通过Json发放指令,而不是通过特殊的ros action进行处理
|
||||
if not action_type_str.startswith("UniLabJsonCommand"):
|
||||
target_type = self._replace_type_with_class(
|
||||
action_type_str, device_id, f"动作 {action_name}"
|
||||
)
|
||||
try:
|
||||
target_type = self._replace_type_with_class(
|
||||
action_type_str, device_id, f"动作 {action_name}"
|
||||
)
|
||||
except ROSMsgNotFound:
|
||||
continue
|
||||
action_str_type_mapping[action_type_str] = target_type
|
||||
if target_type is not None:
|
||||
action_config["goal_default"] = yaml.safe_load(
|
||||
|
||||
Reference in New Issue
Block a user