Skip to content

Commit

Permalink
[RosInterface] implements proper reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jan 15, 2024
1 parent 02461af commit 11302b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/ontologenius/interface/RosInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class RosInterface

/// @brief The variable used to display or not debug information. Can be changed at run time
bool display_;
/// @brief represents all files provided at the initialization
std::vector<std::string> files_;
/// @brief represents the dedicated intern file
std::string intern_file_;

/// @brief The ROS topic callback receiving statements not stamped
void knowledgeCallback(compat::onto_ros::MessageWrapper<std_msgs_compat::String> msg);
Expand Down
17 changes: 17 additions & 0 deletions src/interface/RosInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void RosInterface::init(const std::string& lang, const std::string& intern_file,
if(pose != std::string::npos)
dedicated_intern_file.insert(pose, "_" + name_);
}
intern_file_ = dedicated_intern_file;

files_ = files;
if(onto_->preload(dedicated_intern_file) == false)
for(auto& file : files)
onto_->readFromFile(file);
Expand Down Expand Up @@ -233,6 +235,21 @@ bool RosInterface::actionsHandle(compat::onto_ros::ServiceWrapper<compat::Ontolo
if(close() == false)
res->code = REQUEST_ERROR;
}
else if(req->action == "reset")
{
lock();
delete onto_;
onto_ = new Ontology();
onto_->setDisplay(display_);
reasoners_.link(onto_);
feeder_.link(onto_);
sparql_.link(onto_);

if(onto_->preload(intern_file_) == false)
for(auto& file : files_)
onto_->readFromFile(file);
release();
}
else if(req->action == "clear")
{
lock();
Expand Down

0 comments on commit 11302b3

Please sign in to comment.