    

 ## On this page

  

 

 # simulation\_framework::evaluator::GtBaseEvaluator Class Reference

 Last update: 16.07.2025 

This 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. [More...](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#details)

`#include <<a class="el" href="gt__base__evaluator_8h_source.xhtml">gt_base_evaluator.h</a>>`

Inheritance diagram for simulation_framework::evaluator::GtBaseEvaluator:

![Inheritance graph](/sites/default/files/migrate-content/avxcelerate_simulation_framework_2024_r2_sp02_21/classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator__inherit__graph.png)

\[[legend](graph_legend.xhtml)\]

Collaboration diagram for simulation_framework::evaluator::GtBaseEvaluator:

![Collaboration graph](/sites/default/files/migrate-content/avxcelerate_simulation_framework_2024_r2_sp02_21/classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator__coll__graph.png)

\[[legend](graph_legend.xhtml)\]

## <a name="pub-methods"></a>Public Member Functions

void [Init](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#a930cb234264aa995b30eab8c537a15ad) () void [Reset](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#acacfb885fab2f83b114e870fa9433f3d) () void [Evaluate](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#a09b8959aaaacce2b842abfd304b63674) () void [AddKpi](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#aad43fb627edc44c2c903bf61feed81c8) (std::unique\_ptr&lt; [core::kpi::IKpi](classsimulation__framework_1_1core_1_1kpi_1_1IKpi.xhtml)&lt; avx\_osi3::GroundTruth &gt;&gt; kpi) override core::kpi::KpiMessage [GetKpiMessage](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#a2e37677f4b8884d78f028589c6adac48) () const void [SetInput](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#ae1381e0cf898286fd4738c4dcfe5577c) (const avx\_osi3::GroundTruth &amp;ground\_truth) ![-](/sites/default/files/migrate-content/avxcelerate_simulation_framework_2024_r2_sp02_21/closed.png) Public Member Functions inherited from [simulation\_framework::core::evaluator::IEvaluator&lt; avx\_osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1evaluator_1_1IEvaluator.xhtml)<a id="a49dd7b3abf92041c4b0efcd63890f30e"></a>virtual void **AddKpi** (std::unique\_ptr&lt; [kpi::IKpi](classsimulation__framework_1_1core_1_1kpi_1_1IKpi.xhtml)&lt; avx\_osi3::GroundTruth &gt;&gt; kpi)=0 virtual core::kpi::KpiMessage [GetKpiMessage](classsimulation__framework_1_1core_1_1evaluator_1_1IEvaluator.xhtml#a4ab336b9b848abd1324b4c779b8e4ed6) () const=0 <a id="details" name="details"></a>## Detailed Description

This 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.

To join the simulation, the evaluator must be injected into an Activity and required KPIs need to be added using [AddKpi(std::unique\_ptr&lt;core::kpi::IKpi&lt;avx\_osi3::GroundTruth&gt;&gt; kpi)](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#aad43fb627edc44c2c903bf61feed81c8).

Example of creating one customized KpiEvaluatorActivity containing 2 KPIs and publish the KpiMessage into KpiLoggerTopic to have the KPI results in output json

class MyFirstKpi : public core::kpi::IKpi&lt;avx_osi3::GroundTruth&gt;

{

 public:

 MyFirstKpi(const std::string&amp; kpi_name): kpi_name_(kpi_name) {}

 void [Init](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#a930cb234264aa995b30eab8c537a15ad)() override {}

 void [Reset](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#acacfb885fab2f83b114e870fa9433f3d)() override {}

 kpi::KpiContent CalculateKpi(const avx_osi3::GroundTruth&amp; ground_truth) override

 {

 kpi::KpiContent [kpi](namespacekpi.xhtml);

 return [kpi](namespacekpi.xhtml);

 }

 kpi::Type GetKpiType() const override { return kpi::Type::kScalar; }

};

class MySecondKpi : public [core](namespacecore.xhtml):kpi::IKpi&lt;avx_osi3::GroundTruth&gt; { 

 

class MyKpiEvaluatorActivity : public BaseActivity

{

 public:

 MyKpiEvaluatorActivity(const std::string&amp; name,

 const Topics&amp; topics,

 evaluator::std::unique_ptr&lt;kpi::IKpiMessageConverter&gt; kpi_message_converter,

 std::unique_ptr&lt;core::evaluator::IEvaluator&lt;avx_osi3::GroundTruth&gt;&gt; evaluator)

 : BaseActivity(name, topics),

 kpi_message_converter_(std::move(kpi_message_converter)),

 evaluator_(std::move(evaluator))

 {

 evaluator_-&gt;Init();

 }

 

 ~MyKpiEvaluatorActivity() = default;

 

 void AddPublisherAndSubscriber() override

 {

 AddSubscriber&lt;core::Topic&lt;rtidds::GenericBytesMessage&gt;&gt;(

 "SensorViewTopic", [&amp;](const rtidds::GenericBytesMessage&amp; sv_bytes_msg) {

 if (!osi_proto_sv_.ParseFromArray(sv_bytes_msg.bytes_array().data(), sv_bytes_msg.size()))

 {

 throw std::runtime_error(

 "\[MyKpiEvaluatorActivity\]: Error parsing "

 "osi proto msg from bytes array!");

 }

 });

 

 AddPublisher&lt;core::Topic&lt;rtidds::KpiMessage&gt;&gt;("KpiLoggerTopic", [&amp;]() {

 const auto dds_kpi_message = kpi_message_converter_-&gt;ConvertToDds(kpi_message_);

 return dds_kpi_message;

 });

 }

 

 void ExecuteStep() override

 {

 evaluator_-&gt;SetInput(osi_proto_sv_.global_ground_truth());

 evaluator_-&gt;Evaluate();

 kpi_message_ = evaluator_-&gt;GetKpiMessage();

 }

 

 private:

 evaluator::std::unique_ptr&lt;kpi::IKpiMessageConverter&gt; kpi_message_converter_;

 std::unique_ptr&lt;core::evaluator::IEvaluator&lt;avx_osi3::GroundTruth&gt;&gt;evaluator_;

 core::kpi::KpiMessage kpi_message_;

 avx_osi3::SensorView osi_proto_sv_{};

};

 

 

 auto my_first_kpi = std::make_unique&lt;MyFirstKpi&gt;("kpi\_1");

 auto my_second_kpi = std::make_unique&lt;MySecondKpi&gt;("kpi\_2");

 

 auto evaluator = std::make_unique&lt;simulation_framework::evaluator::BaseEvaluator&gt;();

 evaluator-&gt;AddKpi(std::move(my_first_kpi));

 evaluator-&gt;AddKpi(std::move(my_second_kpi));

 

 auto kpi_message_converter = std::make_unique&lt;core::kpi::KpiMessageConverter&gt;();

 

 auto my_kpi_evaluator_activity = std::make_unique&lt;MyKpiEvaluatorActivity&gt;(

 "MyKpiEvaluatorActivity",

 Topics{topic_registry::GetExistingTopicById("SensorViewTopic"),

 topic_registry::GetExistingTopicById("KpiLoggerTopic")},

 std::move(kpi_message_converter),

 std::move(evaluator));





## Member Function Documentation

<a id="aad43fb627edc44c2c903bf61feed81c8"></a>## [◆ ](#aad43fb627edc44c2c903bf61feed81c8)AddKpi()

 void simulation\_framework::evaluator::GtBaseEvaluator::AddKpi  ( std::unique\_ptr&lt; [core::kpi::IKpi](classsimulation__framework_1_1core_1_1kpi_1_1IKpi.xhtml)&lt; avx\_osi3::GroundTruth &gt;&gt;  *kpi*)   override 

Add one KPI into this evaluator

Parameters kpiThe iKpi interface 



<a id="a09b8959aaaacce2b842abfd304b63674"></a>## [◆ ](#a09b8959aaaacce2b842abfd304b63674)Evaluate()

 void simulation\_framework::evaluator::GtBaseEvaluator::Evaluate  ( )   virtual 

Calculate all KPIs (call all kpi-&gt;CalculateKpi(gt);) which are added in this evaluator and fill the KpiMessage

Implements [simulation\_framework::core::evaluator::IEvaluator&lt; avx\_osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1evaluator_1_1IEvaluator.xhtml#ab083ec7f04182794f04d9bb5a3c0b133).





<a id="a2e37677f4b8884d78f028589c6adac48"></a>## [◆ ](#a2e37677f4b8884d78f028589c6adac48)GetKpiMessage()

 core::kpi::KpiMessage simulation\_framework::evaluator::GtBaseEvaluator::GetKpiMessage  ( )  const

Get the filled KPI messages based on calculation of all KPIs

ReturnsA kpi::KpiMessage object, the vector of KpiContent represents of all added KPIs into this evaluator 



<a id="a930cb234264aa995b30eab8c537a15ad"></a>## [◆ ](#a930cb234264aa995b30eab8c537a15ad)Init()

 void simulation\_framework::evaluator::GtBaseEvaluator::Init  ( )   virtual 

Initial all KPIs (call all kpi-&gt;[Init()](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#a930cb234264aa995b30eab8c537a15ad);) which are added in this evaluator

Implements [simulation\_framework::core::evaluator::IEvaluator&lt; avx\_osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1evaluator_1_1IEvaluator.xhtml#aa81af246c9cf88d00c9b07453fee6ae2).





<a id="acacfb885fab2f83b114e870fa9433f3d"></a>## [◆ ](#acacfb885fab2f83b114e870fa9433f3d)Reset()

 void simulation\_framework::evaluator::GtBaseEvaluator::Reset  ( )   virtual 

Clear KpiMessage and reset all KPIs (call all kpi-&gt;[Reset()](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#acacfb885fab2f83b114e870fa9433f3d);) which are added in this evaluator

Implements [simulation\_framework::core::evaluator::IEvaluator&lt; avx\_osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1evaluator_1_1IEvaluator.xhtml#a072a25b43d319d2f7b9dc6c50076b432).





<a id="ae1381e0cf898286fd4738c4dcfe5577c"></a>## [◆ ](#ae1381e0cf898286fd4738c4dcfe5577c)SetInput()

 void simulation\_framework::evaluator::GtBaseEvaluator::SetInput  ( const avx\_osi3::GroundTruth &amp;  *ground\_truth*)   virtual 

Set GroundTruth message for KPI calculations

Parameters ground\_truthThe osi groundtruth type in protobuf Implements [simulation\_framework::core::evaluator::IEvaluator&lt; avx\_osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1evaluator_1_1IEvaluator.xhtml#aec46af76fd3c4388b18ef093baaebe28).





---

The documentation for this class was generated from the following file:- [gt\_base\_evaluator.h](gt__base__evaluator_8h_source.xhtml)