    

 ## On this page

  

 

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

 Last update: 16.07.2025 

class [PredictiveTimeToCollisionCalculator](classsimulation__framework_1_1evaluator_1_1PredictiveTimeToCollisionCalculator.xhtml "class PredictiveTimeToCollisionCalculator") [More...](classsimulation__framework_1_1evaluator_1_1PredictiveTimeToCollisionCalculator.xhtml#details)

`#include <<a class="el" href="predictive__ttc__calculator_8h_source.xhtml">predictive_ttc_calculator.h</a>>`

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

std::chrono::milliseconds [Calculate](classsimulation__framework_1_1evaluator_1_1PredictiveTimeToCollisionCalculator.xhtml#aeb6dab536ddc23eafec60a4dca7b066e) (const osi3::GroundTruth &amp;ground\_truth) const <a id="details" name="details"></a>## Detailed Description

class [PredictiveTimeToCollisionCalculator](classsimulation__framework_1_1evaluator_1_1PredictiveTimeToCollisionCalculator.xhtml "class PredictiveTimeToCollisionCalculator")

[PredictiveTimeToCollisionCalculator](classsimulation__framework_1_1evaluator_1_1PredictiveTimeToCollisionCalculator.xhtml "class PredictiveTimeToCollisionCalculator") class to calculate the time of Ego to collision with other traffic car based on osi GroundTruth Internal Variables: uint64\_t predictive\_ttc\_precision\_{100} : step in time space to estimate the collision between 2 objects uint64\_t predictive\_ttc\_max\_{20000}: maximum time span from current timestamp for collision evaluation. If the predictive\_min\_ttc value calculated is very large. We assume that the vehicle will never collide. In such cases, we have decided to use a considerably large value of time to collision as predictive\_ttc\_max\_{20000} and mark it as a max value of predictive\_min\_ttc.

Algorithm explaination:

1. read Ego vehicle position and speed vectors, as well as its bounding box size from GroundTruth and compute the BoundingBox
2. loop through all existing objects within MovingObject list from GroundTruth and compute the BoundingBox.
3. check if there is any collision between ego vehicle and traffic objects 3.1 if so return 0 indicating that there is collision 3.2 if there is no collision in current frame, estimate if there will be a collision in near future (dt) under condition that 2 vehicles keeping their current speed vector. If so, return this std::chrono::milliseconds(dt) as predictive time to collision.

Definition at line [44](predictive__ttc__calculator_8h_source.xhtml#l00044) of file [predictive\_ttc\_calculator.h](predictive__ttc__calculator_8h_source.xhtml).



## Member Function Documentation

<a id="aeb6dab536ddc23eafec60a4dca7b066e" name="aeb6dab536ddc23eafec60a4dca7b066e"></a>## [◆ ](#aeb6dab536ddc23eafec60a4dca7b066e)Calculate()

 std::chrono::milliseconds simulation\_framework::evaluator::PredictiveTimeToCollisionCalculator::Calculate  ( const osi3::GroundTruth &amp;  *ground\_truth*)  const

Definition at line [14](predictive__ttc__calculator_8cpp_source.xhtml#l00014) of file [predictive\_ttc\_calculator.cpp](predictive__ttc__calculator_8cpp_source.xhtml).

 15{

 16 auto host_vehicle_validation = std::make_optional&lt;int&gt;();

 17 

 18 const auto&amp; host_vehicle_id = ground_truth.host_vehicle_id();

 19 BoundingBox bounding_box_ego;

 20 const auto&amp; gt_moving_objects = ground_truth.moving_object();

 21 for (auto object : gt_moving_objects)

 22 {

 23 if (host_vehicle_id.value() == object.id().value())

 24 {

 25 host_vehicle_validation = object.id().value();

 26 bounding_box_ego.x = object.base().position().x();

 27 bounding_box_ego.y = object.base().position().y();

 28 bounding_box_ego.width = object.base().dimension().width();

 29 bounding_box_ego.length = object.base().dimension().length();

 30 bounding_box_ego.yaw = object.base().orientation().yaw();

 31 bounding_box_ego.velocity_x = object.base().velocity().x();

 32 bounding_box_ego.velocity_y = object.base().velocity().y();

 33 break;

 34 }

 35 }

 36 

 37 if (!host_vehicle_validation.has_value())

 38 {

 39 return std::chrono::milliseconds::max();

 40 }

 41 

 42 auto predictive_minimum_ttc{std::chrono::milliseconds::max()};

 43 

 44 for (auto object : gt_moving_objects)

 45 {

 46 if (host_vehicle_id.value() == object.id().value())

 47 {

 48 continue;

 49 }

 50 

 51 const auto&amp; vehicle_base = object.base();

 52 BoundingBox bounding_box_vehicle{vehicle_base.position().x(),

 53 vehicle_base.position().y(),

 54 vehicle_base.dimension().width(),

 55 vehicle_base.dimension().length(),

 56 vehicle_base.orientation().yaw(),

 57 vehicle_base.velocity().x(),

 58 vehicle_base.velocity().y()};

 59 

 60 if (AreBoundingBoxesOverlapped(bounding_box_vehicle, bounding_box_ego))

 61 {

 62 return std::chrono::milliseconds(0);

 63 }

 64 predictive_minimum_ttc =

 65 std::min(PredictTimeToCollision(

 66 bounding_box_vehicle, bounding_box_ego, predictive_ttc_precision_, predictive_ttc_max_),

 67 predictive_minimum_ttc);

 68 }

 69 

 70 return predictive_minimum_ttc;

 71};







---

The documentation for this class was generated from the following files:- [predictive\_ttc\_calculator.h](predictive__ttc__calculator_8h_source.xhtml)
- [predictive\_ttc\_calculator.cpp](predictive__ttc__calculator_8cpp_source.xhtml)