Robotics Software Tips and Tricks: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
(Created page with "Initial text")
 
(→‎Random nice tools: added screen utility)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Initial text
== 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 ===
[https://github.com/dirk-thomas/vcstool VCStool] can read <code>.rosinstall</code> files and clone all the repositories in those files. An example with the older [https://github.com/vcstools/wstool wstool] can be found in the https://gitlab.tue.nl/robotics/robots/cura<nowiki/>in the develop branch. See the Docker file where wstool is invoked to clone multiple repositories as specified in the .rosinstall file
 
=== TUE-env ===
[https://github.com/tue-robotics/tue-env TUE-env] was created by the Robocup @Home student team. It consists of a number of bash scripts which install so-called [https://github.com/tue-robotics/tue-env-targets targets] which specify what to install in a .yaml file. See for example the [https://github.com/tue-robotics/tue-env-targets/blob/master/amigo1/install.yaml .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 ===
[https://git-scm.com/book/en/v2/Git-Tools-Submodules 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 ===
[https://www.atlassian.com/git/tutorials/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 ==
[https://gnome-terminator.org/ Terminator] for managing multiple terminals in one Window (super nice)
 
[https://wiki.debian.org/screen Screen] a utility to have multiple terminal instances within one terminal (shell). This way you can also disconnect from the machine you are connected to and leave the program running. Pro tip: Always use screen when updating / upgrading a system over SSH, because if the network gets reset during the upgrade, your upgrade process doesn't get interrupted with all the issues following that.
 
[https://www.zerotier.com/ Zerotier] for creating simple networks without hassle
 
[https://www.nano-editor.org/ 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 [https://gitlab.tue.nl/robotics/robots/cura/cura-meta-legacy cura-mega-legacy] package. This package installs all the software components needed to run CURA in a Docker image. See the <code>Dockerfile</code> and the <code>docker-compose.yaml</code> 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 [https://code.visualstudio.com/docs/devcontainers/containers 'development containers']. Very useful to develop anything on any system, without having to switch system to be able to run certain dependencies. [https://gitlab.tue.nl/robotics/robots/cura/cura-meta-legacy cura-meta-legacy] also contains two examples of these development containers, see the <code>.devcontainer/devcontainer.json</code> 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.

Latest revision as of 12:33, 23 October 2024

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)

Screen a utility to have multiple terminal instances within one terminal (shell). This way you can also disconnect from the machine you are connected to and leave the program running. Pro tip: Always use screen when updating / upgrading a system over SSH, because if the network gets reset during the upgrade, your upgrade process doesn't get interrupted with all the issues following that.

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.