Skip to content

coding_environment

marhcouto edited this page Jan 11, 2024 · 1 revision

Coding environment

This tutorial aims to aid in teaching the developer how to use multiple tools established for this project, as well as creating the base environment for the project and understanding the project's structure.

Links

Git

If you already use git and github, you can skip this step. If you use windows, make sure to be inside your wsl for this.

Installation

sudo apt install git

Configuration

Configure according to github account. For global configuration:

git config --global user.name "username"
git config --global user.email "useremail"

To configure independently per project:

git config user.name "username"
git config user.email "useremail"

SSH connection to Github

  1. Generate ssh key pair:

    ssh-keygen -t ed25519 -C "[email protected]"

    You can leave the default file. Setup password if you wish.

  2. Start the ssh-agent in the background:

    eval "$(ssh-agent -s)"
  3. Add the ssh key to the agent:

    ssh-add ~/.ssh/id_ed25519
  4. Copy the SSH public key to your clipboard:

    cat ~/.ssh/id_ed25519.pub
    # Then select and copy the contents of the id_ed25519.pub file
    # displayed in the terminal to your clipboard

    Tip: Alternatively, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

  5. In the upper-right corner of any page, click your profile photo, then click Settings.

    Screenshot of GitHub's account menu showing options for users to view and edit their profile, content, and settings. The menu item "Settings" is outlined in dark orange.

    Screenshot of GitHub's account menu showing options for users to view and edit their profile, content, and settings. The menu item "Settings" is outlined in dark orange. In the "Access" section of the sidebar, click SSH and GPG keys.

  6. Click New SSH key or Add SSH key.

  7. In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop".

  8. Select the type of key, either authentication or signing. For more information about commit signing, see "About commit signature verification."

  9. In the "Key" field, paste your public key.

  10. Click Add SSH key.

  11. If prompted, confirm access to your account on GitHub. For more information, see "Sudo mode."

For more details on that, checkout the Github tutorials: Generating a new SSH key and Adding a new SSH key to your GitHub account.

Cloning the project

Before anything else, you need to clone the project into your laptop using git. Simply hit clone in the home page of the project, select ssh, copy the command and run git clone, or:

git clone [email protected]:fsfeup-driverless/driverless.git

Project Structure

This project is divided into multiple folders inside src folder. Each of these folders contain a ROS2 package. Essentially, the project is composed of multiple ROS2 packages whose nodes interact with each other in runtime. More details on the system's architecture can be found in here.

Notes on C++ Modules

  • Each module is divided into three folders:
    • src: executables *.cpp files
    • include: libraries and headers *.hpp files
    • test: test files
  • CMakeLists.txt is used as a build system (ROS2 default): it is a tool used to generate makefiles for c++. Everytime you creat e a new .cpp file, it must be added to the list of executable files in this CMakeLists.txt

Coding Environment

In order to properly contribute to this project, a code editor or IDE is suggested. In this tutorial, some suggestions for an environment will be presented.

VSCode

Visual Studio Code is a general purpose IDE very widely used. VSCode is our choice due to the great quantity of extensions available, namely:

  • extensions for ROS environment and ROS2 syntax
  • extensions for C++ and Python syntax check
  • overall simplicity and great array of tools

Steps:

VSCode in WSL

To get VSCode inside wsl, simply run code inside WSL and it will install the dependencies necessary and connect to the existing installation of vscode on the Windows system.

The rest of the tutorial should be followed using the WSL environment through the terminal. Only perform one of the alternatives.

Clone this wiki locally