Why .launch and .py both files?

Dear professor,
Why do we create python script and .launch file both. Can we not just create python file and the run it in the command window? Why do we have to create launch file and then run the python script with command roslaunch <package_name> <launch_file> ?

Thank you

Hello @abdulbasitisdost,

Because in ROS, you will usually have to work with launch files in order to execute the programs you create. You could directly execute the Python script without the launch file, for sure, but this is much more limiting. For instance, launch files allow you to execute multiple Python scripts at the same time, define arguments (variables) that your scripts will need, etc… You will see it more clear once you advance through the course.

Best,

1 Like