From f9a6d3956dd6b6d95d40a47ea015bae5e1651af2 Mon Sep 17 00:00:00 2001
From: fherrero <fherrero@iri.upc.edu>
Date: Mon, 9 Dec 2019 13:33:26 +0100
Subject: [PATCH] Update the way to set the rate, according to last
 iri_base_algorithm version

---
 src/visual_gps_alg_node.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/visual_gps_alg_node.cpp b/src/visual_gps_alg_node.cpp
index 4b37121..1247e25 100644
--- a/src/visual_gps_alg_node.cpp
+++ b/src/visual_gps_alg_node.cpp
@@ -8,7 +8,7 @@ VisualGpsAlgNode::VisualGpsAlgNode(void) :
   //init class attributes if necessary
   double rate;
   this->private_node_handle_.param<double>("framerate", rate, 10.0);
-  this->loop_rate_ = rate;//in [Hz]
+  this->setRate(rate);//in [Hz]
 
   // [init publishers]
   this->pose_publisher_ = this->private_node_handle_.advertise<geometry_msgs::PoseStamped>("pose", 1);
@@ -304,7 +304,12 @@ void VisualGpsAlgNode::set_exposure_mutex_exit(void)
 void VisualGpsAlgNode::node_config_update(Config &config, uint32_t level)
 {
   this->alg_.lock();
-  this->loop_rate_ = config.framerate;
+  static double last_rate=1;
+  if(last_rate!=config.framerate)
+  {
+    this->setRate(config.framerate);
+    last_rate=config.framerate;
+  }
   
   this->config_=config;
   this->alg_.unlock();
-- 
GitLab