0
$\begingroup$

Rosanswers logo

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.


Originally posted by NotARobot on ROS Answers with karma: 109 on 2021-02-18

Post score: 1

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

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.


Originally posted by jdlangs with karma: 971 on 2021-03-08

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by phillipov with karma: 31 on 2021-03-08

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by NotARobot with karma: 109 on 2021-05-27

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.