Changes have been pushed for the project "Fawkes Robotics Software Framework".
Gitweb: http://git.fawkesrobotics.org/fawkes.git Trac: http://trac.fawkesrobotics.org The branch, thofmann/ros-jointstate-publisher has been updated to 1d24a555d0f2fc755e6a640d4d872c8156acab3a (commit) from 8322ee9b1e7834a4dfb017f72e940a5b47f6e7dd (commit) http://git.fawkesrobotics.org/fawkes.git/thofmann/ros-jointstate-publisher Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - *Log* --------------------------------------------------------------- commit 1d24a555d0f2fc755e6a640d4d872c8156acab3a Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> AuthorDate: Mon Jan 13 14:49:52 2014 +0100 Commit: Till Hofmann <hofm...@kbsg.rwth-aachen.de> CommitDate: Mon Jan 13 14:49:52 2014 +0100 ros-joint: close interface if there are no other readers/writers If there are no other readers or writers to the interface, the ros joint publisher is the only reader, therefore close the interface. http://git.fawkesrobotics.org/fawkes.git/commit/1d24a55 http://trac.fawkesrobotics.org/changeset/1d24a55 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- src/plugins/ros/joint_thread.cpp | 44 ++++++++++++++++++++++++++++--------- src/plugins/ros/joint_thread.h | 8 ++++++- 2 files changed, 40 insertions(+), 12 deletions(-) - *Diffs* ------------------------------------------------------------- - *commit* 1d24a555d0f2fc755e6a640d4d872c8156acab3a - - - - - - - - - - Author: Till Hofmann <hofm...@kbsg.rwth-aachen.de> Date: Mon Jan 13 14:49:52 2014 +0100 Subject: ros-joint: close interface if there are no other readers/writers src/plugins/ros/joint_thread.cpp | 44 ++++++++++++++++++++++++++++--------- src/plugins/ros/joint_thread.h | 8 ++++++- 2 files changed, 40 insertions(+), 12 deletions(-) _Diff for modified files_: diff --git a/src/plugins/ros/joint_thread.cpp b/src/plugins/ros/joint_thread.cpp index 01f4796..41ea2f9 100644 --- a/src/plugins/ros/joint_thread.cpp +++ b/src/plugins/ros/joint_thread.cpp @@ -56,8 +56,6 @@ RosJointThread::init() } // watch for creation of new JointInterfaces bbio_add_observed_create("JointInterface"); - // watch for destruction of JointInterfaces - bbio_add_observed_destroy("JointInterface"); // register to blackboard blackboard->register_listener(this); @@ -98,16 +96,40 @@ RosJointThread::bb_interface_created(const char *type, const char *id) throw() } void -RosJointThread::bb_interface_destroyed(const char *type, const char *id) throw() +RosJointThread::bb_interface_writer_removed(Interface *interface, + unsigned int instance_serial) + throw() { - if (strncmp(type, "JointInterface", __INTERFACE_TYPE_SIZE) != 0) return; - for (std::list<JointInterface *>::iterator it = ifs_.begin(); it != ifs_.end(); it++) { - if ((*it)->id() == id) { - bbil_remove_data_interface(*it); - blackboard->update_listener(this); - blackboard->close(*it); - ifs_.erase(it); - break; + conditional_close(interface); +} + + +void +RosJointThread::bb_interface_reader_removed(Interface *interface, + unsigned int instance_serial) + throw() +{ + conditional_close(interface); +} + +void +RosJointThread::conditional_close(Interface *interface) throw() +{ + // Verify it's a JointInterface + JointInterface *jiface = dynamic_cast<JointInterface *>(interface); + if (! jiface) return; + + std::list<JointInterface *>::iterator it; + for (it = ifs_.begin(); it != ifs_.end(); ++it) { + if (*interface == **it) { + if (! interface->has_writer() && (interface->num_readers() == 1)) { + // It's only us + bbil_remove_data_interface(*it); + blackboard->update_listener(this); + blackboard->close(*it); + ifs_.erase(it); + break; + } } } } diff --git a/src/plugins/ros/joint_thread.h b/src/plugins/ros/joint_thread.h index 338cee8..5a17714 100644 --- a/src/plugins/ros/joint_thread.h +++ b/src/plugins/ros/joint_thread.h @@ -54,10 +54,16 @@ class RosJointThread virtual void finalize(); virtual void bb_interface_created(const char *type, const char *id) throw(); - virtual void bb_interface_destroyed(const char *type, const char *id) throw(); + virtual void bb_interface_writer_removed(fawkes::Interface *interface, + unsigned int instance_serial) throw(); + virtual void bb_interface_reader_removed(fawkes::Interface *interface, + unsigned int instance_serial) throw(); virtual void bb_interface_data_changed(fawkes::Interface *interface) throw(); private: + void conditional_close(fawkes::Interface *interface) throw(); + + private: ros::Publisher ros_pub_; std::list<fawkes::JointInterface *> ifs_; -- Fawkes Robotics Framework http://www.fawkesrobotics.org _______________________________________________ fawkes-commits mailing list fawkes-commits@lists.kbsg.rwth-aachen.de https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits