Class CognexConsultant

java.lang.Object
edu.tufts.hrilab.consultant.Consultant<CognexReference>
edu.tufts.hrilab.cognex.consultant.CognexConsultant
All Implemented Interfaces:
ConsultantInterface

public class CognexConsultant extends Consultant<CognexReference> implements ConsultantInterface
  • Field Details

    • availableJobs

      protected Set<CognexJob> availableJobs
    • boundJobs

      protected Map<String,CognexJob> boundJobs
    • lessSalientRefIds

      protected Set<Symbol> lessSalientRefIds
    • groupNames

      protected String groupNames
      Group identifier to be prepended to reference names
  • Constructor Details

    • CognexConsultant

      public CognexConsultant()
    • CognexConsultant

      public CognexConsultant(List<String> groups)
  • Method Details

    • localConvertToType

      public <U> U localConvertToType(Symbol refId, Class<U> type)
      Description copied from class: Consultant
      The local implementation of convertToType.
      Specified by:
      localConvertToType in class Consultant<CognexReference>
      Type Parameters:
      U - target Java class template type (any)
      Parameters:
      refId - reference resolution ID (e.g.object_3)
      type - target Java class type
      Returns:
      instance of specified target Java class
    • localConvertToType

      public <U> U localConvertToType(Symbol refId, Class<U> type, List<? extends Term> constraints)
      Description copied from class: Consultant
      The local implementation of convertToType.
      Specified by:
      localConvertToType in class Consultant<CognexReference>
      Type Parameters:
      U - target Java class template type (any)
      Parameters:
      refId - reference resolution ID (e.g.object_3)
      type - target Java class type
      constraints - first-order-logic predicate constraints
      Returns:
      instance of specified target Java class
    • assertProperties

      public boolean assertProperties(Map<Variable,Symbol> bindings, Double prob, List<Term> properties)
      Description copied from interface: ConsultantInterface
      an attempt is made to bring the knowledge base in line with the provided bindings, list of properties, and probability value.
      Specified by:
      assertProperties in interface ConsultantInterface
      Overrides:
      assertProperties in class Consultant<CognexReference>
      Parameters:
      bindings - list of bindings in tuple form (free-variable and refId pair)
      prob - probability value
      properties - list of Properties
      Returns:
      whether the updated was successful?
    • assertProperties

      public boolean assertProperties(Symbol refId, List<Term> properties)
      Description copied from interface: ConsultantInterface
      Add properties to already existing object ref. Each property should contain a connection to the existing reference either by refId or refId's variable.
      Specified by:
      assertProperties in interface ConsultantInterface
      Overrides:
      assertProperties in class Consultant<CognexReference>
      Parameters:
      refId - reference
      properties - reference properties
      Returns:
      if property was successfully added to reference refId
    • addDetectionType

      public Symbol addDetectionType(Symbol descriptor, Symbol jobName)
      Adds a binding between the human descriptor and the name of the job on the cognex, these doesn't necessarily need to be the same. The system should know about all of the job names, but it doesn't have to know about the human producable descriptors?

      Once the binding is done it adds the proerty to the consultant. TODO:brad is there a way we could just get the jobs from the Cognex at start up? thT would make this a lot easier.

      Parameters:
      descriptor - human provided descriptor
      jobName - name of job on the Cognex that is used to detect the thing associated with the provided descriptor
    • createCogRefWithProps

      public CognexReference createCogRefWithProps(CognexJob j, List<Term> additionalProperties)
    • createCognexRef

      public CognexReference createCognexRef(CognexJob job, List<Term> additionalProps)
    • getJobForDescriptor

      public CognexJob getJobForDescriptor(String descriptor)
      Parameters:
      descriptor -
      Returns:
    • removeReference

      public CognexReference removeReference(Symbol refId)
      Description copied from class: Consultant
      Remove known reference from the consultant.
      Overrides:
      removeReference in class Consultant<CognexReference>
      Parameters:
      refId - unique reference ID
      Returns:
      removed Reference or null if it doesn't exist
    • getNextReferenceId

      protected Symbol getNextReferenceId()
      Generates the new refId based on the refNumber counter, and increments. Informs all other consultants with the same kbName of the current ref being allocated to attempt to maintain sync and avoid duplicating refs.
      Overrides:
      getNextReferenceId in class Consultant<CognexReference>
      Returns:
    • addReference

      public void addReference(CognexReference newRef)
      Description copied from class: Consultant
      Add new reference from some source (file or learning) to the consultant
      Overrides:
      addReference in class Consultant<CognexReference>
      Parameters:
      newRef - new reference to add
    • getActivatedEntities

      public Map<Symbol,Double> getActivatedEntities()
      Description copied from interface: ConsultantInterface
      Get a list of currently highly salient entities that should be considered "activated."
      Specified by:
      getActivatedEntities in interface ConsultantInterface
      Overrides:
      getActivatedEntities in class Consultant<CognexReference>
      Returns:
      list of refIds and probability pairs
    • createCogRefWithProperty

      public Symbol createCogRefWithProperty(Symbol jobDescriptor, Term property)
    • getCognexJobForDescriptor

      public CognexJob getCognexJobForDescriptor(Symbol descriptor)
    • bindCognexResult

      public void bindCognexResult(CognexReference ref, CognexResult result, int indexIntoCognexResult)
    • getCognexJobForCognexReference

      public CognexJob getCognexJobForCognexReference(CognexReference ref)
      Returns the CognexJob able to detect the given reference, if it exists.
      Parameters:
      ref - The CognexReference to fetch the matching CognexJob of.
      Returns:
      The CognexJob associated with this reference.
    • getCognexReferenceForID

      public CognexReference getCognexReferenceForID(Symbol refId)