Software Engineering for Robotics (SER)
This is a first-semester mandatory course in the Master of Autonomous Systems program at Hochschule Bonn-Rhein-Sieg. I taught this course for the first time in the winter semester 2023/24, under the official name “Advanced Software Technology.”
Description
In the course, I focus on techniques and tools that are specifically used for developing software for autonomous robots. The following are some of the questions that we address in the course:
- Is developing software for robots different from developing other types of software?
- (How) Can traditional software development techniques be used in robot software development?
- What kinds of software architectures are there in robotics?
- What are some commonly used tools for developing robot software?
- How can simulations support robot software development and testing?
- Does anything change in the software development approach when learning-based components are used on a robot?
Lectures
The following topics are covered in the course:
- Robot software development introduction
- Robot software architectures
- Tools for robot software development
- Software engineering methodologies
- Software design patterns (invited lecture)
- Software development lifecycle
- Simulation-based robot software development
- Robot simulation tools (practical session)
- Quality assurance and testing (in-class discussion)
- Multi-robot software development (in-class discussion)
- Data-driven robot software development
- Metaprogramming and introspection (practical session)
Lab classes
Exercise 1: Robotic system design based on high-level requirements
In this exercise, you will get a little bit of practice in obtaining requirements for a robot applied to a particular domain and then designing a software system for solving that problem.
Please follow the steps below in this exercise:
- Interact with ChatGPT and ask it to describe a problem where a robot should be used (e.g. a robot that works in an office environment and delivers coffee to people).
- The problem that ChatGPT has given you contains requirements for your robotic software system; use these requirements to design a software architecture for a robot that can be used to satisfy those requirements. Here, don’t just think about the technical aspect of your system, but also about who is supposed to be using the robot, and how.
- Document your system design in a diagram (e.g. using https://app.diagrams.net)
At the end of the exercise, upload:
- A markdown (.md) file containing your interaction with ChatGPT
- An image or pdf file containing your system design
Exercise 2: System design continued (using UML)
In the previous exercise, you obtained the requirement for a robotic system and started working on an architecture for that system. In today’s lab class, you need to continue with the modelling of that same system, but now using the modelling knowledge that we acquired in today’s lecture, specifically using UML diagrams.
Your concrete task is to:
- Create a system architecture for your robotic system using a UML class diagram
- Pick one or more of the other diagram types (use case, activity, sequence, state) and create for one some concrete functionalities of your system (e.g. a sequence diagram for how a user of your robotic system sends a task request to a robot). Feel free to be creative with the choice of functionalities.
You can use any tool you want for creating the diagrams (e.g. using https://app.diagrams.net). At the end of the exercise, upload the diagrams you created (as pdf or image files).
Exercise 3: ROS practice
In this exercise, we will practice using ROS2 a little bit. The concrete objective of the exercise is to develop a collection of ROS2 packages that simulate task execution on a mobile manipulator, namely a robot that can move around and manipulate objects.
Your ROS system should include:
- Packages for different actions that the robot can perform (e.g. move, perceive_plane, pick, place) — one package per action. Each package should expose a single node in which the action execution is simulated. For this, the node should be have the following features:
- The node should subscribe to a message that invokes the respective action.
- If the action is called, its execution should be simulated, for instance by publishing an “executing” status message for a given time period.
- At the end of the execution, a “completed” message should be sent on a given topic.
- A robot package, which has a single node that simulates task execution (a task being an ordered sequence of actions to be executed). In particular, the node should be able to publish action messages, wait for the action execution to be completed, and then send the next action to the robot.
You don’t need to submit anything for this lab class exercise, but we will discuss your solution at the end of this class or during the next lab class.
Exercise 4: ROS practice continued
This exercise is a continuation of the previous lab class exercise, where we developed different ROS packages, each of which exposes a particular robot action, as well as a robot package that simulates task execution.
In this exercise, your objective is to modify your implementation of the robot actions so that they are implemented using ROS actions rather than through topic subscribers. The implementation of the task executor will need to be adapted accordingly, so that ROS action requests are sent to the actions rather than as published messages.
You don’t need to submit anything for this lab class exercise, but we will discuss your solution at the end of this class or during the next lab class.
Exercise 5: Agile development practice
This lab class exercise is a continuation of our first few lab classes, namely we follow up on the design of your robotic system, such that we will use some agile development practices today.
The following are the concrete tasks you need to do:
- Create a few user stories (at most 5) for some of the requirements of your system (obtained in our first lab class).
- Given the requirements (now expressed as user stories) and the system architecture designed in a previous lab class, define your product backlog, i.e. create issue cards for implementing specific components in your architecture. You are free to choose a tool for creating the issues; you can also just use markdown files (one per issue).
- Pick one simple component and work on a mock implementation of it by doing pair programming.
At the end of the class, please upload:
- Your user stories (ideally, each story should be an individual markdown file)
- Your issue cards (depending on how you created them, in a PDF file or as markdown files)
Exercise 6: Property-based testing
In this exercise, we want to explore property-based testing a little bit.
Concretely, install the Hypothesis library in Python and then integrate some property-based tests in your testing code from the second assignment.
You are free to choose which tests you adapt for this purpose, as well as which properties you test specifically.
Assignments
Assignment 1: State machines and behaviour trees
In this assignment, we will compare the implementation of behaviour trees and state machines to establish primary safety features for a robot; this includes situations such as the battery level falling below a certain threshold and avoiding potential collisions. In other words, we want to implement both a behaviour tree and a state machine to achieve the same functionality.
We particularly want the robot to behave as follows:
- The battery level falling below a given threshold: The robot starts rotating in place until the level is above the threshold again (you can control the battery level by publishing to a topic you define).
- A collision is about to happen: The robot stops moving and needs to be moved to a safe distance manually.
You will use the Robile simulation for testing your implementation. For your submission, you need to add your code to the appropriate cells in the assignment Jupyter notebook; however, note that, to actually test your implementation, you need to integrate the code in a ROS package and perform all tests on your local machine.
Detailed instructions for the assignment are provided on Jupyter Hub; the submission should also be done there.
Assignment 2: Testing and quality assurance
This assignment is concerned with software testing and (code) quality assurance. The assignment builds on your first course assignment (where you worked with state machines and behaviour trees), such that the objective is to embed the software you developed there into a continuous integration workflow where your software is tested and the quality of the code is evaluated.
The following are your concrete tasks in this assignment:
- Form / join a team in our GitHub classroom; you will get an empty GitHub repository for your team. Push your code from the assignment on state machines and behaviour trees to your repository.
- Implement some tests for your components (unit, but also integration). Feel free to decide which aspects of your code you will test (e.g. whether you handle the sensor data correctly, whether your state machine / behaviour tree has the correct states / behaviours, etc.). For testing, I recommend using the unittest Python library, but you can also explore other alternatives if you want.
- Set up continuous integration in your repository. The continuous integration process should execute your unit tests so that you can ensure that any changes made to the implementation do not break the tests. Since we are using GitHub, you should use GitHub CI for this purpose.
- In your final task, you need to:
- Develop some new functionality for your robot; feel free to be creative about this. The functionality should be developed on a feature branch in your repository.
- Update your unit tests so that the new components are covered by the tests.
- Once you are done with the implementation, create a pull request and merge it only once you have resolved any test issues.
To test the robustness of your workflow, you can, for instance, push some changes that should break some of your tests and create a pull request.
In your submission, add the URL of your repository. Please also upload a directory of screenshots which show that unit tests are executed when you push changes to your repository.
Assignment 3: An investigation of simulators
In this exercise, you will explore the use of different simulators for setting up a robot and interacting with it on a simple point-to-point navigation task. We are particularly aiming to explore how the Robile can be set up and used in different simulators. Each group will work with a different simulator (PyBullet, Webots, MuJoCo, CoppeliaSim, or Chrono). We will not use Gazebo in this exercise since you are already familiar with it — one group will have an unfair advantage.
Detailed instructions
Here are some steps to follow during the assignment:
- After installing the respective simulator on your system, figure out what programming interface is available for it (what kind of API is there, can you use ROS, etc.).
- If the simulator supports URDF, import the Robile URDF directly; otherwise, find out whether the simulator uses another description language and whether there is a built-in URDF conversion utility. Only if neither of the two conditions are satisfied, you can use a simple robot model that is available in the simulator.
- Once you have a robot model, set up an environment for the robot (if URDF is supported, you can import one of the environments that we use in the Gazebo simulation).
- The final step is the most involved: You need to write software so that you can send motion commands to the robot and perform obstacle avoidance. During this step, particularly see how you can obtain laser measurements so that you can also perform obstacle avoidance (this should, in principle, be easy if the simulator supports ROS).
Submission
First of all, please make sure to push everything you develop to the repository that you set up in the previous assignment.
Additionally, in the assignment Jupyter notebook, submit any code you develop in the assignment, and please submit a screen recorded video to demonstrate your robot in action (you can also upload the video externally, e.g. on Google Drive, and provide a link to it).
Assignment 4: Multi-robot systems
This assignment is a continuation of your assignment on testing and quality assurance, such that the objective is to extend your software so that you can have a multi-robot system. Your particular objective is to develop a functionality based on which robots move side-by-side with a predefined distance between them; in other words, when you then send a goal pose to one of the robots, all other robots should follow along.
Once you develop your functionality, add some unit tests for it, in particular:
- A test to verify that the expected number of robots are available in the environment.
- Another test to verify that the distance constraint is satisfied throughout the motion of the robots. This test should use data recorded from multiple runs of your multi-robot system (with different numbers of robots).
As before, add your new features to your repository with a pull request.
Submission
In the assignment Jupyter notebook
- Add the URL of your repository (please use the same repository that was created for the testing and quality assurance assignment).
- Add a URL of a short screen recording video demonstrating the multi-robot functionality (in particular, show that the functionality does not depend on how many robots are spawned).
- Please also upload screenshots which show that unit tests are executed when you push changes to your repository; include those screenshots in the cell below as well.