ad_rss
RssDynamicsValidInputRange.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"
23 #include "ad/physics/DurationValidInputRange.hpp"
24 #include "ad/physics/SpeedValidInputRange.hpp"
29 #include "spdlog/fmt/ostr.h"
30 #include "spdlog/spdlog.h"
31 
44 inline bool withinValidInputRange(::ad::rss::world::RssDynamics const &input, bool const logErrors = true)
45 {
46  // check for generic member input ranges
47  bool inValidInputRange = true;
48  inValidInputRange = withinValidInputRange(input.alphaLon, logErrors)
49  && withinValidInputRange(input.alphaLat, logErrors)
51  && withinValidInputRange(input.responseTime, logErrors)
53  && withinValidInputRange(input.unstructuredSettings, logErrors);
54  if (!inValidInputRange && logErrors)
55  {
56  spdlog::error("withinValidInputRange(::ad::rss::world::RssDynamics)>> {} has invalid member",
57  input); // LCOV_EXCL_BR_LINE
58  }
59 
60  // check for individual input ranges
61  if (inValidInputRange)
62  {
63  inValidInputRange = (::ad::physics::Distance(0.) <= input.lateralFluctuationMargin)
64  && (input.lateralFluctuationMargin <= ::ad::physics::Distance(1.));
65  if (!inValidInputRange && logErrors)
66  {
67  spdlog::error(
68  "withinValidInputRange(::ad::rss::world::RssDynamics)>> {} element {} out of valid input range [{}, {}]",
69  input,
71  ::ad::physics::Distance(0.),
72  ::ad::physics::Distance(1.)); // LCOV_EXCL_BR_LINE
73  }
74  }
75 
76  if (inValidInputRange)
77  {
78  inValidInputRange
79  = (::ad::physics::Duration(0.) < input.responseTime) && (input.responseTime <= ::ad::physics::Duration(10.));
80  if (!inValidInputRange && logErrors)
81  {
82  spdlog::error(
83  "withinValidInputRange(::ad::rss::world::RssDynamics)>> {} element {} out of valid input range [{}, {}]",
84  input,
85  input.responseTime,
86  ::ad::physics::Duration(0.),
87  ::ad::physics::Duration(10.)); // LCOV_EXCL_BR_LINE
88  }
89  }
90 
91  return inValidInputRange;
92 }
ad::rss::world::RssDynamics::maxSpeedOnAcceleration
::ad::physics::Speed maxSpeedOnAcceleration
Definition: RssDynamics.hpp:154
LateralRssAccelerationValuesValidInputRange.hpp
ad::rss::world::RssDynamics
DataType RssDynamics.
Definition: RssDynamics.hpp:50
ad::rss::world::RssDynamics::unstructuredSettings
::ad::rss::world::UnstructuredSettings unstructuredSettings
Definition: RssDynamics.hpp:159
ad::rss::world::RssDynamics::lateralFluctuationMargin
::ad::physics::Distance lateralFluctuationMargin
Definition: RssDynamics.hpp:140
ad::rss::world::RssDynamics::alphaLon
::ad::rss::world::LongitudinalRssAccelerationValues alphaLon
Definition: RssDynamics.hpp:130
ad::rss::world::RssDynamics::responseTime
::ad::physics::Duration responseTime
Definition: RssDynamics.hpp:145
ad::rss::world::RssDynamics::alphaLat
::ad::rss::world::LateralRssAccelerationValues alphaLat
Definition: RssDynamics.hpp:135
LongitudinalRssAccelerationValuesValidInputRange.hpp
UnstructuredSettingsValidInputRange.hpp
RssDynamics.hpp
withinValidInputRange
bool withinValidInputRange(::ad::rss::world::RssDynamics const &input, bool const logErrors=true)
check if the given RssDynamics is within valid input range
Definition: RssDynamicsValidInputRange.hpp:44