In course Python 3 for Robotics, Unit-2 Basic concepts, in exercise 2.1.
We have created a python script as
from robot_control_class import RobotControl
rc = RobotControl()
a = rc.get_laser(360)
print ("The distance measured is: ", a)
So I try to look RobotControl class in its module, the get_laser() is defined as:
def get_laser(self, pos):
time.sleep(1)
return self.laser_msg.ranges[pos]
How to understand ‘self.laser_msg.ranges’?
- what is ‘self’ module means?
- inside ‘self’, there is ‘laser_msg’, is this a class? And how this is defined?
- I guess ‘ranges’ is calling the LaserScan class from sensor_msgs? But is only explained as ‘float32 ranges # range data [m] (Note: values < range_min or > range_max should be discarded)’ in LaserScan, where is the code really read the measurements from laser ray?
Your help and answer is appreciated!