From 903bbe44c2a7504ef6c61737e95afec3e074c529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=BCller?= Date: Sun, 22 Dec 2024 10:07:11 +0000 Subject: [PATCH 1/3] Ignore objects that are currently carried by other robots when resolving possible objects to pick --- pyrobosim/pyrobosim/utils/knowledge.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pyrobosim/pyrobosim/utils/knowledge.py b/pyrobosim/pyrobosim/utils/knowledge.py index 8ce9f7e5..42322a08 100644 --- a/pyrobosim/pyrobosim/utils/knowledge.py +++ b/pyrobosim/pyrobosim/utils/knowledge.py @@ -340,12 +340,16 @@ def resolve_to_object( obj for obj in possible_objects if ( - obj.parent == location - or obj.parent.name == location - or obj.parent.parent == location - or obj.parent.parent.name == location - or obj.parent.category == location - or obj.parent.parent.category == location + # Check whether the parent is a robot performing further checks + hasattr(obj.parent, "parent") + and ( + obj.parent == location + or obj.parent.name == location + or obj.parent.parent == location + or obj.parent.parent.name == location + or obj.parent.category == location + or obj.parent.parent.category == location + ) ) ] From 1958b1c43eb452a3c7bc29177cac74cb0a21ee24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=BCller?= Date: Sun, 22 Dec 2024 11:22:16 +0000 Subject: [PATCH 2/3] Add robot check also to room filter --- pyrobosim/pyrobosim/utils/knowledge.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyrobosim/pyrobosim/utils/knowledge.py b/pyrobosim/pyrobosim/utils/knowledge.py index 42322a08..fc6ef63a 100644 --- a/pyrobosim/pyrobosim/utils/knowledge.py +++ b/pyrobosim/pyrobosim/utils/knowledge.py @@ -332,7 +332,11 @@ def resolve_to_object( possible_objects = [ obj for obj in possible_objects - if obj.parent.parent.parent.name == room_name + if ( + # Check whether the parent is a robot before performing further checks + hasattr(obj.parent, "parent") + and obj.parent.parent.parent.name == room_name + ) ] if location is not None: @@ -340,7 +344,7 @@ def resolve_to_object( obj for obj in possible_objects if ( - # Check whether the parent is a robot performing further checks + # Check whether the parent is a robot before performing further checks hasattr(obj.parent, "parent") and ( obj.parent == location From f11940395597d3a97cac76616ee6ee4a2ecfc004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=BCller?= Date: Sun, 22 Dec 2024 11:24:10 +0000 Subject: [PATCH 3/3] Fix comments --- pyrobosim/pyrobosim/utils/knowledge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrobosim/pyrobosim/utils/knowledge.py b/pyrobosim/pyrobosim/utils/knowledge.py index fc6ef63a..e7828c3f 100644 --- a/pyrobosim/pyrobosim/utils/knowledge.py +++ b/pyrobosim/pyrobosim/utils/knowledge.py @@ -333,7 +333,7 @@ def resolve_to_object( obj for obj in possible_objects if ( - # Check whether the parent is a robot before performing further checks + # Verify the object's parent is not a robot before performing further checks hasattr(obj.parent, "parent") and obj.parent.parent.parent.name == room_name ) @@ -344,7 +344,7 @@ def resolve_to_object( obj for obj in possible_objects if ( - # Check whether the parent is a robot before performing further checks + # Verify the object's parent is not a robot before performing further checks hasattr(obj.parent, "parent") and ( obj.parent == location