Rémi Saurel

Petri Nets

Big news for this year 2015, the code embedded in the robots runs with a Petri Net implementation created by me. This tool allowed us to managed both hands of one of the two robots, graphically and in a thread-safe way. These hands indeed needed a software synchronization, to provide a correct behavior and avoid any physical failure. All of the remaining high-level logic has equally been implemented using Petri Nets.

The theory

Petri Nets (also know as Place-Transition Nets) are one set of Places combined with a set of Transitions. A place is typically given an action (e.g. start an electrical motor), while transitions check that all conditions are met to allow others places to be executed.

Running multiple places concurrently is of course allowed by the implementation, and becames very useful in automatic control (we can move one part of the robot while another one works on something possibly unrelated). There exist multiple methodes allowing to prove the correctness of a Petri net, making use of such tool particularly on spot for a real-time, reliable application.

The project

I have created on my free time a graphical editor, written in C#, which tops at more than 10k lines of code. The runtime, written in C++ and totalling about 2.6k lines of code makes possible the execution of Petri Nets and their integration in existing projects, here the robotic club code.

The editor auto-generates the C++ source code, then compiles it as a shared librairy (dynamic librairy, depending on the terminology) and helps following its execitiont. The integrated debugger displays the currently active places, adds breakpoints on the specific places deignated by the user, and performs dynamic evaluation of some arbitrary C++ expressions in the main program (displaying the return value of a C++ function at will, for example). The main point about a shared library is that the user can choose to update the Petri Net, re-generate and compile the code and then have the main program reload it and execute it without having to relaunch it, and nevertheless immediately accessing the changes.

Written in C#, the editor uses the well known Mono and Gtk# frameworks, thus it is multiplatform and has been successfully tested on Linux, OS X and Windows (for Windows, only opening and modifying documents is provided, the other functionalities are written on top of the POSIX specification).

You can acces the source code here:https://github.com/rems4e/petri.

Screenshots

Down here, you can see the ditor GUI with a simple Petri Net opened. We can se two initial places (1 and 2), the bigger circle is a macro wrapping another Petri Net, simplifying the display for bigger nets.

The bottom panel displays search results of an expression in any entity (Action, Transition or Comment).

Interface du débuggueur

Down here the debugger GUI, which shows as green discs the active states at the time the screenshot was made.

The red circled states have breakpoints associated with them. We can see here that the execution is paused in one state, and that we can click on the "Resume" button to continue the execution.

Session de débuggage en cours