OpenSwarm: The open-source Operating System for Robots
What is OpenSwarm?
OpenSwarm is an easy-to-use event-driven preemptive operating system for miniature robots. It offers abstract hardware-independent functions to make user code more extendible, maintainable, and portable.
OpenSwarm has been designed, from start, as hybrid kernel and provides two execution models:
Multiple processes can be executed concurrently during a time interval. Preemption defines the reclaiming of used resources of a running process before it has finished. These resources can then be used by another process. Typically, preemptive scheduling is implemented in a time-slicing manner, where each process has a certain execution time before it is rescheduled.
Preemptive Scheduling requires threads with call stacks and, therefore, needs more time and memory. However, preemtive scheduled processes cannot monopolise computational resources and they are more efficient for computational intensive tasks.
Cooperative scheduling describes either run-to-completion tasks or tasks that hand over the used resources at pre-defined points. Event-based cooperative scheduling often describes short sets of instructions which are executed at the occurrence of events (not necessary sequentially).
Cooperatively scheduled task that runs to completion can monopolise the computational resources. This asynchronous execution model is difficult to maintain and debug. However, it requires only a little amount of computational overhead and is more efficient. It is usually faster as well.
The use of events is one of the main features of OpenSwarm. It enables:
Asynchronous Programming Models
Asynchronous programming describes the execution of function at the occurrence of signals, interrupts, or events. For example, while program A is executed, an interrupt occurs and executes the corresponding interrupt handler.
In OpenSwarm, this concept was adapted to provide software events, where a event handler function is executed at the occurrence of an even.
Inter-process Synch. & Communication
Events can be used to share resources and synchronise processes. For instance, process A wants to use resource R while process B uses it. As a result, A has to wait until B has finished using it. Similarly, events can be used to transfer data between processes. For example, if A needs results provided by B, A blocks/suspends until the results are ready.
OpenSwarm is designed to be adjustable and customisable, to provide the needed flexibility to solve a wide range of problems.
The scheduler is an algorithm that decides when and in which order a process is executed.
OpenSwarm gives the developer/user the possibility to change the scheduling algorithm as well as a structure that contains scheduling-specific values. This can be used to implement a different scheduling (such as real-time scheduling).
Pre-Processing Input Callback Functions
Each value received by an input device (such as an ADC) provides meaning-less values that need to be transformed/converted to meaning-full hardware independent values. For instance, a proximity sensor might return a value 3521. In OpenSwarm, this value gets then transformed into a meaning-full distance value (e.g. 5 cm).
This conversion is done by the pre-processor, which transforms the value before it gets received by any process. This function can be changed and customised by the user.
Note that you can use this function to implement filters, simulate other sensors, etc.
Post-Processing Output Callback Functions
Hardware-independent values cannot be applied directly to an output device (such as an DAC) and need to be transformed/converted. For instance, a motor should drive with 5 rpm. This value needs to be transformed into a hardware-specific value (such as 245 or is a sequence of steps).
This conversion is done by the post-processor, which can be changed and customised by the user.
Note that you can use the post processor to implement limitations, safety mechanisms, etc.
As a robot, the I/O management provides mechanisms to restrict, convert, or manipulate sensor or actuator values on a high abstraction level. These function can protect the robot of performing an action that would result in a malicious state of robot or task.
Most importantly, the operating system was designed for mobile robots and their need to interact with their environment.
Some features of OpenSwarm are: