From 96a4feffddf6feca8b80ec175e9a54ae3c48eb0c Mon Sep 17 00:00:00 2001 From: Daniel Stonier Date: Thu, 29 Aug 2019 08:34:24 -0400 Subject: [PATCH 1/2] [backend] ensure tree modifications are published with an updated timestamp --- CHANGELOG.rst | 1 + py_trees_ros/trees.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ae2b1734..55c6eff1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog Forthcoming ----------- +* [backend] ensure tree modifications are published with an updated timestamp 1.1.2 (2019-08-10) ------------------ diff --git a/py_trees_ros/trees.py b/py_trees_ros/trees.py index aa52b0e9..30cf4c41 100644 --- a/py_trees_ros/trees.py +++ b/py_trees_ros/trees.py @@ -165,7 +165,7 @@ def _setup_publishers(self): # set a handler to publish future modifications whenever the tree is modified # (e.g. pruned). The tree_update_handler method is in the base class, set this # to the callback function here. - self.tree_update_handler = self._publish_serialised_tree + self.tree_update_handler = self._on_tree_update_handler def tick_tock( self, @@ -239,6 +239,17 @@ def _tick_tock_timer_callback( else: self.timer.cancel() + def _on_tree_update_handler(self): + """ + Whenever there has been a modification to the tree (insertion/pruning), publish + the snapshot. + """ + # only worth notifying once we've actually commenced + if self.statistics is not None: + rclpy_start_time = rclpy.clock.Clock().now() + self.statistics.stamp = rclpy_start_time.to_msg() + self._publish_serialised_tree() + def _statistics_pre_tick_handler(self, tree: py_trees.trees.BehaviourTree): """ Pre-tick handler that resets the statistics and starts the clock. From 67c8c88fad74cb4fbd2d4287e64a4411f523b1ad Mon Sep 17 00:00:00 2001 From: Daniel Stonier Date: Thu, 29 Aug 2019 08:35:23 -0400 Subject: [PATCH 2/2] trivial --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 55c6eff1..b7d3b902 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,7 +4,7 @@ Changelog Forthcoming ----------- -* [backend] ensure tree modifications are published with an updated timestamp +* [backend] ensure tree modifications are published with an updated timestamp, `#100 `_ 1.1.2 (2019-08-10) ------------------