|
|
import networkx as nx
|
|
|
from nodes import ROOMS, OFFICES, ASSETS, OBJECTS
|
|
|
|
|
|
def add_edges(graph):
|
|
|
for node_name in graph.nodes:
|
|
|
node = graph.nodes[node_name]
|
|
|
match node['type']:
|
|
|
case 'place':
|
|
|
graph.add_edge(node_name,('scene',1))
|
|
|
case 'asset':
|
|
|
graph.add_edge(node_name,node['place'])
|
|
|
case 'object':
|
|
|
graph.add_edge(node_name,node['related_to'])
|
|
|
case 'agent':
|
|
|
graph.add_edge(node_name,node['location'])
|
|
|
case 'scene':
|
|
|
pass
|
|
|
case _:
|
|
|
print(f"Unknown node type: {node['type']}")
|
|
|
|
|
|
def create_office_graph():
|
|
|
"""Initializes and builds the office scene graph."""
|
|
|
graph = nx.Graph()
|
|
|
graph.add_node(('scene', 1), name='SayPlan Office', type='scene')
|
|
|
|
|
|
|
|
|
for place in (OFFICES + ROOMS):
|
|
|
graph.add_node(place, type='place')
|
|
|
|
|
|
|
|
|
for asset, place, states, affordances, properties in ASSETS:
|
|
|
graph.add_node(asset, place=place, states=states, affordances=affordances, properties=properties, type='asset')
|
|
|
|
|
|
|
|
|
for obj, relation, related_to, states, affordances, properties in OBJECTS:
|
|
|
graph.add_node(obj, relation=relation, related_to=related_to, states=states, affordances=affordances, properties=properties, type='object')
|
|
|
|
|
|
|
|
|
agent_node = ('agent', 1)
|
|
|
agent_location = ('mobile_robotics_lab', 1)
|
|
|
graph.add_node(agent_node, location=agent_location, holding='', type='agent')
|
|
|
add_edges(graph)
|
|
|
return graph
|
|
|
|
|
|
|
|
|
office_graph = create_office_graph() |