Skip to content

Commit 3f80349

Browse files
committed
Force update resource when adding new resource / transfer to another resource
location not passed to ItemizedCarrier when assign child resource Fix size not pass through.
1 parent 0241568 commit 3f80349

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

unilabos/resources/itemized_carrier.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def assign_child_resource(
149149

150150
if not reassign and self.sites[idx] is not None:
151151
raise ValueError(f"a site with index {idx} already exists")
152+
location = list(self.child_locations.values())[idx]
152153
super().assign_child_resource(resource, location=location, reassign=reassign)
153154
self.sites[idx] = resource
154155

unilabos/resources/resource_tracker.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515

1616
class ResourceDictPositionSize(BaseModel):
17-
depth: float = Field(description="Depth", default=0.0)
18-
width: float = Field(description="Width", default=0.0)
19-
height: float = Field(description="Height", default=0.0)
17+
depth: float = Field(description="Depth", default=0.0) # z
18+
width: float = Field(description="Width", default=0.0) # x
19+
height: float = Field(description="Height", default=0.0) # y
2020

2121

2222
class ResourceDictPositionScale(BaseModel):
@@ -469,9 +469,9 @@ def node_to_plr_dict(node: ResourceDictInstance, has_model: bool):
469469
**res.config,
470470
"name": res.name,
471471
"type": res.config.get("type", plr_type),
472-
"size_x": res.config.get("size_x", 0),
473-
"size_y": res.config.get("size_y", 0),
474-
"size_z": res.config.get("size_z", 0),
472+
"size_x": res.pose.size.width,
473+
"size_y": res.pose.size.height,
474+
"size_z": res.pose.size.depth,
475475
"location": {
476476
"x": res.pose.position.x,
477477
"y": res.pose.position.y,

unilabos/ros/nodes/base_device_node.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,13 @@ def _handle_update(
881881
raise ValueError("tree_set不能为None")
882882
plr_resources = tree_set.to_plr_resources()
883883
result = _handle_add(plr_resources, tree_set, additional_add_params)
884+
new_tree_set = ResourceTreeSet.from_plr_resources(plr_resources)
885+
r = SerialCommand.Request()
886+
r.command = json.dumps(
887+
{"data": {"data": new_tree_set.dump()}, "action": "update"}) # 和Update Resource一致
888+
response: SerialCommand_Response = await self._resource_clients[
889+
"c2s_update_resource_tree"].call_async(r) # type: ignore
890+
self.lab_logger().info(f"确认资源云端 Add 结果: {response.response}")
884891
results.append(result)
885892
elif action == "update":
886893
if tree_set is None:
@@ -1758,6 +1765,7 @@ def __init__(
17581765
or driver_class.__name__ == "LiquidHandlerBiomek"
17591766
or driver_class.__name__ == "PRCXI9300Handler"
17601767
or driver_class.__name__ == "TransformXYZHandler"
1768+
or driver_class.__name__ == "OpcUaClient"
17611769
)
17621770

17631771
# 创建设备类实例

0 commit comments

Comments
 (0)