Fix bug in context of tree and chain in wam_node_sim.
authorWalter Fetter Lages <w.fetter@ieee.org>
Wed, 12 Dec 2018 14:13:33 +0000 (12:13 -0200)
committerWalter Fetter Lages <w.fetter@ieee.org>
Wed, 12 Dec 2018 14:13:33 +0000 (12:13 -0200)
wam_node_sim/include/wam_node_sim/detail/wam-impl.h
wam_node_sim/include/wam_node_sim/wam.h

index f955a0f..5b231e1 100644 (file)
@@ -71,17 +71,16 @@ Wam<DOF>::Wam(Hand *hand,const std::string& sysName)
         if(!node_.getParam("/robot_description",robotDescription))
                 ROS_ERROR("Could not find 'robot_description'.");
                 
-        KDL::Tree tree;
-        if (!kdl_parser::treeFromString(robotDescription,tree))
+        if (!kdl_parser::treeFromString(robotDescription,tree_))
                 ROS_ERROR("Failed to construct KDL tree.");
                 
                 
-       KDL::SegmentMap::const_iterator s=tree.getRootSegment();
-        KDL::Chain chain;
-        if (!tree.getChain(GetTreeElementSegment(s->second).getName(),"wam_tool_plate",chain)) 
+       KDL::SegmentMap::const_iterator s=tree_.getRootSegment();
+
+        if (!tree_.getChain(GetTreeElementSegment(s->second).getName(),"wam_tool_plate",chain_)) 
                 ROS_ERROR("Failed to get chain from KDL tree.");
 
-        fwdKinSolverPos_=new KDL::ChainFkSolverPos_recursive(chain);
+        fwdKinSolverPos_=new KDL::ChainFkSolverPos_recursive(chain_);
 }
 
 template<size_t DOF>
index c9b5259..3a40716 100644 (file)
@@ -53,6 +53,7 @@
 #include "trajectory_msgs/JointTrajectoryPoint.h"
 #include <sensor_msgs/JointState.h>
 
+#include <kdl/tree.hpp>
 #include <kdl/chainfksolverpos_recursive.hpp>
 #include <wam_node_sim/hand.h>
 
@@ -185,6 +186,8 @@ private:
        jp_type jointPosition_;
        jv_type jointVelocity_;
        jt_type jointEffort_;
+        KDL::Tree tree_;
+        KDL::Chain chain_;
        KDL::ChainFkSolverPos_recursive *fwdKinSolverPos_;
        Hand *hand_;