This repository serves as a template for creating ROS2 packages, equipped with a basic CI workflow and devcontainer configuration.
To begin development in a containerized environment:
-
Use this repo as a template (You only do this once!): 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
and thenCreate new repository
:Alternatively, you may choose to "Fork" the repository (read here about the differences)
Then, in the next step specify the owner and the repository name you want to create as shown below (You are recommended to make this a private repository until the marking of the assessment is complete):
You will end up having your own repository, which looks something like this:
-
Open in Visual Studio Code: Open your new repository in VSCode. The easiest way is to go to the git tab in VSCode and select
Clone Repository
and then copy the URL to the repository into the dialog that opens, e.g.https://github.com/marc-hanheide/my-cmp3103-ws
in the example case. Then, choose the local folder you want to repository to be checked out into and choose to open the new workspace.After cloning the repository and opening it, VSCode will prompt you if you want to "Reopen in Container", as it has found a devContainer configuration. You should say "yes". Alternatively if you don't see the prompt, you can use the command palette (
Ctrl+Shift+P
) and search for the "Reopen in Container" command. -
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. This may take a while (in particular if you have not previouly used the computer with the container), as you entire image with all installations is being pulled.
-
Verify Container Environment: After the build completes, VSCode will connect to the container. You can verify that you are within the container environment.
See bottom left, saying "Dev Container":
You can now open the virtual desktop (see next section) or a terminal in VSCode inside the DevContainer:
The devcontainer includes a virtual 3D accelerated (if the host has an NVIDIA GPU and docker runtime installed) desktop.
-
Accessing the Desktop Interface: Open the user interface by navigating to the
PORTS
tab in VSCode, selected the URL labeleddesktop
to open it in your browser. You can also right-click on the URL it and choose "Preview in Editor" to have that desktop shown directly in VSCode, instead. -
Complete the connection: Click on "Connect".
Your desktop will open. If you want the size of this virtual desktop to adjust automatically to your browser window, choose "Remote Resizing" in the options on the left hand side.
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.
You can now use the VSCode terminal to launch all the commands you need and run code directly from VSCode in your devcontainer. Any windows you open from the terminal or from your code will appear in the virtual desktop (i.e. you Browser).
All ROS2 packages should go into the src/
folder. Create them with ros2 pkg create...
.
The devcontainer installs 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.