Skip to main content

AVxcelerate Simulation Framework 2024 R1

Create customized KPIs and use it as evaluator activity

Last update: 16.07.2025

As extended ability of customized activity, you can also bring your own KPIs into simulation and calculate them as part of results.

Interfaces and topic definition

Before implementing a customized evaluator, you need to include kpi_evaluator.h where more interfaces are introduced for extending KPIs. Three main interface for customized KPIs you must have a look on:

  1. evaluator/kpi/definition/kpi_definition.h
  2. evaluator/kpi/i_kpi/i_kpi.h
  3. evaluator/kpi/kpi_message_converter/kpi_message_converter.h
  4. evaluator/base_evaluator/base_evaluator.h

In evaluator/kpi/definition/kpi_definition.h defines a native C++ data structure where one KPI value can be stored.

struct KpiContent
{
core::time::Timestamp timestamp;
std::string name;
Datatype data_type;
std::string value;
std::string unit;
Type type;
};
using KpiMessage = std::vector<KpiContent>;

where data_type , value and unit are all defined in string, so that different KPIs could be logged into different formats with more freedom.

KpiMessage is a vector of KpiContent . This is native C++ type and it can be converted into DDS message type rtidds:: KpiMessage using converter evaluator/kpi/kpi_message_converter/kpi_message_converter.h . Message published into KpiLoggerTopic will be captured by default KpiLoggerActivity and each extra KPI content will be logged into the output json as additional value of complete KPI results.

IKpi is responsible for representing one KPI core calculation logic (i.e. calculation of TTC, Max Acceleration etc.) and provide definition of calls to be used inside an evaluator

KpiMessageConverter is implementation to convert KpiMessage struct into DDS type kpi message so that the msg can be published through DDS network.

BaseEvaluator is the implementation of IEvaluator interface and provides users ability to evaluate KPIs that are added by themselves. This class controls all KPIs centrally and fill/reset the KpiMessage accordingly based on each KPI's calculation result.

Example customized KPI evaluator

There is an example implementation of customized evaluator activity provided by the Simulation Framework delivery, namely simulation_framework/example/my_kpi_evaluator_activity/my_kpi_evaluator_activity.h . Same as above example, this MyKpiEvaluatorActivity can be executed independently from simfwk_cli , and they will wait for simulation requests from simfwk_cli if they are selected in the simulation config.

After execute this example, you will get following KPI results in console:

Successfully ran MyKpiEvaluatorActivity in simulation using simfwk_cli
Output KPIs are available:
{
"kpi_1": {
"datatype": "double",
"unit": "ms",
"value": 12345.1
},
"kpi_2": {
"datatype": "double",
"unit": "ms",
"value": 54321.2
}
}

Following the code API documentation and instruction in the comments of this example implementation, you might understand how you can build your own KPI evaluation step by step and have the results after simulation is executed.

Connect with Ansys