Autoware.Auto
time_utils.hpp
Go to the documentation of this file.
1 // Copyright 2019 Christopher Ho
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 #ifndef TIME_UTILS__TIME_UTILS_HPP_
15 #define TIME_UTILS__TIME_UTILS_HPP_
16 
18 #include <builtin_interfaces/msg/duration.hpp>
19 #include <builtin_interfaces/msg/time.hpp>
20 
21 #include <chrono>
22 
23 namespace time_utils
24 {
26 TIME_UTILS_PUBLIC builtin_interfaces::msg::Time to_message(std::chrono::system_clock::time_point t);
28 TIME_UTILS_PUBLIC builtin_interfaces::msg::Duration to_message(std::chrono::nanoseconds dt);
30 TIME_UTILS_PUBLIC
31 std::chrono::system_clock::time_point from_message(builtin_interfaces::msg::Time t) noexcept;
33 TIME_UTILS_PUBLIC
34 std::chrono::microseconds from_message(builtin_interfaces::msg::Duration dt) noexcept;
36 TIME_UTILS_PUBLIC std::chrono::nanoseconds interpolate(
37  std::chrono::nanoseconds a,
38  std::chrono::nanoseconds b,
39  float t) noexcept;
40 
41 namespace details
42 {
43 template<typename TimeT>
44 TimeT duration_to_msg(std::chrono::nanoseconds dt);
45 } // namespace details
46 } // namespace time_utils
47 
48 #endif // TIME_UTILS__TIME_UTILS_HPP_
TimeT duration_to_msg(std::chrono::nanoseconds dt)
Definition: time_utils.cpp:25
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_PUBLIC std::chrono::nanoseconds interpolate(std::chrono::nanoseconds a, std::chrono::nanoseconds b, float t) noexcept
Standard interpolation.
Definition: time_utils.cpp:97
t
Definition: catr_diff.py:22
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
a
Definition: catr_diff.py:22
Definition: time_utils.hpp:23