Skip to content

Commit

Permalink
This change is still in process. Added a few stubs, but need to have …
Browse files Browse the repository at this point in the history
…an architecure discussion still
  • Loading branch information
Evana Gizzi authored and Evana Gizzi committed Oct 12, 2023
1 parent 6279476 commit f5dc9cc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
5 changes: 5 additions & 0 deletions onair/src/reasoning/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""
from ..ai_components.learners_interface import LearnersInterface
from ..ai_components.planners_interface import PlannersInterface
from ..reasoning.complex_reasoning_interface import ComplexReasoningInterface
from ..reasoning.diagnosis import Diagnosis

class Agent:
Expand All @@ -24,6 +25,7 @@ def __init__(self, vehicle, plugin_list):
# AI Interfaces
self.learning_systems = LearnersInterface(self.vehicle_rep.get_headers(),plugin_list)
self.planning_systems = PlannersInterface(self.vehicle_rep.get_headers(),plugin_list)
self.complex_reasoning_systems = ComplexReasoningInterface(self.vehicle_rep.get_headers(),plugin_list)

# Markov Assumption holds
def reason(self, frame):
Expand All @@ -37,6 +39,9 @@ def reason(self, frame):
self.learning_systems.check_for_salient_event()
self.planning_systems.check_for_salient_event()

# NOT YET COMPLETE
self.complex_reasoning_systems.update(frame, self.learning_systems.check_for_salient_event())

def diagnose(self, time_step):
""" Grab the mnemonics from the """
learning_system_results = self.learning_systems.render_reasoning()
Expand Down
39 changes: 39 additions & 0 deletions onair/src/reasoning/complex_reasoning_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# GSC-19165-1, "The On-Board Artificial Intelligence Research (OnAIR) Platform"
#
# Copyright © 2023 United States Government as represented by the Administrator of
# the National Aeronautics and Space Administration. No copyright is claimed in the
# United States under Title 17, U.S. Code. All Other Rights Reserved.
#
# Licensed under the NASA Open Source Agreement version 1.3
# See "NOSA GSC-19165-1 OnAIR.pdf"

"""
Reasoning interface class for managing all complex custom reasoning components
"""
import importlib.util

from ..util.data_conversion import *

class ComplexReasoningInterface:
def __init__(self, headers, _reasoning_plugins={}):
assert(len(headers)>0), 'Headers are required'
self.headers = headers
self.reasoning_constructs = []
for module_name in list(_reasoning_plugins.keys()):
spec = importlib.util.spec_from_file_location(module_name, _reasoning_plugins[module_name])
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
self.reasoning_constructs.append(module.Plugin(module_name,headers))

def update(self, low_level_data, high_level_data):
for plugin in self.reasoning_constructs:
plugin.update(low_level_data,high_level_data)

def check_for_salient_event(self):
pass

def render_reasoning(self):
intelligent_outcomes = {}
for plugin in self.reasoning_constructs:
intelligent_outcomes[plugin.component_name] = plugin.render_reasoning()
return intelligent_outcomes
2 changes: 1 addition & 1 deletion onair/src/reasoning/reasoning_plugin_abstract/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, _name, _headers):
self.headers = _headers

@abstractmethod
def update(self, frame=[], high_level_info=[]):
def update(self, low_level_data=[], high_level_data={}):
"""
Given streamed data point and other sources of high-level info,
system should update internally
Expand Down

0 comments on commit f5dc9cc

Please sign in to comment.