    

 ## 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_2025_r2_2/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_2025_r2_2/classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator__coll__graph.png)

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

## <a id="pub-methods" 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#a7d9970bad7943a552c385b01785fb66f) (std::unique\_ptr&lt; [core::kpi::IKpi](classsimulation__framework_1_1core_1_1kpi_1_1IKpi.xhtml)&lt; 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#adc68080d44c2f5a294dbb511fe7d1c77) (const osi3::GroundTruth &amp;ground\_truth) ![-](/sites/default/files/migrate-content/avxcelerate_simulation_framework_2025_r2_2/closed.png) Public Member Functions inherited from [simulation\_framework::core::IEvaluator&lt; osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1IEvaluator.xhtml)[virtual](classsimulation__framework_1_1core_1_1Topic.xhtml) [void](classsimulation__framework_1_1core_1_1Topic.xhtml) **AddKpi** (std::unique\_ptr&lt; [kpi::IKpi](classsimulation__framework_1_1core_1_1kpi_1_1IKpi.xhtml)&lt; osi3::GroundTruth &gt; &gt; kpi)=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;osi3::GroundTruth&gt;&gt; kpi)](classsimulation__framework_1_1evaluator_1_1GtBaseEvaluator.xhtml#a7d9970bad7943a552c385b01785fb66f).

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](classsimulation__framework_1_1core_1_1kpi_1_1IKpi.xhtml)&lt;osi3::GroundTruth&gt;

{

 public:

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

 void Init() override {}

 void Reset() override {}

 kpi::KpiContent CalculateKpi(const 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;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::IEvaluator&lt;osi3::GroundTruth&gt;&gt; [evaluator](namespaceevaluator.xhtml))

 : BaseActivity(name, topics),

 kpi_message_converter_(std::move(kpi_message_converter)),

 evaluator_(std::move([evaluator](namespaceevaluator.xhtml)))

 {

 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::IEvaluator&lt;osi3::GroundTruth&gt;&gt;evaluator_;

 core::kpi::KpiMessage kpi_message_;

 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](namespaceevaluator.xhtml) = std::make_unique&lt;simulation_framework::evaluator::BaseEvaluator&gt;();

 [evaluator](namespaceevaluator.xhtml)-&gt;AddKpi(std::move(my_first_kpi));

 [evaluator](namespaceevaluator.xhtml)-&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](namespaceevaluator.xhtml)));

[simulation\_framework::core::kpi::IKpi](classsimulation__framework_1_1core_1_1kpi_1_1IKpi.xhtml)

Represents core KPI calculation logic.

**Definition** [i\_kpi.h:39](i__kpi_8h_source.xhtml#l00038)



[core](namespacecore.xhtml)

The namespace for all core functionalities under namespace simulation_framework.



[evaluator](namespaceevaluator.xhtml)

The namespace containing evaluator implementations.



[kpi](namespacekpi.xhtml)

The namespace for kpi definition and corresponding APIs under namespace simulation_framework::evaluat...





Definition at line [132](gt__base__evaluator_8h_source.xhtml#l00132) of file [gt\_base\_evaluator.h](gt__base__evaluator_8h_source.xhtml).



## Member Function Documentation

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

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

Add one KPI into this evaluator

Parameters kpiThe iKpi interface 



<a id="a09b8959aaaacce2b842abfd304b63674" name="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::IEvaluator&lt; osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1IEvaluator.xhtml#a251fb9feee11d29b6c4bd5161a7b7089).





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

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

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 Implements [simulation\_framework::core::IEvaluator&lt; osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1IEvaluator.xhtml#a81ab03795b81308e647d4f7022a64d4a).





<a id="a930cb234264aa995b30eab8c537a15ad" name="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::IEvaluator&lt; osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1IEvaluator.xhtml#ac62458dfff2bf4a0287bc48335bec4ff).





<a id="acacfb885fab2f83b114e870fa9433f3d" name="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::IEvaluator&lt; osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1IEvaluator.xhtml#a4f2140b6e5dc9289d084c601c1f28cf2).





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

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

Set GroundTruth message for KPI calculations

Parameters ground\_truthThe osi groundtruth type in protobuf Implements [simulation\_framework::core::IEvaluator&lt; osi3::GroundTruth &gt;](classsimulation__framework_1_1core_1_1IEvaluator.xhtml#a17db67a251425e3ecc47d45c03a1b056).





---

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