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 470 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 495 of file multiple_object_tracker_component.cpp.

498 {
499 return std::visit(
500 [this](const auto & t, const auto & d) { return (*this)(t, d); }, track, detection);
501 }

◆ 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 473 of file multiple_object_tracker_component.cpp.

474 {
475 if constexpr (std::is_same_v<decltype(track.state), decltype(detection.state)>) {
476 const auto dist{two_dimensional_distance(track.state, detection.state)};
477
478 // Fall back to 2D Euclidean distance if either semantic class if unknown. The unknown
479 // track/detection may actually be the same other track/detection we are scoring against.
480 if (
481 track.semantic_class == mot::SemanticClass::kUnknown ||
482 detection.semantic_class == mot::SemanticClass::kUnknown) {
483 return dist;
484 }
485
486 if (track.semantic_class == detection.semantic_class) {
487 return dist;
488 }
489 }
490
491 return std::nullopt;
492 }
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 515 of file multiple_object_tracker_component.cpp.

517 {
518 const auto x_diff_sq{
519 std::pow(mot::remove_units(lhs.position_x) - mot::remove_units(rhs.position_x), 2)};
520 const auto y_diff_sq{
521 std::pow(mot::remove_units(lhs.position_y) - mot::remove_units(rhs.position_y), 2)};
522
523 return std::sqrt(x_diff_sq + y_diff_sq);
524 }
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 504 of file multiple_object_tracker_component.cpp.

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

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: