Action Exercise 4.2 what is the role of msg

In the snippet of

def cameraCallback(self, msg):
        self._lastImage = msg

What is here happening?

Hi @2657802376,

msg is the image taken by the camera. Each time the camera takes an image, it calls the cameraCallback function and passes the image to the variable msg. msg can be anything else you decide to call it. It could be image, picture, message, etc.

Also, cameraCallback is an instance function of a Python class, and we are setting _lastImage (an instance variable of the class) equal to msg. self is the keyword that refers to an instance of the class.

If you are not yet familiar with Python classes, I would suggest that you take the free Python for Robotics Course.

Please let me know if this clarifies.