Skip to content

Commit

Permalink
Added functions Nodelet::ok() and Nodelet::requestStop().
Browse files Browse the repository at this point in the history
  • Loading branch information
peci1 committed Feb 5, 2022
1 parent 3eabcdc commit ab95aa5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nodelet/include/nodelet/nodelet.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ class NODELETLIB_DECL Nodelet
ros::CallbackQueueInterface* st_queue = NULL,
ros::CallbackQueueInterface* mt_queue = NULL);

/**\brief Whether it is OK to continue working with this nodelet. This function starts returning true right
* before onInit() is called and starts returning false when the nodelet is requested to stop via
* requestStop() or execution of its destructor.
* \return Status of the nodelet.
*/
bool ok() const;

/**\brief Request this nodelet to stop. This function returns immediately. Afterwards, ok() returns false.
*/
void requestStop();

virtual ~Nodelet();
};

Expand Down
1 change: 1 addition & 0 deletions nodelet/src/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ struct ManagedNodelet : boost::noncopyable

~ManagedNodelet()
{
nodelet->requestStop();
callback_manager->removeQueue(st_queue);
callback_manager->removeQueue(mt_queue);
}
Expand Down
11 changes: 11 additions & 0 deletions nodelet/src/nodelet_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Nodelet::Nodelet ()

Nodelet::~Nodelet()
{
requestStop();
}

ros::CallbackQueueInterface& Nodelet::getSTCallbackQueue () const
Expand Down Expand Up @@ -134,4 +135,14 @@ void Nodelet::init(const std::string& name, const M_string& remapping_args, cons
this->onInit ();
}

bool Nodelet::ok() const
{
return inited_;
}

void Nodelet::requestStop()
{
inited_ = false;
}

} // namespace nodelet

0 comments on commit ab95aa5

Please sign in to comment.