Robotics StackExchange | Archived questions

The callback is updated later

class Laser:

    def __init__(self):

        self.sub = rospy.Subscriber('front_laser/scan', LaserScan, self.laser_callback)

    def laser_callback(self, scan):

        print "rango 340: " +str(scan.ranges[340])

        ... DoSOMETHING ...

if __name__ == '__main__':
    rospy.init_node('laser')
    Laser()
    rospy.spin()

When I execute the node, the print in the callback is updated later with the correct data and I don't know if it is for my code (DoSOMETHING) does many things, my computer is not very powerfull or something wrong with ros - No such check - . If I remove DoSOMETHING, the print is updated correct, but I need doing DoSOMETHING.

My computer is:

model name : Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz

cpu MHz : 800.000

cache size : 3072 KB

RAM : 6 G

I use gazebo simulator with Pioneer 3dx and hayuko laser.

Example: In Gazebo has:

robot ------(range:5)----->

in shell:

5 5 5 .....

You move the robot in gazebo:

robot ----(range:3)-->

in shell:

5 5 5 (after a few seconds) 4 4 3 3 3

Any Ideas?

Sorry for my English and thanks for your answers

Asked by Lucer on 2016-08-08 03:15:52 UTC

Comments

Answers