Skip to content

Tailor-made Development of Safety-critical ML Controllers

Design and verification of cyber-physical systems

Example of an AI-controlled Cartpole system

The system consists of a movable, magnetically driven cart on an XTS transport rail from Beckhoff GmbH. A freely oscillating pole is mounted on the cart. Both the position of the cart and the angle of the pole are measured by sensors. The following sequence is to be executed:

  • Swinging up the poles using a sensor-based SwingUp model (position and pole angle).
  • Balancing the poles using the sensor-based balance model. This step is performed for a predefined number of time steps.
  • Balancing the poles using an image-based balance model (image processing can be done either via OpenCV or a CNN). 

Unsafe states in the Cartpole system

During the swing-up of this Cartpole system, a strong acceleration of the cart is required in both directions. To ensure the safety of both the hardware and the people standing next to it, it is important to test the safety of the system. The term “safety” assumes that the position of the cart does not exceed the physical limits of the rail at any time during the swing-up process. 

Due to the large delay caused by the image processing in controlling the cart to balance when using the video as input, a different model to the sensor-based balance model is used. This different behavior of the two controls and the resulting hard transition between angle-based and video-based balancing also requires TraceTube to analyze the safety of the system. The term “safety” in this case implies not only that the carriage does not exceed the physical limits of the rail, but also that the pendulum remains in the upright position during this transition phase.

Verification of the AI-controlled system

The Beckhoff system demonstrates TraceTube’s capabilities using an AI-controlled simulator for an inverted pendulum – the classic problem of balancing a pendulum on a moving carriage. The AI controller keeps the pendulum upright while TraceTube evaluates its robustness by generating limits that show the safe operating range of the system. This demo highlights TraceTube’s ability to verify AI models and ensure safety in dynamic real-time applications. 

The controller was trained using reinforcement learning methods on a simulated environment with physical equations describing the setup. The length of the rod, the mass of the rod, the acceleration of the carriage (the responsiveness of the carriage), the position of the carriage and the angle of the pendulum were used as parameters to model and control the system. The TraceTube tool was used separately to verify the upswing and balancing phases. 

The balancing process was verified when it was exposed to a switch from sensor data to camera data. This switching point can be seen in the graph with a higher variation in system behavior. This process demonstrates TraceTube’s ability to verify complex systems when conditions change and environmental attributes vary. This use case is a generic example of TraceTube’s application areas.