ad_rss
LongitudinalRssAccelerationValuesValidInputRange.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/AccelerationValidInputRange.hpp"
24 #include "spdlog/fmt/ostr.h"
25 #include "spdlog/spdlog.h"
26 
42  bool const logErrors = true)
43 {
44  // check for generic member input ranges
45  bool inValidInputRange = true;
46  inValidInputRange = withinValidInputRange(input.accelMax, logErrors)
47  && withinValidInputRange(input.brakeMax, logErrors) && withinValidInputRange(input.brakeMin, logErrors)
48  && withinValidInputRange(input.brakeMinCorrect, logErrors);
49  if (!inValidInputRange && logErrors)
50  {
51  spdlog::error("withinValidInputRange(::ad::rss::world::LongitudinalRssAccelerationValues)>> {} has invalid member",
52  input); // LCOV_EXCL_BR_LINE
53  }
54 
55  // check for individual input ranges
56  if (inValidInputRange)
57  {
58  inValidInputRange
59  = (::ad::physics::Acceleration(0.) <= input.accelMax) && (input.accelMax <= ::ad::physics::Acceleration(1e2));
60  if (!inValidInputRange && logErrors)
61  {
62  spdlog::error("withinValidInputRange(::ad::rss::world::LongitudinalRssAccelerationValues)>> {} element {} out of "
63  "valid input range [{}, {}]",
64  input,
65  input.accelMax,
66  ::ad::physics::Acceleration(0.),
67  ::ad::physics::Acceleration(1e2)); // LCOV_EXCL_BR_LINE
68  }
69  }
70 
71  if (inValidInputRange)
72  {
73  inValidInputRange = (::ad::physics::Acceleration(-1e2) <= input.brakeMax) && (input.brakeMax <= input.brakeMin);
74  if (!inValidInputRange && logErrors)
75  {
76  spdlog::error("withinValidInputRange(::ad::rss::world::LongitudinalRssAccelerationValues)>> {} element {} out of "
77  "valid input range [{}, {}]",
78  input,
79  input.brakeMax,
80  ::ad::physics::Acceleration(-1e2),
81  input.brakeMin); // LCOV_EXCL_BR_LINE
82  }
83  }
84 
85  if (inValidInputRange)
86  {
87  inValidInputRange = (input.brakeMax <= input.brakeMin) && (input.brakeMin <= input.brakeMinCorrect);
88  if (!inValidInputRange && logErrors)
89  {
90  spdlog::error("withinValidInputRange(::ad::rss::world::LongitudinalRssAccelerationValues)>> {} element {} out of "
91  "valid input range [{}, {}]",
92  input,
93  input.brakeMin,
94  input.brakeMax,
95  input.brakeMinCorrect); // LCOV_EXCL_BR_LINE
96  }
97  }
98 
99  if (inValidInputRange)
100  {
101  inValidInputRange
102  = (input.brakeMin <= input.brakeMinCorrect) && (input.brakeMinCorrect < ::ad::physics::Acceleration(0.));
103  if (!inValidInputRange && logErrors)
104  {
105  spdlog::error("withinValidInputRange(::ad::rss::world::LongitudinalRssAccelerationValues)>> {} element {} out of "
106  "valid input range [{}, {}]",
107  input,
108  input.brakeMinCorrect,
109  input.brakeMin,
110  ::ad::physics::Acceleration(0.)); // LCOV_EXCL_BR_LINE
111  }
112  }
113 
114  return inValidInputRange;
115 }
ad::rss::world::LongitudinalRssAccelerationValues::brakeMin
::ad::physics::Acceleration brakeMin
Definition: LongitudinalRssAccelerationValues.hpp:133
ad::rss::world::LongitudinalRssAccelerationValues::brakeMinCorrect
::ad::physics::Acceleration brakeMinCorrect
Definition: LongitudinalRssAccelerationValues.hpp:139
ad::rss::world::LongitudinalRssAccelerationValues::accelMax
::ad::physics::Acceleration accelMax
Definition: LongitudinalRssAccelerationValues.hpp:121
ad::rss::world::LongitudinalRssAccelerationValues::brakeMax
::ad::physics::Acceleration brakeMax
Definition: LongitudinalRssAccelerationValues.hpp:127
LongitudinalRssAccelerationValues.hpp
withinValidInputRange
bool withinValidInputRange(::ad::rss::world::LongitudinalRssAccelerationValues const &input, bool const logErrors=true)
check if the given LongitudinalRssAccelerationValues is within valid input range
Definition: LongitudinalRssAccelerationValuesValidInputRange.hpp:41
ad::rss::world::LongitudinalRssAccelerationValues
DataType LongitudinalRssAccelerationValues.
Definition: LongitudinalRssAccelerationValues.hpp:43