heartbeat_responser.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import roslib
00003 roslib.load_manifest('heartbeat')
00004 import rospy
00005 from heartbeat.msg import Heartbeat, HeartbeatResponse
00006 
00007 class Responser():
00008     def __init__(self):
00009         rospy.init_node('heartbeat_responser')
00010         self.pub_response = rospy.Publisher("heartbeat/response", HeartbeatResponse)
00011         rospy.Subscriber("heartbeat/request", Heartbeat, self.callback)
00012         rospy.spin()
00013 
00014     def callback(self, heartbeat):
00015         res = HeartbeatResponse()
00016         res.header.stamp = rospy.Time.now()
00017         res.heartbeat = heartbeat
00018         self.pub_response.publish(res)
00019         rospy.loginfo("respond to msg published %s.%s" % (heartbeat.header.stamp.secs, heartbeat.header.stamp.nsecs))
00020 
00021 
00022 if __name__ == '__main__':
00023     Responser()


jsk_network_tools
Author(s): Yusuke Furuta
autogenerated on Mon Oct 6 2014 11:03:45