This repository serves as a template for creating ROS2 packages, equipped with a comprehensive CI workflow and devcontainer configuration.
To begin development in a containerized environment:
-
Use this repo as a template: The best way to work with this repo is to use it as a template for your ROS package development, to do so, in the top right corner select
Use this template
:Then in the next step specify the owner and the package name as shown below:
-
Open in Visual Studio Code: Open the cloned repository in VSCode. VSCode will prompt you to "Reopen in Container." Alternatively, you can use the command palette (
Ctrl+Shift+P
) and search for the "reopen in container" command.Then this will promote you with the following two options:
You may select the base image according to your targeted application. For instance, if the nodes do not require GPU processing tasks, it is preferable to use the default devcontainer as it is more lightweight.
-
Container Setup: Once reopened in the container, VSCode will initiate the building process and pull all necessary dependencies. You can monitor the building log within VSCode.
-
Verify Container Environment: After the build completes, VSCode will connect to the container. You can verify that you are within the container environment.
The devcontainer includes a light desktop interface. To utilize this feature:
-
Configuration: Add the following features to the devcontainer configuration:
"features": { "ghcr.io/LCAS/devcontainer-features/desktop-lite:1": {} }, "forwardPorts": [6080, 5801], "portsAttributes": { "6080": { "label": "desktop" }, "5801": { "label": "desktop opengl" } }
-
Accessing the Desktop Interface: Open the user interface by navigating to the PORTS tab in VSCode, selecting port
6080
(or port5801
for the CUDA-OpenGL version), and opening it in the browser. -
Connecting to the Interface: Click on "Connect" and use the password
vscode
to access the desktop interface.
By leveraging this setup, you can develop on a remote machine with a lightweight desktop interface. Magic! Furthermore, this template package provides very nice ROS2 functionality like syntax highlight and template code generation.
All ROS2 packages should go into the src/
folder. Create them with ros2 pkg create...
.
The devcontainer tries to install all dependencies of the workspace automatically as much as possible, and also tries to build the workspace when it is created, to speed up later colcon builds.