Project - how to get the laser scan data in the service?

Yes, it’s doable without classes, you can use global variables. Here is what you need to do (I’m leaving you to figure the implementation out):

  1. Create a global variable, say msg, that will store the laser scan message.
  2. In the subscriber callback, update the global variable.
  3. Based on 1 and 2 above, the global variable msg will always contain the latest laser scan data, and you can access it within your service callback or anywhere else.

You can get some hints on using global variables in this post: Solution to Exercise 6.2 solution missing global