Basic concepts_how to understand 'get laser'?

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’?

  1. what is ‘self’ module means?
  2. inside ‘self’, there is ‘laser_msg’, is this a class? And how this is defined?
  3. 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!

Hi @253874655,

Let me take a look and get back to you later today.

Hi @253874655,

Here the class is just used as an example. You will understand better when you get to the section called 5. Python Classes and OOP. Please try to ignore anything you don’t understand now and continue along - they will become clear along the way.

Apologies for any confusion.

1 Like