Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
carma_cooperative_perception::SemanticDistance2dScore Struct Reference

Calculate 2D Euclidean distance between track and detection. More...

Collaboration diagram for carma_cooperative_perception::SemanticDistance2dScore:
Collaboration graph

Public Member Functions

template<typename Track , typename Detection >
auto operator() (const Track &track, const Detection &detection) const -> std::optional< float >
 
template<typename... TrackAlternatives, typename... DetectionAlternatives>
auto operator() (const std::variant< TrackAlternatives... > &track, const std::variant< DetectionAlternatives... > &detection) const -> std::optional< float >
 

Static Private Member Functions

static auto two_dimensional_distance (const mot::CtrvState &lhs, const mot::CtrvState &rhs) -> float
 
static auto two_dimensional_distance (const mot::CtraState &lhs, const mot::CtraState &rhs) -> float
 

Detailed Description

Calculate 2D Euclidean distance between track and detection.

If both the track and detection semantic classes are known, this function object returns the 2D Euclidean distance between their states. Otherwise, it returns std::nullopt.

Definition at line 467 of file multiple_object_tracker_component.cpp.

Member Function Documentation

◆ operator()() [1/2]

template<typename... TrackAlternatives, typename... DetectionAlternatives>
auto carma_cooperative_perception::SemanticDistance2dScore::operator() ( const std::variant< TrackAlternatives... > &  track,
const std::variant< DetectionAlternatives... > &  detection 
) const -> std::optional<float>
inline

Definition at line 492 of file multiple_object_tracker_component.cpp.

495 {
496 return std::visit(
497 [this](const auto & t, const auto & d) { return (*this)(t, d); }, track, detection);
498 }

◆ operator()() [2/2]

template<typename Track , typename Detection >
auto carma_cooperative_perception::SemanticDistance2dScore::operator() ( const Track track,
const Detection detection 
) const -> std::optional<float>
inline

Definition at line 470 of file multiple_object_tracker_component.cpp.

471 {
472 if constexpr (std::is_same_v<decltype(track.state), decltype(detection.state)>) {
473 const auto dist{two_dimensional_distance(track.state, detection.state)};
474
475 // Fall back to 2D Euclidean distance if either semantic class if unknown. The unknown
476 // track/detection may actually be the same other track/detection we are scoring against.
477 if (
478 track.semantic_class == mot::SemanticClass::kUnknown ||
479 detection.semantic_class == mot::SemanticClass::kUnknown) {
480 return dist;
481 }
482
483 if (track.semantic_class == detection.semantic_class) {
484 return dist;
485 }
486 }
487
488 return std::nullopt;
489 }
static auto two_dimensional_distance(const mot::CtrvState &lhs, const mot::CtrvState &rhs) -> float

◆ two_dimensional_distance() [1/2]

static auto carma_cooperative_perception::SemanticDistance2dScore::two_dimensional_distance ( const mot::CtraState &  lhs,
const mot::CtraState &  rhs 
) -> float
inlinestaticprivate

Definition at line 512 of file multiple_object_tracker_component.cpp.

514 {
515 const auto x_diff_sq{
516 std::pow(mot::remove_units(lhs.position_x) - mot::remove_units(rhs.position_x), 2)};
517 const auto y_diff_sq{
518 std::pow(mot::remove_units(lhs.position_y) - mot::remove_units(rhs.position_y), 2)};
519
520 return std::sqrt(x_diff_sq + y_diff_sq);
521 }
constexpr auto remove_units(const T &value)

References carma_cooperative_perception::remove_units().

Here is the call graph for this function:

◆ two_dimensional_distance() [2/2]

static auto carma_cooperative_perception::SemanticDistance2dScore::two_dimensional_distance ( const mot::CtrvState &  lhs,
const mot::CtrvState &  rhs 
) -> float
inlinestaticprivate

Definition at line 501 of file multiple_object_tracker_component.cpp.

503 {
504 const auto x_diff_sq{
505 std::pow(mot::remove_units(lhs.position_x) - mot::remove_units(rhs.position_x), 2)};
506 const auto y_diff_sq{
507 std::pow(mot::remove_units(lhs.position_y) - mot::remove_units(rhs.position_y), 2)};
508
509 return std::sqrt(x_diff_sq + y_diff_sq);
510 }

References carma_cooperative_perception::remove_units().

Here is the call graph for this function:

The documentation for this struct was generated from the following file: