Introduction to Co-Simulation: A Step-by-Step Example
- clemenslinnhoff
- Apr 9
- 3 min read
Updated: May 2
Welcome to our introductory tutorial on Co-Simulation! In this post, we'll explore the basics of Co-Simulation, its importance, and how to set up a simple Co-Simulation using open-source and free tools. Whether you're new to the concept or looking to refine your skills, this guide will provide you with a solid foundation.
What is Co-Simulation?
Co-Simulation is a technique that allows the integration of simulation models from different sources into a single cohesive simulation environment. This approach is particularly useful when specialized models are required, such as vehicle dynamics or sensor models, which are best provided by experts in those fields.
Why Use Co-Simulation?
In traditional all-in-one simulation tools, you might have traffic, vehicle dynamics, and sensor simulations bundled together. However, for more accurate and specialized simulations, Co-Simulation enables the use of models developed by the most knowledgeable sources, such as the actual suppliers of the components.
Setting Up a Co-Simulation
Here's a step-by-step guide to setting up a basic Co-Simulation:
Choose Your Co-Simulation Master: This software orchestrates the simulation, handling the timing and interactions between different modules. Examples include Easy-SSP, OpenMCx, and AVL Scenario Simulator. For this tutorial, we'll use the AVL Scenario Simulator, which is free to download and use. You can find it on the AVL website and follow the instructions to install it on your system.
Prepare Your Models:
Scenario Player: We'll use esmini, an open-source tool that plays back predefined scenarios. It needs to be packaged as a Functional Mockup Unit (FMU) to be used in Co-Simulation. Download esmini from GitHub and follow the official documentation to build it. Package esmini as a Functional Mockup Unit (FMU) by following the instructions in the OSMP_FMU folder of the esmini repository. This ensures it can be used in Co-Simulation.
Sensor Model: We'll use a simple sensor model from the Open Source Model & Simulation Library. This also needs to be packaged as an FMU. Download the sensor model template repository from GitHub and follow the README to build the model. It will automatically be packaged as an FMU.
Build Your Simulation Architecture:
Open the AVL Scenario Simulator. You will start with a blank canvas.
Drag and drop the FMUs (ES Mini and the sensor model) onto the canvas. The simulator will recognize these FMUs as compliant with the FMI standard.
Connect the SensorView output of the scenario player to the input of the sensor model.
Add a scenario recorder to capture the outputs of the simulation. Drag and drop the recorder onto the canvas. Set a SensorView and SensorData input in the parameters panel and connect the recorder inputs to the outputs of both the scenario player and the sensor model.
Co-Simulation setup in AVL Scenario Simulator
Define the Scenario:
In the AVL Scenario Simulator, go to the parameters section under esmini and set the xosc_path to the location of the scenario file. You can use an example from the resources folder of esmini. It contains predefined scenarios, such as a vehicle cutting in front of another vehicle. Use for example the cut_in scenario.
Run the Simulation:
Set the parameters to visualize the simulation. In the parameters section, enable the viewer window for esmini to see the simulation in real-time.
Hit the run button in the AVL Scenario Simulator. The simulation will start, and you will see the scenario being played, such as a red car cutting in front of a white car (the ego vehicle).
Analyze the Results:
Use the scenario player to replay and inspect the simulation results.
The output will show the GroundTruth and SensorData, allowing you to evaluate the performance of your models.
Conclusion
Co-Simulation offers a flexible and powerful way to integrate specialized models into a unified simulation environment. By following this tutorial, you can set up a basic Co-Simulation and start exploring more complex scenarios and models. Stay tuned for our next video, where we'll delve deeper into standardized interfaces and advanced Co-Simulation techniques.
Happy Simulating!
コメント