Skip to content

Development

Ossian Eriksson edited this page May 27, 2021 · 8 revisions

This page assumes you have gone through the steps in Getting Started. If you don't have write permissions on this repo you should fork it and continue working in your fork. You can later ask to integrate the changes made in your fork into this main repo through Github's pull request system. If you think you should have write access to the original repo please contact someone who worked on the project previously with full access.

Visual Studio Code

Install Visual Studio Code (code) with

sudo snap install code --classic

The first time you format a python file in code, select autopep8 as your formatter.

Recommended Code Extensions

  • Markdown All in One: Used to generate table of contents in README files

  • Clang-Format: Formatting of C++ files, the following .clang-format file has been used:

    BasedOnStyle: LLVM
    
    IndentWidth: 4
    
    ConstructorInitializerAllOnOneLineOrOnePerLine: true
    BreakConstructorInitializers: BeforeColon
    
    AllowShortLoopsOnASingleLine: true
    AllowShortBlocksOnASingleLine: true
    
  • XML: Formatting of .launch files

Code Style and Conventions

Make sure you have some basic knowledge of how ROS structures code and packages. Here is some suggested reading if you are just getting into ROS:

Git

Setup

Set git configuration options:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

Branches

All development should be done in a branch separate from master. Currently there is only two types of branches:

  • master: Stable, tested production code. This branch is persistent
  • gh-pages: Used to host Github pages, largely managed by Github actions/accounts
  • dev-<some-description-here>: Implementation of a single feature, fix of a single bug or similar isolated code update

Workflow

Basic git things. If you are using code you can do a lot (maybe all) of the following directly from the editor without interfacing with the terminal.

  1. After cloning the repo (see Getting Started), create a new branch for development with

    git checkout -b dev-<some-description-here>

    replacing <some-description-here> for example like so: git checkout -b dev-rewrite-controller-node.

  2. Commit your updates (read about commits online if you haven't worked with git before, for example here) often and write commit messages in English:

    git commit -m "<Commit message here>"
    

    for example git commit -m "Fixed causing latency bug in controller".

  3. To make your branch visible on Github, run

    git push -u origin <branch-name>

    and then optionally call git push periodically to update the remote branch with your latest changes. To view the code on Github, you need to select the corresponding branch.

  4. When you are done with your implementation and have run tests on it and old code to make sure everything still works (catkin_make run_tests), open a pull request from your branch to master. Cloud based tests will automatically run on your pull requests. If the tests pass or you feel very confident the code is safe you can immediately merge the pull request for now and then delete your original branch from Github. The branch will still be available on your local computer.

  5. To prepare for starting the cycle over run

git checkout master
git pull

to pull updates to the master branch from Github. The changes you made in your own branch should now be available to you in master on your local machine. You are now ready to start over from step 1. with your next update!

Useful Git Commands

  • git status: What's the status since the last commit?
  • git checkout <branch-name>: View code from another branch
  • git branch: What branch am I on?
  • git reset HEAD~: Undo last commit
  • git add <file/path>: Tell git to track history of file
  • git merge <branch-A>: Merge branch-A into current branch. Read up on merging before you use