ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS2 Project Structure

asked 2021-02-18 05:25:16 -0600

NotARobot gravatar image

updated 2021-05-28 00:23:09 -0600

jayess gravatar image

I try to develop a project with ROS2. At the moment I am struggling with a project structure. My goal is in a way similar to the TurtleBot3 simulation.

I want to create a ready to use simulated test environment with ROS2 and Gazebo within a single package in order to be as much 'stand-alone' and tidy as it gets. I found there is something along these lines in ROS1 if I read Package Organization For a ROS Stack correctly.

Unfortunately, I am new to ROS or ROS2 for that matter, so I am unaware how to realize my goal or if it is even possible.

My Idea was to structure the package as follows:








---_ _ init _









The reason is, I don't want this package to mingle with other packages in the src directory to avoid confusion and eventual side effects. This is because I want to borrow and append on code from the Turtlebot3 simulation but keeping the original as is (robot model, world, nav2, slam). However I have read ROS2 colcon build not getting subfolders and compared with the package organization mentioned before, it is not possible to build nested packages.

Could you recommend a way for organizing ROS2 projects in a tidy and obvious manner? Is there a way to not have all packages side by side on the src directory level, but integrated in their superior package?

Because the Turtlebot3 simulation provides a structure more or less similar to the suggested package organization in ROS1 I gave it a closer look, but to be honest, I am not able to grasp all of the concepts they are using.

Your help and suggestions are much appreciated.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2021-05-27 11:24:39 -0600

NotARobot gravatar image

Thank you for your answers, they brought me on the right track.

I solved it in via the creation of a secondary workspace, just for my code and augmenting the turtlebot code before using it in my application. With this i have two working workspaces and can source them independently, also I can have my workspace tidy by applying structure. Now I have sub-packages in parallel as required but I have one my_sim_bringup, for the applications start sequence and in the same style my_sim_gazebo, my_sim_robots, my_sim_slam for each aspect of the project.

edit flag offensive delete link more

answered 2021-03-08 13:52:02 -0600

phillipov gravatar image

Nested packages aren't the right way to keep "tidiness" in your ROS2 workspace. Instead, you can keep multiple packages in one git repository. You can nest directories as much as you want inside of ros2_ws/src, but you can't nest packages.

        my_sim_env (GIT REPO)

Notice how there is no package nesting.

edit flag offensive delete link more

answered 2021-03-08 10:58:42 -0600

jdlangs gravatar image

Normally a ROS "project" is a single version-controlled repository that might be just one package but could also be several packages. Often it also has source dependencies that need to be built in the same workspace but are outside of the project repository. It looks like you will be reusing bits from the turtlebot3 repository, so you should keep that as a separate repository, alongside your own underneath the workspace src/ directory. You should not attempt to make a workspace with nested packages.

Your question in written somewhat vaguely, so it's not fully clear what level of advice you're looking for. If you'd like to elaborate about specific things you're not sure about, we can go into more detail then.

edit flag offensive delete link more

Question Tools



Asked: 2021-02-18 05:25:16 -0600

Seen: 1,536 times

Last updated: May 28 '21