Skip to content

Setup of ROS2 workspace, Git, GitHub

Sreeram P edited this page Aug 1, 2024 · 2 revisions

Documenting how I setup the development environment to try out ROS2 coding samples!

  1. What is the development environment that I have in place
  • ROS2 Humble distro is installed within WSL2 environment (Ubuntu distro) in my Windows 11
  • VS Code is installed in Windows 11 and accesses the python code in WSL2 using WSL Extension in VS Code. (Video reference: https://www.youtube.com/watch?v=F3n0SMAFheM)
  1. Git was installed in Ubuntu within WSL2 for version control of your ROS2 code.
  • Set up Git user name and email: git config --global user.name "psreeram" git config --global user.email "my gmail id"

  • Create GitHub SSH keys cd ~/.ssh ssh-keygen -t ed25519 -C "my gmail id"

  • Copied the public key stored in ~/.ssh/id_ed25519.pub into clipboard. This will be used later.

  1. GitHub repo will be used for remote code storage and collaboration.
  • In my GitHub account, I created an SSH Key and copied the public key coped earlier.
  1. Created a new repo for my ROS2 example code in my GitHub account
  • Use "New Repository" button in GitHub and gave the repo name "coh45_ex1" and as a public repository and all other defaults. (I plan to use SSH commands to later push my local repo into this GitHub repo.
  1. In Ubuntu, created a new ROS2 workspace (one for each exercise so that Each workspace has its own independent build environment for isolation)
  • mkdir ros_rblabs_coh45_ex1
  • cd ros_rblabs_coh45_ex1
  • mkdir src
  • cd src
  1. Use the colcon build system to setup the ROS2 workspace cd .. (to move to the workspace level)
  • colcon build
  1. Created a new ROS2 python package within the src folder
  • cd src
  • ros2 pkg create --build-type ament_python coh45_ex1 with this step the ROS2 package is setup for the actual code addition
  1. Initialize Local Git Repository:
  • git init
  1. Commit your code changes in local repo
  • git add .
  • git commit -m "Initial commit"
  1. Push the existing local git repo (which means all the ROS2 workspace files) into GitHub
  • Test the SSH connection using the following command and check the success message ssh -T [email protected]
  • Add Remote Repository to the local git repo (this is using SSH and not HTTPS) git remote set-url origin [email protected]:psreeram/coh45_ex1.git
  • Push your code to the remote repository (GitHub) git push -u origin main
  • You can refresh the Github repo to see the whole ROS2 workspace files reflected there.
Clone this wiki locally