Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
units_extensions.hpp
Go to the documentation of this file.
1// Copyright 2023 Leidos
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef CARMA_COOPERATIVE_PERCEPTION__UNITS_EXTENSIONS_HPP_
16#define CARMA_COOPERATIVE_PERCEPTION__UNITS_EXTENSIONS_HPP_
17
18#include <units.h>
19
20#include <ratio>
21
23{
24template <typename T>
25constexpr auto remove_units(const T & value)
26{
27 return units::unit_cast<typename T::underlying_type>(value);
28}
29
30} // namespace carma_cooperative_perception
31
32/*
33 * The nholthaus/units library does not include an exhaustive list of units, so
34 * this is how we can add missing/new ones. See the following for more information:
35 * - https://github.com/nholthaus/units?tab=readme-ov-file#defining-new-units
36 * - https://github.com/nholthaus/units?tab=readme-ov-file#unit-definition-macros
37 */
38namespace units
39{
40
41// NOLINTBEGIN
43 acceleration, centi_meters_per_second_squared, centimeters_per_second_squared,
44 centi_mps_sq,
45 unit<std::centi, meters_per_second_squared>)
46
49 unit<std::ratio_multiply<std::ratio<2>, std::centi>, standard_gravity>)
50
52 angular_velocity, centi_degrees_per_second, centi_degrees_per_second, centi_deg_per_s,
53 unit<std::centi, degrees_per_second>)
54
57 unit<std::ratio_multiply<std::deci, std::micro>, degrees>)
58
60 length, deca_centimeters, deca_centimeters, deca_cm, unit<std::ratio<10>, centimeters>)
61
64 unit<std::ratio_multiply<std::ratio<1, 8>, std::deci>, degrees>)
65
67 velocity, two_milli_meters_per_second, two_milli_meters_per_second, two_milli_mps,
68 unit<std::ratio_multiply<std::ratio<2>, std::milli>, meters_per_second>)
69
72 unit<std::ratio_multiply<std::ratio<2>, std::centi>, meters_per_second>)
73// NOLINTEND
74
75} // namespace units
76
77#endif // CARMA_COOPERATIVE_PERCEPTION__UNITS_EXTENSIONS_HPP_
constexpr auto remove_units(const T &value)
unit< std::ratio_multiply< std::ratio< 2 >, std::centi >, standard_gravity > unit< std::ratio_multiply< std::deci, std::micro >, degrees > eighth_ddeg
unit< std::ratio_multiply< std::ratio< 2 >, std::centi >, standard_gravity > unit< std::ratio_multiply< std::deci, std::micro >, degrees > eighth_deci_degrees
unit< std::ratio_multiply< std::ratio< 2 >, std::centi >, standard_gravity > unit< std::ratio_multiply< std::deci, std::micro >, degrees > unit< std::ratio_multiply< std::ratio< 1, 8 >, std::deci >, degrees > two_centi_meters_per_second
unit< std::ratio_multiply< std::ratio< 2 >, std::centi >, standard_gravity > unit< std::ratio_multiply< std::deci, std::micro >, degrees > unit< std::ratio_multiply< std::ratio< 1, 8 >, std::deci >, degrees > two_centi_mps
two_centi_standard_gravities
unit< std::ratio_multiply< std::ratio< 2 >, std::centi >, standard_gravity > deci_udeg
unit< std::ratio_multiply< std::ratio< 2 >, std::centi >, standard_gravity > deci_micro_degrees
UNIT_ADD(acceleration, centi_meters_per_second_squared, centimeters_per_second_squared, centi_mps_sq, unit< std::centi, meters_per_second_squared >) UNIT_ADD(acceleration