What is the use of while loop when sending action messages

Hi Izzat,
your question is very good. That part of code is just a dirty hack to avoid one problem of ROS.

It happens that, sometimes, when you try to publish in a publisher that has just been created, the connection to the publisher is still not completed, hence, your publish will fail. If you check the solution, you will see that the publisher is created just a few lines above that code that you are indicating.

In order to avoid that problem, we just decided to retry for 4 times, once every second. That ensures that the publish will be achieved.

That is a dirty solution! If you want the professional solution to that problem, check this other post of the Forum: How to publish once (only one message) into a topic and get it to work