    

 ## On this page

  

 

 # Create customized KPIs and use it as evaluator activity

 Last update: 16.07.2025 

<a class="anchor" id="autotoc_md24"></a> As extended ability of customized activity, you can also bring your own KPIs into simulation and calculate them as part of results.

### <a class="anchor" id="autotoc_md25"></a>Interfaces and topic definition

Three main interface for customized KPIs you must have a look on:

1. `<a class="el" href="kpi__definition_8h_source.xhtml">core/kpi/definition/kpi_definition.h</a>`
2. `<a class="el" href="i__kpi_8h_source.xhtml">core/kpi/i_kpi/i_kpi.h</a>`
3. `<a class="el" href="kpi__message__converter_8h_source.xhtml">core/kpi/kpi_message_converter/kpi_message_converter.h</a>`
4. `<a class="el" href="gt__base__evaluator_8h_source.xhtml">evaluator/gt_base_evaluator/gt_base_evaluator.h</a>`

In `<a class="el" href="kpi__definition_8h_source.xhtml">core/kpi/definition/kpi_definition.h</a>` 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&lt;KpiContent&gt;;



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 `<a class="el" href="kpi__message__converter_8h_source.xhtml">core/kpi/kpi_message_converter/kpi_message_converter.h</a>` . Message published into `KpiLoggerTopic` will be captured by default Default KPI Logger​ 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.

`GtBaseEvaluator` is the implementation of `GroundTruth` templated `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.

### <a class="anchor" id="autotoc_md26"></a>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.