Repository: isi-vista/adam

Issue:
In situation generation block regions from being gazeable in the default

Comments:

Patch:
diff --git a/adam/ontology/phase1_ontology.py b/adam/ontology/phase1_ontology.py
index 7919b073..202317ca 100644
--- a/adam/ontology/phase1_ontology.py
+++ b/adam/ontology/phase1_ontology.py
@@ -475,7 +475,7 @@ _TORSO = OntologyNode("torso")
 subtype(_TORSO, _BODY_PART)
 _ANIMAL_LEG = OntologyNode("(animal) leg")
 subtype(_ANIMAL_LEG, _BODY_PART)
-_INANIMATE_LEG = OntologyNode("(inanimate) leg")
+_INANIMATE_LEG = OntologyNode("(furniture) leg")
 subtype(_INANIMATE_LEG, INANIMATE_OBJECT)
 _CHAIR_BACK = OntologyNode("chairback")
 subtype(_CHAIR_BACK, INANIMATE_OBJECT)
diff --git a/adam/perception/perception_graph.py b/adam/perception/perception_graph.py
index 0c85889c..0e0e9df2 100644
--- a/adam/perception/perception_graph.py
+++ b/adam/perception/perception_graph.py
@@ -127,6 +127,10 @@ HAS_PROPERTY_LABEL = OntologyNode("has-property")
 """
 Edge label in a `PerceptionGraph` linking an `ObjectPerception` to its associated `Property`.
 """
+FACING_OBJECT_LABEL = OntologyNode("facing-axis")
+"""
+Edge label in a `PerceptionGraph` linking an `Axis` to a `ObjectPerception` it is facing
+"""
 
 
 class PerceptionGraphProtocol(Protocol):
@@ -229,6 +233,10 @@ class PerceptionGraph(PerceptionGraphProtocol):
                 raise RuntimeError(f"Don't know how to translate property {property_}")
             graph.add_edge(source_node, dest_node, label=HAS_PROPERTY_LABEL)
 
+        if frame.axis_info:
+            for (object_, axis) in frame.axis_info.axes_facing.items():
+                graph.add_edge(axis, object_, label=FACING_OBJECT_LABEL)
+
         return PerceptionGraph(graph)
 
     def render_to_file(  # pragma: no cover
diff --git a/adam/situation/high_level_semantics_situation.py b/adam/situation/high_level_semantics_situation.py
index 9ff0c93e..17d50c0a 100644
--- a/adam/situation/high_level_semantics_situation.py
+++ b/adam/situation/high_level_semantics_situation.py
@@ -191,6 +191,13 @@ class HighLevelSemanticsSituation(Situation):
                     f" in {self}"
                 )
 
+        for object_ in self.gazed_objects:
+            if isinstance(object_, Region):
+                raise RuntimeError(
+                    f"Cannot have a Region as a gazed object in a situation, got"
+                    f"{object_} which is a region."
+                )
+
     def __repr__(self) -> str:
         # TODO: the way we currently repr situations doesn't handle multiple nodes
         # of the same ontology type well.  We'd like to use subscripts (_0, _1)
@@ -229,6 +236,7 @@ class HighLevelSemanticsSituation(Situation):
             object_
             for action in self.actions
             for (_, object_) in action.argument_roles_to_fillers.items()
+            if not isinstance(object_, Region)
         )
 
     @all_objects.default


Test patch:
diff --git a/tests/situation/high_level_semantics_situation.py b/tests/situation/high_level_semantics_situation.py
index e69de29b..3373909f 100644
--- a/tests/situation/high_level_semantics_situation.py
+++ b/tests/situation/high_level_semantics_situation.py
@@ -0,0 +1,49 @@
+from adam.ontology.phase1_ontology import (
+    MOM,
+    BALL,
+    TABLE,
+    PUT,
+    GOAL,
+    THEME,
+    AGENT,
+    GAILA_PHASE_1_ONTOLOGY,
+)
+from adam.ontology.phase1_spatial_relations import (
+    EXTERIOR_BUT_IN_CONTACT,
+    GRAVITATIONAL_UP,
+    Region,
+)
+from adam.situation import Action
+from adam.situation.high_level_semantics_situation import HighLevelSemanticsSituation
+from tests.adam_test_utils import situation_object
+
+
+def test_no_region_in_gazed_objects():
+    putter = situation_object(MOM)
+    object_put = situation_object(BALL)
+    on_region_object = situation_object(TABLE)
+    situation = HighLevelSemanticsSituation(
+        salient_objects=[putter, object_put, on_region_object],
+        actions=[
+            Action(
+                PUT,
+                argument_roles_to_fillers=[
+                    (AGENT, putter),
+                    (THEME, object_put),
+                    (
+                        GOAL,
+                        Region(
+                            on_region_object,
+                            distance=EXTERIOR_BUT_IN_CONTACT,
+                            direction=GRAVITATIONAL_UP,
+                        ),
+                    ),
+                ],
+            )
+        ],
+        ontology=GAILA_PHASE_1_ONTOLOGY,
+    )
+
+    assert situation.gazed_objects
+    for object_ in situation.gazed_objects:
+        assert not isinstance(object_, Region)