I created this repository , so that fellow ros2 developers have access to a dockerized ros2-foxy workspace on an ubuntu 20.04 base.
My goal is to include gdb , line coverage , cpp lint , gtest , ros package debian generation and sanitization.
This workspace can be minimzed and also be used for pure c++ development, using ros2 as a build and execute system.
I have added sample packages for understanding publishing and subscribing to custom ros2 topics.
I plan to add sample packages showcasing gtest, action server and other ros2 basics.
I might extend it to ros2 galactic, and I think it can be seamlessly done by replacing all references of foxy to galactic in the dockerfile and container setup scripts.
From the current working directory, cd to ros2-workspace-template repo which u just cloned
Open a terminal in ros2-workspace-template and type
code .
A VSCode popup should arise which says "Open folder in Container" where you choose Yes OR press F1,search for "Open Folder in Container" and execute the command
Now wait for the build process to finish, once it's completed, you have a fully functional ROS2 workspace with example packages
When the container is built for the first time, a error will popup saying "Failed to enable ROS Extension" , just choose the reload window option
Set up ROS dependencies using the following section
Setting up ROS-Dependencies :
Once the repo is opened in a container, you have to install ROS2-dependencies. To do this, follow these steps:
Press "Ctrl+Shift+B" to run VSCode tasks popup, choose "ROS: Install dependencies" option from it.
Wait for installation to finish,once it is done, now you can go ahead and install sanitization dependencies
Setting up Sanitizers :
Press "Ctrl+Shift+B" to run VSCode tasks popup, choose "C++: Install Sanitizer dependencies" option from it.
Wait for installation to finish,once it is done, now you can go ahead and build the packages inside the repos
Building Packages :
Press "Ctrl+Shift+B" to run VSCode tasks popup, and select "ROS:Build Package"
It will ask you to choose default build configuration, choose one and press enter
Then add the exact package name you need to build, and press enter.If u keep it blank, all packages shall build.
If the builds complete successfully, you have packages ready to use
Running Nodes :
Once done building quit the terminal session, open a new terminal instance(Ctrl+Shift+`), which will run ./bashrc configuration again and source all the recently built packages for you
This allows you to directly use "ros2 run package_name node_name" without specifically sourcing anything
Enjoy!
How do you reuse it ? :
Once you have cloned this repository and want to use it for your own project , first change this directory's name to whatever you want
Change line 55 of Dockerfile ARG WORKSPACE=/workspaces/ros2-template-workspace to ARG WORKSPACE=/workspaces/your_workspace_name
cd to this now renamed directory and delete the git artifacts by sudo rm -rf .git and then you are free to initialize your own git repository