title: How to subsribe to a ROS topic for several seperate times?
body: <p>I have a scanlist of 5 positions for the robot to go. And for each position, I hope to subscribe to a topic to get the sensor data and add a marker in the rviz. Here is my code:</p>
  
  <pre><code>def addMarkerCallback(msg):
      draw_functions = DrawFunctions('visualisation_marker')
      if msg.data:
          draw_functions.draw_rviz_sphere(0.02)
      else:
          print 'no data'
  
  rospy.init_node("sensor_marker", anonymous = True)
  
  for item in scanlist:    
      moveit_cmd.go(item, wait=True)
      sub1 = rospy.Subscriber('sensor/right', SensorData, addMarkerCallback)   
      rospy.spin()
      print 'go finished' 
  </code></pre>
  
  <p>However when I run the code, the problem is the loop will always stay in the first iteration, so the robot will not go to the other positions in the scanlist. I guess it is the problem of rospy.spin(). Could anyone please tell me how to solve this problem...Thanks a lot! </p>