Autoware.Auto
time_utils.hpp
Go to the documentation of this file.
1 // Copyright 2019-2021 Apex.AI, Inc.
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 // Co-developed by Tier IV, Inc. and Apex.AI, Inc.
16 #ifndef TIME_UTILS__TIME_UTILS_HPP_
17 #define TIME_UTILS__TIME_UTILS_HPP_
18 
20 #include <builtin_interfaces/msg/duration.hpp>
21 #include <builtin_interfaces/msg/time.hpp>
22 
23 #include <chrono>
24 
25 namespace time_utils
26 {
28 TIME_UTILS_PUBLIC builtin_interfaces::msg::Time to_message(std::chrono::system_clock::time_point t);
30 TIME_UTILS_PUBLIC builtin_interfaces::msg::Duration to_message(std::chrono::nanoseconds dt);
32 TIME_UTILS_PUBLIC
33 std::chrono::system_clock::time_point from_message(builtin_interfaces::msg::Time t) noexcept;
35 TIME_UTILS_PUBLIC
36 std::chrono::nanoseconds from_message(builtin_interfaces::msg::Duration dt) noexcept;
38 TIME_UTILS_PUBLIC std::chrono::nanoseconds interpolate(
39  std::chrono::nanoseconds a,
40  std::chrono::nanoseconds b,
41  float t) noexcept;
42 
43 namespace details
44 {
45 template<typename TimeT>
46 TimeT duration_to_msg(std::chrono::nanoseconds dt);
47 } // namespace details
48 } // namespace time_utils
49 
50 #endif // TIME_UTILS__TIME_UTILS_HPP_
time_utils::to_message
TIME_UTILS_PUBLIC builtin_interfaces::msg::Time to_message(std::chrono::system_clock::time_point t)
Convert from std::chrono::time_point to time message.
Definition: time_utils.cpp:67
time_utils::details::duration_to_msg
TimeT duration_to_msg(std::chrono::nanoseconds dt)
Definition: time_utils.cpp:25
time_utils::interpolate
TIME_UTILS_PUBLIC std::chrono::nanoseconds interpolate(std::chrono::nanoseconds a, std::chrono::nanoseconds b, float t) noexcept
Standard interpolation.
Definition: time_utils.cpp:96
time_utils
Definition: time_utils.hpp:25
time_utils::from_message
TIME_UTILS_PUBLIC std::chrono::system_clock::time_point from_message(builtin_interfaces::msg::Time t) noexcept
Convert from std::chrono::time_point from time message.
Definition: time_utils.cpp:80
visibility_control.hpp