ad_rss
StructuredObjectStateValidInputRange.hpp
Go to the documentation of this file.
1 /*
2  * ----------------- BEGIN LICENSE BLOCK ---------------------------------
3  *
4  * Copyright (C) 2018-2022 Intel Corporation
5  *
6  * SPDX-License-Identifier: LGPL-2.1-only
7  *
8  * ----------------- END LICENSE BLOCK -----------------------------------
9  */
10 
18 #pragma once
19 
20 #include <cmath>
21 #include <limits>
22 #include "ad/physics/DistanceValidInputRange.hpp"
25 #include "spdlog/fmt/ostr.h"
26 #include "spdlog/spdlog.h"
27 
40 inline bool withinValidInputRange(::ad::rss::core::StructuredObjectState const &input, bool const logErrors = true)
41 {
42  // check for generic member input ranges
43  bool inValidInputRange = true;
44  inValidInputRange = withinValidInputRange(input.velocity, logErrors)
47  if (!inValidInputRange && logErrors)
48  {
49  spdlog::error("withinValidInputRange(::ad::rss::core::StructuredObjectState)>> {} has invalid member",
50  input); // LCOV_EXCL_BR_LINE
51  }
52 
53  // check for individual input ranges
54  if (inValidInputRange)
55  {
56  inValidInputRange = (::ad::physics::Distance(0.) <= input.distance_to_enter_intersection)
58  if (!inValidInputRange && logErrors)
59  {
60  spdlog::error("withinValidInputRange(::ad::rss::core::StructuredObjectState)>> {} element {} out of valid input "
61  "range [{}, {}]",
62  input,
64  ::ad::physics::Distance(0.),
65  input.distance_to_leave_intersection); // LCOV_EXCL_BR_LINE
66  }
67  }
68 
69  if (inValidInputRange)
70  {
71  inValidInputRange = (input.distance_to_enter_intersection <= input.distance_to_leave_intersection)
72  && (input.distance_to_leave_intersection <= ::ad::physics::Distance(1e4));
73  if (!inValidInputRange && logErrors)
74  {
75  spdlog::error("withinValidInputRange(::ad::rss::core::StructuredObjectState)>> {} element {} out of valid input "
76  "range [{}, {}]",
77  input,
80  ::ad::physics::Distance(1e4)); // LCOV_EXCL_BR_LINE
81  }
82  }
83 
84  return inValidInputRange;
85 }
bool withinValidInputRange(::ad::rss::core::StructuredObjectState const &input, bool const logErrors=true)
check if the given StructuredObjectState is within valid input range
Definition: StructuredObjectStateValidInputRange.hpp:40
DataType StructuredObjectState.
Definition: StructuredObjectState.hpp:49
::ad::physics::Distance distance_to_leave_intersection
Definition: StructuredObjectState.hpp:148
::ad::rss::world::Velocity velocity
Definition: StructuredObjectState.hpp:128
::ad::physics::Distance distance_to_enter_intersection
Definition: StructuredObjectState.hpp:143