Ask Your Question
1

ROS2 Project Structure

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

NotARobot gravatar image

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

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:

ros2_ws/src/

-my_symulation_environment/

--recource

--test

--setup.py

--setup.cfg

--package.xml

--my_sim_environment

---_ _ init _ _.py

---my_sim_bringup

---turtlebot3_gazebo

---turtlebot3_msgs

---turtlebot3_description

---turtlebot3_navigation

---turtlebot3_slam

---turtlebot3_teleop

---my_sim_mycode

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
0

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

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
2

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

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.

ros2_ws
    src
        some_unrelated_package_a
            package.xml
        some_unrelated_package_b
            package.xml
        my_sim_env (GIT REPO)
            package_a
                package.xml
            package_b
                package.xml
            package_c
                package.xml
            sim_env_msgs
                package.xml
            sim_env_testing
                package.xml
            README.md

Notice how there is no package nesting.

edit flag offensive delete link more
1

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

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

Seen: 673 times

Last updated: May 28 '21