Laser scan topic returns many messages
I am using a very simple subscription to a /scan topic to get the laser distances that my hokuyo laser scanner has grabbed, using:
scan_msg = rospy.Subscriber("/scan", LaserScan, scan_message, queue_size=1)
but when I print out the returning message I get 3 message packets, not 1 as expected. Why?
Code:
rospy.init_node("node1")
def scan_message(msg):
laser_range = msg.ranges
print "Range: ",laser_range
scan_msg = rospy.Subscriber("/scan", LaserScan, scan_message, queue_size=1)
Result:
Range: (inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, 2.886342763900757, 2.874502420425415, 2.8628132343292236, 2.8512728214263916, 2.839879274368286, 2.828630208969116, 2.817523241043091, 2.8065567016601562, 2.7957284450531006, 2.785036087036133, 2.7744781970977783, 2.764052629470825, 2.7537574768066406, 2.743590831756592, 2.733551025390625, 2.7236363887786865, 2.7138447761535645, 2.7041749954223633, 2.694624900817871, 2.6851933002471924, 2.6758782863616943, 2.6666784286499023, 2.657592296600342, 2.648618221282959, 2.6397545337677, 2.631000280380249, 2.6223537921905518, 2.613813638687134, 2.6053783893585205, 2.5970470905303955, 2.588818073272705, 2.5806901454925537, 2.572661876678467, 2.564732313156128, 2.5569002628326416, 2.549164295196533, 2.5415234565734863, 2.5339765548706055, 2.526522397994995, 2.5191597938537598, 2.511888027191162, 2.5047056674957275, 2.4976117610931396, 2.490605354309082, 2.4836854934692383, 2.476851224899292, 2.4701013565063477, 2.463434934616089, 2.4568514823913574, 2.4503495693206787, 2.4439284801483154, 2.4375874996185303, 2.431325674057007, 2.4251420497894287, 2.4190359115600586, 2.41300630569458, 2.407052516937256, 2.4011738300323486, 2.395369529724121, 2.389638662338257, 2.3839805126190186, 2.378394365310669, 2.3728795051574707, 2.3674352169036865, 2.362061023712158, 2.3567559719085693, 2.3515193462371826, 2.346350908279419, 2.341249465942383, 2.336214780807495, 2.3312461376190186, 2.326343059539795, 2.3289997577667236, 2.3506991863250732, 2.3728525638580322, 2.3954737186431885, 2.418576717376709, 2.4421770572662354, 2.466289758682251, 2.490931749343872, 2.5161192417144775, 2.541870594024658, 2.568204164505005, 2.5951387882232666, 2.622695207595825, 2.6508941650390625, 2.679757833480835, 2.7093093395233154, 2.739572763442993, 2.770573377609253, 2.802337646484375, 2.8348937034606934, 2.8682701587677, 2.902498245239258 ...