def test_string_passthrough(self): # 20 seconds to validate fixture timeout_t = time.time() + 20. print "waiting for 20 seconds for fixture to verify" while not self.fixture_nodes_cb == self.nodes_set and \ not rospy.is_shutdown() and \ timeout_t > time.time(): time.sleep(0.2) self.failIf(timeout_t < time.time(), "timeout exceeded") self.failIf(rospy.is_shutdown(), "node shutdown") self.assertEquals(self.nodes_set, self.fixture_nodes_cb, "fixture did not validate: %s vs %s"%(self.nodes_set, self.fixture_nodes_cb)) # another 20 seconds to validate client timeout_t = time.time() + 20. print "waiting for 20 seconds for client to verify" while not self.test_nodes_cb == self.nodes_set and \ not rospy.is_shutdown() and \ timeout_t > time.time(): time.sleep(0.2) self.assertEquals(self.nodes_set, self.test_nodes_cb, "passthrough did not pass along all message") # Create a new Publisher here. This will validate publisherUpdate() pub = rospy.Publisher('string_in', String) msg = 'test_publisherUpdate' timeout_t = time.time() + 20. print "waiting for 20 seconds for client to verify" while not msg in self.nodes_set and \ not rospy.is_shutdown() and \ timeout_t > time.time(): pub.publish(data=msg) time.sleep(0.2)
def publisher(): rospy.init_node('string_publisher') pub = rospy.Publisher('string_in', std_msgs.msg.String) m = std_msgs.msg.String(rospy.get_name()) r = rospy.Rate(10) while not rospy.is_shutdown(): pub.publish(m) r.sleep()
def publisher(): rospy.init_node('testheader_publisher') pub = rospy.Publisher('test_header_in', rosjava_test_msgs.msg.TestHeader) r = rospy.Rate(10) m = rosjava_test_msgs.msg.TestHeader() m.caller_id = rospy.get_name() m.header.stamp = rospy.get_rostime() while not rospy.is_shutdown(): pub.publish(m) r.sleep()
def publisher(): rospy.init_node('int64_publisher') pub = rospy.Publisher('int64_in', std_msgs.msg.Int64) i = 0 r = rospy.Rate(10) m = std_msgs.msg.Int64(i) while not rospy.is_shutdown(): pub.publish(m) i += 1 m.data = i r.sleep()
def publisher(): rospy.init_node('composite_publisher') pub = rospy.Publisher('composite_in', test_ros.msg.Composite) r = rospy.Rate(10) m = test_ros.msg.Composite() m.a.x = random.random() * 10000. m.a.y = random.random() * 10000. m.a.z = random.random() * 10000. m.a.w = m.a.x + m.a.y + m.a.z m.b.x = m.a.x m.b.y = m.a.y m.b.z = m.a.z while not rospy.is_shutdown(): pub.publish(m) r.sleep()