Interfaces and topic definition
Three main interface for customized KPIs you must have a look on:core/kpi/definition/kpi_definition.hcore/kpi/i_kpi/i_kpi.hcore/kpi/kpi_message_converter/kpi_message_converter.hevaluator/gt_base_evaluator/gt_base_evaluator.h
core/kpi/definition/kpi_definition.h defines a native C++ data structure where one KPI value can be stored.
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 core/kpi/kpi_message_converter/kpi_message_converter.h . 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.
Example customized KPI evaluator
There is an example implementation of customized evaluator activity provided by the Simulation Framework delivery, namelysimulation_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: