From dcaedf54ee38b11ef5009672e7a1b7d5f6c2e412 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu>
Date: Tue, 10 Dec 2013 17:18:35 +0000
Subject: [PATCH] Changed the point where the thread is started (from the
 constructor to the main ROS loop) to avoid executing the thread before ROS is
 correctly set up.

---
 include/iri_base_algorithm/iri_base_algorithm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/iri_base_algorithm/iri_base_algorithm.h b/include/iri_base_algorithm/iri_base_algorithm.h
index e0d3026..b41f0a4 100644
--- a/include/iri_base_algorithm/iri_base_algorithm.h
+++ b/include/iri_base_algorithm/iri_base_algorithm.h
@@ -286,9 +286,6 @@ IriBaseAlgorithm<Algorithm>::IriBaseAlgorithm() :
 {
   ROS_DEBUG("IriBaseAlgorithm::Constructor");
 
-  // create the status thread
-  pthread_create(&this->thread,NULL,this->mainThread,this);
-
 //   // assign callback to dynamic reconfigure server
 //   dsrv_.setCallback(boost::bind(&IriBaseAlgorithm<Algorithm>::reconfigureCallback, this, _1, _2));
 
@@ -354,6 +351,9 @@ int IriBaseAlgorithm<Algorithm>::spin(void)
   // assign callback to dynamic reconfigure server
   this->dsrv_.setCallback(boost::bind(&IriBaseAlgorithm<Algorithm>::reconfigureCallback, this, _1, _2));
 
+  // create the status thread
+  pthread_create(&this->thread,NULL,this->mainThread,this);
+
   while(ros::ok() && !ctrl_c_hit_count_)
   {
     // update diagnostics
-- 
GitLab