Fix scope problem in handPubThread. Join it.
authorWalter Fetter Lages <w.fetter@ieee.org>
Wed, 19 Dec 2018 11:53:23 +0000 (09:53 -0200)
committerWalter Fetter Lages <w.fetter@ieee.org>
Wed, 19 Dec 2018 11:53:23 +0000 (09:53 -0200)
wam_node_sim/src/wam_node_sim.cpp

index 10fcf0e..b6a3d70 100644 (file)
@@ -817,7 +817,8 @@ int main(int argc,char *argv[])
   WamNode<7> wam_node(wam,bhand);
   ros::Rate loop(PUBLISH_FREQ);
 
-  if(useHand) std::thread handPubThread(&WamNode<7>::publishHand,&wam_node);
+  std::thread handPubThread;
+  if(useHand) handPubThread=std::thread(&WamNode<7>::publishHand,&wam_node);
 
   while (ros::ok())
   {
@@ -827,5 +828,6 @@ int main(int argc,char *argv[])
     loop.sleep();
   }
   
+  handPubThread.join();
   return 0;
 }