Aldebaran documentation What's new in NAOqi 2.4.3?

ALKnowledge API

NAOqi Core - Overview | API | Tutorial


Methods

void ALKnowledge::add(const std::string& domain, const std::string& subject, const std::string& predicate, const std::string& object)

Adds a triplet to the ontology.

The ontology is persistent so any added triplet will stay in the ontology until it is removed by ALKnowledge::remove, ALKnowledge::resetKnowledge or ALKnowledge::update.

Parameters:
  • domain – Domain of the predicate.
  • subject – Subject of the triplet.
  • predicate – Predicate of the triplet.
  • object – Object of the triplet.
std::vector<std::string> ALKnowledge::getSubject(const std::string& domain, const std::string& predicate, const std::string& object)

Gets the vector of all subjects given the predicate and the object.

Parameters:
  • domain – Domain of the predicate.
  • predicate – Predicate of a triplet.
  • object – Object of a triplet.
Returns:

vector of all subjects for which the triplet subject-predicate-object exists in the ontology.

std::vector<std::string> ALKnowledge::getPredicate(const std::string& domain, const std::string& subject, const std::string& object)

Gets the vector of all predicates given the subject and the object.

Parameters:
  • domain – Domain of the predicate.
  • subject – Subject of a triplet.
  • object – Object of a triplet.
Returns:

vector of all predicates (of the given domain) for which the triplet subject-predicate-object exists in the ontology.

std::vector<std::string> ALKnowledge::getObject(const std::string& domain, const std::string& subject, const std::string& predicate)

Gets the vector of all objects given the subject and the predicate.

Parameters:
  • domain – Domain of the predicate.
  • subject – Subject of a triplet.
  • predicate – Predicate of a triplet.
Returns:

vector of all objects (of the given domain) for which the triplet subject-predicate-object exists in the ontology.

void ALKnowledge::update(const std::string& domain, const std::string& subject, const std::string& predicate, const std::string& object)

Removes all triplets where the subject is subject and the predicate is predicate and add the triplet subject-predicate-object.

Parameters:
  • domain – Domain of the predicate.
  • subject – Subject of the triplet.
  • predicate – Predicate of the triplet.
  • object – Object of the new triplet
void ALKnowledge::remove(const std::string& domain, const std::string& subject, const std::string& predicate, const std::string& object)

Removes the triplet given the subject, predicate and object.

Parameters:
  • domain – Domain of the predicate.
  • subject – Subject of the triplet.
  • predicate – Predicate of the triplet.
  • object – Object of the triplet.
bool ALKnowledge::contains(const std::string& domain, const std::string& subject, const std::string& predicate, const std::string& object)

Checks if the ontology contains the given triplet.

Parameters:
  • domain – Domain of the predicate
  • subject – Subject of the triplet.
  • predicate – Predicate of the triplet.
  • object – Object of the triplet.
std::vector<std::string> ALKnowledge::query(const std::string& domain, const std::string& subject, const std::string& predicate, const std::string& object)

Returns the list of values satisfying the query given in parameters.

The parameters must contain 2 existing values and a question mark ”?” for the value you are looking for.

Parameters:
  • domain – Domain of the predicate.
  • subject – Subject of the triplet.
  • predicate – Predicate of the triplet.
  • object – Object of the new triplet.
Returns:

A vector of values.

    print result #Should print True

    #Remove
void ALKnowledge::resetKnowledge(const std::string& domain)

Removes all the triplets where the predicate is in the domain “domain”.

Parameters:
  • domain – Domain of the predicate.