Robotics Software Tips and Tricks

From Control Systems Technology Group
Jump to navigation Jump to search

Intro

This page lists various software tips, tricks and tools that can come in handy during robot development. Feel free to add your tips and tricks to this list!

General

A lot of robotics software runs on Unix-like operating systems based on the Linux kernel. One of the most familiar operating systems is Ubuntu. Be sure to familiarize yourself with Ubuntu and shell usage.

Dual-boot?

Many 'roboticists' dualboot their PCs with Windows and some version of Linux. If you decide to do so, be sure to backup well first. It used to be quite hard to do a dual boot with encryption on both systems, but with the recent Ubuntu installer that has gotten much easier. See https://www.mikekasberg.com/blog/2024/05/20/dual-boot-ubuntu-24-04-and-windows-with-encryption.html.

Single repository version management

Learn git! https://git-scm.com/book/en/v2

Merging vs rebasing

Merging combines two branches by creating a new commit that merges changes, preserving the history of both branches. Rebasing writes commit history by applying changes from one branch onto another, creating a linear history without merge commits. Please simply use 'merging' in your robotics code, the full history is preserved and could help to backtrack things.

Multiple Repository version management

Robots often use multiple repositories at the same time. Managing all these repositories by hand or with custom scripts can be tricky. Fortunately, various tools can be utilized.

VSCTool/wstool

VCStool can read .rosinstall files and clone all the repositories in those files. An example with the older wstool can be found in the https://gitlab.tue.nl/robotics/robots/curain the develop branch. See the Docker file where wstool is invoked to clone multiple repositories as specified in the .rosinstall file

TUE-env

TUE-env was created by the Robocup @Home student team. It consists of a number of bash scripts which install so-called targets which specify what to install in a .yaml file. See for example the .yaml file of Amigo. If you adopt tue-env, you must probably create your own targets, as those of the Robocup team are probably not useful to you.

Git Submodule

Git submodules are one way git allows having a repository in another repository. You could, for example, have one 'robot' meta-repository, which has several sub-repositories integrated as git submodulus. Git Submodulus allow you to fetch and update upstream changes of the submodulus.

Git Subtree

Git Subtrees can be used to 'copy' one commit of an existing repository to your repository.

Subtree vs Submodule

For an interesting discussion on subtrees or submodulus, see https://stackoverflow.com/questions/31769820/differences-between-git-submodule-and-subtree. Because development in robot software usually takes place in multiple repositories, keeping a link which can be updated easily to the original repository using submodules seems useful.

Random nice tools

Terminator for managing multiple terminals in one Window (super nice)

Zerotier for creating simple networks without hassle

Nano terminal editor for quickly editing text files in terminal, also very useful over SSH

System dependency management (Docker/containerization)

Robot software is often built for specific OSes, build configurations and dependency configurations. This limits usability by different users, who will run other OSes, systems and who will not have all the required dependencies. Of course, these users could switch to the correct build system and tools, but often, this would result in conflicts with their existing software.

To combat these drawbacks; one could opt for virtual machines. However these run often quite heavy usually degrade performance noticeably.

Containerization is one of the lightest forms of abstracting the software and its dependencies from the host OS. Docker is often used for containerization purposes. If your software runs in Docker, every user that also wants to run your software, can do so by having a working Docker installation, either on Windows, Ubuntu or MacOS. Docker results in very little performance degradation.

An example of Docker usage is the cura-mega-legacy package. This package installs all the software components needed to run CURA in a Docker image. See the Dockerfile and the docker-compose.yaml in the root of CURA. Even though the CURA software uses ROS1 and an older Ubuntu version, this way it still can be ran in a safe and easy way.

Development dependency management

Docker also supports mounts to the operating system. This is often used for development in so called 'development containers'. Very useful to develop anything on any system, without having to switch system to be able to run certain dependencies. cura-meta-legacy also contains two examples of these development containers, see the .devcontainer/devcontainer.json file.

Remote development

Robotics often contains software which integrates components on robots, that run their own PCs. It can be very valuable to be able to access a robot to do development in several ways.

SSH & SFTP

SSH is simply a way to create a tunnel to the robot and use its shell. With SFTP you can mount a folder or disk from the robot, via the network, to your own PC.

Remote development

VSCode supports development over SSH on a robot. See https://code.visualstudio.com/docs/remote/ssh. It even supports development over SSH in a container on the robot.