Abstract
Controllers for autonomous robotic systems can be specified using state machines. However, these are typically developed in an ad hoc manner without formal semantics, which makes it difficult to analyse the controller. Simulations are often used during the development, but a rigorous connection between the designed controller and the implementation is often overlooked. This paper presents a state-machine based notation, RoboChart, together with a tool to automatically create code from the state machines, establishing a rigorous connection between specification and implementation. In RoboChart, a robot's controller is specified either graphically or using a textual description language. The controller code for simulation is automatically generated through a direct mapping from the specification. We demonstrate our approach using two case studies (self-organized aggregation and swarm taxis) in swarm robotics. The simulations are presented using two different simulators showing the general applicability of our approach.
Introduction
In the development of autonomous robotics, particularly within swarm robotics, controllers are frequently constructed in an ad hoc fashion. While engineers may conceptualize a controller as a state machine, the transition to executable code is often manual. This manual translation introduces a "reality gap": a disconnect between the high-level formal model and the low-level implementation. Consequently, safety properties verified at the model level may not hold in the actual code. This paper introduces RoboChart, a framework designed to bridge this gap by providing a rigorous, automated link between formal specification and implementation.
The RoboChart Framework
The RoboChart framework provides a unified environment for robotic controller design, verification, and implementation. It utilizes a state-machine-based notation that is available in both graphical and textual formats.
As shown in Figure 1, the framework supports two primary outputs from the textual language:
- Code Generation: Automatic mapping of RoboChart elements to executable C++ classes. States become enumerated types, while operations (entry, during, exit actions) are translated into class methods.
- Semantics Generation: Translation into formal languages (based on CSP, or Communicating Sequential Processes) for verification tasks such as model checking and theorem proving.
The architecture follows a Model-View-Controller (MVC) pattern to integrate generated code into simulators. The "Model" encapsulates the generated controller and environment logic, while the "Controller" component implements the specific robotic platform interface (e.g., for an e-puck robot).
Modeling with RoboChart
RoboChart's notation is inspired by UML but tailored for the specific needs of robotics, including constructs for timed behaviors and probabilistic transitions.
Key features of the notation include:
- Interfaces: Defining the robot's capabilities (e.g.,
linearSpeed,angularSpeed) and events (e.g.,seeWall,seeRobot). - State Machines: Defining logic through states and transitions. As seen in Figure 4, the
AggregationFSMmanages transitions between statesS1andS2based on sensor events. - Timed Primitives: The
since(T)primitive allows designers to specify guards based on elapsed time, which the code generator translates into robust timer logic in C++.
Case Studies and Results
The framework was evaluated using two canonical swarm robotics case studies:
- Self-Organized Aggregation: 20 robots must form a single cluster using line-of-sight sensors. Using the Enki 2D simulator, the automatically generated code achieved successful aggregation in 10 out of 10 trials.
- Swarm Taxis: 20 robots navigate toward a beacon while maintaining group coherence. This was tested in the ARGoS 3D simulator, demonstrating the framework's applicability to complex, physics-heavy environments.
By separating the robot's interface from its logic, the same controller could be deployed across different simulators with minimal changes, proving platform independence.
Conclusion
RoboChart eliminates the manual labor of translating designs into code, ensuring that the resulting behavior matches the high-level formal design. Future work includes formally proving the soundness of the code generator, extending support for probabilistic logic, and deploying generated code onto physical hardware to test against real-world sensor noise and physics.
Summary updated