Confused with this code | Exercise 5.13 | Understanding ROS Actions - Servers

Hello, I often see this code, usually, I found it at the end of a program. I do not quite understand the function of this code. The one that I highlight.

Hi @sp_jason,
This line means, that if this python file is directly executed (it is the main file), then the code below gets executed. However, if you start a different script, and then import this file, then the code does not get executed. It is often used for modules like subscribers and action/service servers, that you later on will import, but want to test the functionality on their own.

2 Likes

Thanks! I got it now :grinning: