FeederPublisher Class
The FeederPublisher class provides an abstraction for ontologenius feeder topic. More...
Header: | #include "ontologenius/FeederPublisher.h" |
Namespace: | onto |
Public Functions
FeederPublisher(const std::string& name) | |
addProperty(const std::string& from, const std::string& property, const std::string& on, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
addProperty(const std::string& from, const std::string& property, const std::string& type, const std::string& value, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
addInheritage(const std::string& child, const std::string& mother, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
addLanguage(const std::string& from, const std::string& lang, const std::string& name, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
addConcept(const std::string& from, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
addInverseOf(const std::string& property, const std::string& inverse_property, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
removeProperty(const std::string& from, const std::string& property, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
removeProperty(const std::string& from, const std::string& property, const std::string& on, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
removeProperty(const std::string& from, const std::string& property, const std::string& type, const std::string& value, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
removeInheritage(const std::string& from, const std::string& on, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
removeLanguage(const std::string& from, const std::string& lang, const std::string& name, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
removeConcept(const std::string& from, const onto_ros::Time& stamp = onto_ros::Node::get().current_time()) | |
size_t | getNumSubscribers() |
waitConnected() | |
bool | waitUpdate(int32_t timeout = -1) |
std::string | commit(int32_t timeout = -1) |
bool | commit(const std::string& commit_name, int32_t timeout = -1) |
bool | checkout(const std::string& commit_name, int32_t timeout = -1) |
registerFeederNotificationCallback(const std::function<void(const std::string&)>& callback) | |
registerReasonersNotificationCallback(const std::function<void(const std::string&)>& callback) |
Detailed Description
The FeederPublisher class provides an abstraction ontologenius feeder(insert) ROS topic.
Working in a closed world can be interesting, but with ontologenius, you can also choose to work in an open world by adding and modifying the agent's knowledge base during its operation. The feeder publisher is used to insert and delete knowledge dynamically. The feeding process is asynchronous and therefore does not guarantee any response time. It still provides functions to synchronize if you have applications where you have to query the ontology right after having modified it.
All modifications can be time-stamped for advanced uses using the republication mechanism.
Public Function Documentation
FeederPublisher::FeederPublisher(const std::string& name)
Constructs a FeederPublisher.
Can be used in a multi-ontology mode by specifying the name of the ontology name. For classic use, name should be defined as "".
FeederPublisher::addProperty(const std::string& from, const std::string& property, const std::string& on, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Adds the fact that from is linked with on by the property property.
At least from or on must be already known to the system. If one of them is unknown, it will be automatically created. The property can be unknown before calling this function.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::addProperty(const std::string& from, const std::string& property, const std::string& type, const std::string& value, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Adds the fact that from is linked to the data value of type type by the property property.
from must be already known to the system. The property can be unknown before calling this function.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::addInheritage(const std::string& child, const std::string& mother, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Adds the inheratage: child is a mother. child and mother could by a class, an individual or a property.
At least child or mother must be already known to the system. If one of them is unknown, it will be automatically created.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::addLanguage(const std::string& from, const std::string& lang, const std::string& name, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Adds the label name in the language lang the class, individual, or property from.
from must be already known to the system.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::addConcept(const std::string& from, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Adds the class or individual from.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::addInverseOf(const std::string& property, const std::string& inverse_property, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Adds the object property inverse axiom that property has for inverse inverse_property.
property must be already known to the system.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::removeProperty(const std::string& from, const std::string& property, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Removes the fact that from is linked to any object by the property property.
After this action, knowledge of the property is not removed.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::removeProperty(const std::string& from, const std::string& property, const std::string& on, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Removes the fact that from is linked with on by the property property.
After this action, knowledge of the property is not removed.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::removeProperty(const std::string& from, const std::string& property, const std::string& type, const std::string& value, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Removes the fact that from is linked to the data value of type type by the property property.
After this action, knowledge of the property is not removed.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::removeInheritage(const std::string& from, const std::string& on, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Removes the inheratage: from is a on. from and on could by a class, an individual or a property.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::removeLanguage(const std::string& from, const std::string& lang, const std::string& name, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Removes the label name in the language lang the class, individual, or property from.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
FeederPublisher::removeConcept(const std::string& from, const onto_ros::Time& stamp = onto_ros::Node::get().currentTime())
Removes the class or individual from.
All inheritance, properties, and labels applied to from are also removed.
onto_ros::Time is an abstraction of the ROS time definition which can be provided either with ROS1 and ROS2 time representation (i.e. ros::Time or rclcpp::Time).
If the time stamp stamp is not defined, the function takes the current ROS time as the time stamp.
size_t FeederPublisher::getNumSubscribers()
Returns the number of subscribers that are currently connected to the internal ROS publisher.
FeederPublisher::waitConnected()
Blocks while no subscribers are currently connected to the internal ROS publisher.
bool FeederPublisher::waitUpdate(int32_t timeout = -1)
Waits until all changes have been applied.
The default parameter timeout is the expiration time in milliseconds. The default value -1 represents an infinite wait.
Returns false if the function returns on a timeout.
std::string FeederPublisher::commit(int32_t timeout = -1)
Saves all the modifications from the previous commit and waits until all changes have been applied.
The default parameter timeout is the expiration time in milliseconds. The default value -1 represents an infinite wait.
Returns the commit id and an empty string if the function returns on a timeout.
This function can only be used on a copied ontology.
bool FeederPublisher::commit(const std::string& commit_name, int32_t timeout = -1)
Saves all the modifications from the previous commit with a specific id commit_name and waits until all changes have been applied.
The default parameter timeout is the expiration time in milliseconds. The default value -1 represents an infinite wait.
Returns false if the function returns on a timeout.
This function can only be used on a copied ontology.
bool FeederPublisher::checkout(const std::string& commit_name, int32_t timeout = -1)
Apply the necessary changes to return to the specified commit_name and waits until all changes have been applied.
The default parameter timeout is the expiration time in milliseconds. The default value -1 represents an infinite wait.
Returns false if the function returns on a timeout.
This function can only be used on a copied ontology.
void FeederPublisher::registerFeederNotificationCallback(const std::function<void(const std::string&)>& callback)
Register a callback function to get notifications from the feeder.
The parameter callback is the callback function taking a string.
void FeederPublisher::registerReasonersNotificationCallback(const std::function<void(const std::string&)>& callback)
Register a callback function to get notifications from the reasoners.
The parameter callback is the callback function taking a string.