heartbeat_responser.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import rospy
3 from jsk_network_tools.msg import Heartbeat, HeartbeatResponse
4 
5 class Responser():
6  def __init__(self):
7  rospy.init_node('heartbeat_responser')
8  self.pub_response = rospy.Publisher("heartbeat/response", HeartbeatResponse)
9  rospy.Subscriber("heartbeat/request", Heartbeat, self.callback)
10  rospy.spin()
11 
12  def callback(self, heartbeat):
13  res = HeartbeatResponse()
14  res.header.stamp = rospy.Time.now()
15  res.heartbeat = heartbeat
16  self.pub_response.publish(res)
17  rospy.loginfo("respond to msg published %s.%s" % (heartbeat.header.stamp.secs, heartbeat.header.stamp.nsecs))
18 
19 
20 if __name__ == '__main__':
21  Responser()


jsk_network_tools
Author(s): Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:07