2 import roslib; roslib.load_manifest(
'openni_launch')
 
    5 from sensor_msgs.msg 
import PointCloud2
 
   17 rospy.init_node(
'test_sub')
 
   22 consecutive_failures = 0
 
   23 while not rospy.is_shutdown() 
and consecutive_failures < 5:
 
   27     ns = 
"depth_reg_%d" % attempt
 
   28     topic = 
"/camera/%s/points" % ns
 
   30     sub = rospy.Subscriber(topic, PointCloud2, callback, callback_args=received)
 
   32     command = 
"roslaunch openni_launch openni.launch depth_registered:=%s" % ns
 
   34     tmp = open(os.devnull, 
'w')
 
   35     p = subprocess.Popen(shlex.split(command), stdout=tmp, stderr=subprocess.STDOUT)
 
   38     while (
not rospy.is_shutdown()) 
and (time.time() < end) 
and (
not received[0]):
 
   40     duration = time.time() - start
 
   43     p.send_signal(signal.SIGINT) 
 
   46     if not rospy.is_shutdown():
 
   48             rospy.loginfo(
"Succeeded in %.1fs", duration)
 
   49             successes = successes + 1
 
   50             consecutive_failures = 0
 
   53             rospy.logerr(
"Failed!")
 
   54             failures = failures + 1
 
   55             consecutive_failures = consecutive_failures + 1
 
   59             with open(
"%s_%05d.log" % (status, attempt), 
'w') 
as f:
 
   61                 shutil.copyfileobj(tmp, f)
 
   64                 core_name = 
"core_%d" % attempt
 
   65                 os.rename(
"core", core_name)
 
   66                 print(
"Core dump %s" % core_name)
 
   70 print(
"Successes: %d" % successes)
 
   71 print(
"Failures: %d" % failures)