ad_rss
LateralRssAccelerationValuesValidInputRange.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 
40  bool const logErrors = true)
41 {
42  // check for generic member input ranges
43  bool inValidInputRange = true;
44  inValidInputRange
45  = withinValidInputRange(input.accelMax, logErrors) && withinValidInputRange(input.brakeMin, logErrors);
46  if (!inValidInputRange && logErrors)
47  {
48  spdlog::error("withinValidInputRange(::ad::rss::world::LateralRssAccelerationValues)>> {} has invalid member",
49  input); // LCOV_EXCL_BR_LINE
50  }
51 
52  // check for individual input ranges
53  if (inValidInputRange)
54  {
55  inValidInputRange
56  = (::ad::physics::Acceleration(0.) <= input.accelMax) && (input.accelMax <= ::ad::physics::Acceleration(1e2));
57  if (!inValidInputRange && logErrors)
58  {
59  spdlog::error("withinValidInputRange(::ad::rss::world::LateralRssAccelerationValues)>> {} element {} out of "
60  "valid input range [{}, {}]",
61  input,
62  input.accelMax,
63  ::ad::physics::Acceleration(0.),
64  ::ad::physics::Acceleration(1e2)); // LCOV_EXCL_BR_LINE
65  }
66  }
67 
68  if (inValidInputRange)
69  {
70  inValidInputRange
71  = (::ad::physics::Acceleration(-1e2) <= input.brakeMin) && (input.brakeMin < ::ad::physics::Acceleration(0.));
72  if (!inValidInputRange && logErrors)
73  {
74  spdlog::error("withinValidInputRange(::ad::rss::world::LateralRssAccelerationValues)>> {} element {} out of "
75  "valid input range [{}, {}]",
76  input,
77  input.brakeMin,
78  ::ad::physics::Acceleration(-1e2),
79  ::ad::physics::Acceleration(0.)); // LCOV_EXCL_BR_LINE
80  }
81  }
82 
83  return inValidInputRange;
84 }
withinValidInputRange
bool withinValidInputRange(::ad::rss::world::LateralRssAccelerationValues const &input, bool const logErrors=true)
check if the given LateralRssAccelerationValues is within valid input range
Definition: LateralRssAccelerationValuesValidInputRange.hpp:39
ad::rss::world::LateralRssAccelerationValues::accelMax
::ad::physics::Acceleration accelMax
Definition: LateralRssAccelerationValues.hpp:120
ad::rss::world::LateralRssAccelerationValues
DataType LateralRssAccelerationValues.
Definition: LateralRssAccelerationValues.hpp:43
ad::rss::world::LateralRssAccelerationValues::brakeMin
::ad::physics::Acceleration brakeMin
Definition: LateralRssAccelerationValues.hpp:125
LateralRssAccelerationValues.hpp