ad_rss
VehicleStateValidInputRange.hpp
Go to the documentation of this file.
1 /*
2  * ----------------- BEGIN LICENSE BLOCK ---------------------------------
3  *
4  * Copyright (C) 2018-2020 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"
28 #include "spdlog/fmt/ostr.h"
29 #include "spdlog/spdlog.h"
30 
43 inline bool withinValidInputRange(::ad::rss::situation::VehicleState const &input, bool const logErrors = true)
44 {
45  // check for generic member input ranges
46  bool inValidInputRange = true;
47  inValidInputRange = withinValidInputRange(input.velocity, logErrors)
48  && withinValidInputRange(input.dynamics, logErrors)
51  && withinValidInputRange(input.objectType, logErrors) && withinValidInputRange(input.objectState, logErrors);
52  if (!inValidInputRange && logErrors)
53  {
54  spdlog::error("withinValidInputRange(::ad::rss::situation::VehicleState)>> {} has invalid member",
55  input); // LCOV_EXCL_BR_LINE
56  }
57 
58  // check for individual input ranges
59  if (inValidInputRange)
60  {
61  inValidInputRange = (::ad::physics::Distance(0.) <= input.distanceToEnterIntersection)
63  if (!inValidInputRange && logErrors)
64  {
65  spdlog::error(
66  "withinValidInputRange(::ad::rss::situation::VehicleState)>> {} element {} out of valid input range [{}, {}]",
67  input,
69  ::ad::physics::Distance(0.),
70  input.distanceToLeaveIntersection); // LCOV_EXCL_BR_LINE
71  }
72  }
73 
74  if (inValidInputRange)
75  {
76  inValidInputRange = (input.distanceToEnterIntersection <= input.distanceToLeaveIntersection)
77  && (input.distanceToLeaveIntersection <= ::ad::physics::Distance(1e4));
78  if (!inValidInputRange && logErrors)
79  {
80  spdlog::error(
81  "withinValidInputRange(::ad::rss::situation::VehicleState)>> {} element {} out of valid input range [{}, {}]",
82  input,
85  ::ad::physics::Distance(1e4)); // LCOV_EXCL_BR_LINE
86  }
87  }
88 
89  return inValidInputRange;
90 }
ad::rss::situation::VehicleState::distanceToEnterIntersection
::ad::physics::Distance distanceToEnterIntersection
Definition: VehicleState.hpp:153
VehicleState.hpp
ad::rss::situation::VehicleState::velocity
::ad::rss::situation::VelocityRange velocity
Definition: VehicleState.hpp:133
ad::rss::situation::VehicleState
DataType VehicleState.
Definition: VehicleState.hpp:51
RssDynamicsValidInputRange.hpp
withinValidInputRange
bool withinValidInputRange(::ad::rss::situation::VehicleState const &input, bool const logErrors=true)
check if the given VehicleState is within valid input range
Definition: VehicleStateValidInputRange.hpp:43
ad::rss::situation::VehicleState::dynamics
::ad::rss::world::RssDynamics dynamics
Definition: VehicleState.hpp:138
VelocityRangeValidInputRange.hpp
ad::rss::situation::VehicleState::distanceToLeaveIntersection
::ad::physics::Distance distanceToLeaveIntersection
Definition: VehicleState.hpp:158
ad::rss::situation::VehicleState::objectType
::ad::rss::world::ObjectType objectType
Definition: VehicleState.hpp:163
ObjectTypeValidInputRange.hpp
ObjectStateValidInputRange.hpp
ad::rss::situation::VehicleState::objectState
::ad::rss::world::ObjectState objectState
Definition: VehicleState.hpp:168