Callback function is not called

asked 2015-12-15 10:00:30 -0600

Yacoub gravatar image

updated 2015-12-15 10:03:52 -0600

Hello, I am trying to subscribed with two different synchronized topics. So I've written a python program to do that. It compile without any errors. But the callback functions is not called.

Thanks Ali

#!/usr/bin/env python
import graphlab
import rospy
from geometry_msgs.msg import WrenchStamped
import message_filters
from  sensor_msgs.msg import JointState
class Node:
        def __init__(self):
             self.fx_model=graphlab.load_model('src/ft_comp/scripts/models/Fx_model_joints_lr')
             print 'models loading...'
             self.fy_model=graphlab.load_model('src/ft_comp/scripts/models/Fy_model_joints_lr')
             self.fz_model=graphlab.load_model('src/ft_comp/scripts/models/Fz_model_joints_lr')
             self.Tx_model=graphlab.load_model('src/ft_comp/scripts/models/Tx_model_joints_lr')
             self.Ty_model=graphlab.load_model('src/ft_comp/scripts/models/Ty_model_joints_lr')
             self.Tz_model=graphlab.load_model('src/ft_comp/scripts/models/Tz_model_joints_lr')
             self.Wrench_msg_sub=message_filters.Subscriber("ft_msgs_sync",WrenchStamped)
             self.Joint_msg_sub=message_filters.Subscriber("joint_states_sync", JointState)
             self.ts = message_filters.TimeSynchronizer([self.Wrench_msg_sub,self.Joint_msg_sub], 10)
             self.ts.registerCallback(self.callback)
             print 'models loading ...'

      def callback(self,ft_msgs_sync,joint_states_sync):
             print 'in callback function'
             Rostime=[]
             Rostime.append(ft_msgs_sync.rostime)
             force_array=[]
             for i in range(0,3):
             if i==0:
                force_array.append(ft_msgs_sync.wrench.force.x)
             if i==1:
                force_array.append(ft_msgs_sync.wrench.force.y)
             if i==2:
                force_array.append(ft_msgs_sync.wrench.force.z)

             joints_array=[]
             for i in range(0,2):
                 if i==0:
                     #joint_s
                     joints_array.append(joint_states_sync[0])
                 if i==1:
                     #joint_l
                     joints_array.append(joint_states_sync[1])
                 if i==2:
                     #joint_e
                     joints_array.append(joint_states_sync[2])
                     print 'hello'


 def listener():

   rospy.init_node('listener', anonymous=True)
   Nh=Node()
    rospy.spin()

 if __name__ == '__main__':
    listener()
edit retag flag offensive close merge delete