Organize folder in a workspace?

Hi,

I see in documents, you usually put python code in the scripts folder instead of the src folder.
Could you share the reason why you do it?
Is it a way to organize folder in reality?

Yes, it’s an attempt to organize folders in reality, but can you give a specific example for better context?

No, I am a newbie. I just wonder if you will organize folders as same as the course in reality. And in reality, what will you organize? and Why?

Don’t bother so much about this now, just keep learning. You will be able to figure it out along the line, as you increase your learning.

1 Like

Hi @NguyenDuyDuc

Let me explain how we manage ROS workspace

In ROS (Robot Operating System), the convention of separating code into different folders within a ROS workspace, such as src and scripts , is a matter of organization and helps to maintain a clean project structure. While these conventions are not strictly enforced by ROS itself, they are widely adopted by the ROS community for clarity and consistency.

Here’s a brief explanation of the common usage of the src and scripts folders:

  1. src (Source) Folder:
  • The src folder typically contains the source code of ROS packages. This is where you put the source files of your ROS nodes, libraries, and other components.
  • ROS packages often include C++ or Python source code that implements the functionality of the robot or system.
  • The src folder is where you organize your code into packages and modules.
  1. scripts Folder:
  • The scripts folder is commonly used for storing executable scripts or simple utility programs written in scripting languages like Python.
  • These scripts are often standalone and may not be directly integrated into the ROS build system as nodes or packages.
  • Scripts in the scripts folder might be used for various tasks such as data processing, analysis, or simple automation tasks that are not part of the main ROS nodes.

So this is how we maintain our ROS workspace

Regards
Raunak Abhani

1 Like

Hi @NguyenDuyDuc

Yeah, your question is valid. Before doing my course of ROS2 python, I was also very inconsistent with the placement of python script file, my mission was just to make the package work correctly. So I also had difficulty adopting this method. But so far it worked perfect, so I just got along with it.

So your question was

I see in documents, you usually put python code in the scripts folder instead of the src folder.
Could you share the reason why you do it?
Is it a way to organize folder in reality?

Actually, this is a convention that has been adopted by the ROS community for organizational purposes.
The src directory is typically used for C++ source files, while the scripts directory is used for Python scripts.

But yes, you can place your script file wherever u like.
But the exercise given for quiz will have some restrictions. Like, it will require that you have named the package, launch file and executable node as specified. Also, the gradebot checks that you have placed all the files in their respective places. Otherwise, it can fail your quiz. You know bots, they have clear instructions. So if you want to save time and don’t want to waste your attempt count due to such a minute error, then just follow the format given in the examples.

Also an advice, do keep in mind the grading steps given in the quiz instructions. The gradebot checks your package step by step, and if any step fails, then the following steps would be skipped and attempted would be wasted.

Hope it helps u around the course.
Regards,
Awais Adis

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.