- 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.
- Install vs-code editor on your ubuntu 20.04 host OS : https://linuxize.com/post/how-to-install-visual-studio-code-on-ubuntu-20-04/
- Install docker on your ubuntu 20.04 host OS : https://docs.docker.com/engine/install/ubuntu/
- Please remember to follow all the steps in docker installation, and verifying it's successful installation @ https://docs.docker.com/engine/install/ubuntu/#next-steps > https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user (Step 1 2 3 4)
- Install following extensions on your VSCode:
- Clone this repository using:
git clone https://github.com/vedran97/ros2-workspace-template.git
- 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
- 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
- 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
- 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
- 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!
- 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
toARG 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 - Follow the Initial Setup headline's from step 6