rclcpp  master
C++ ROS Client Library API
time.hpp
Go to the documentation of this file.
1 // Copyright 2017 Open Source Robotics Foundation, 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 #ifndef RCLCPP__TIME_HPP_
16 #define RCLCPP__TIME_HPP_
17 
18 #include "builtin_interfaces/msg/time.hpp"
19 
21 
22 #include "rcl/time.h"
23 
24 #include "rclcpp/duration.hpp"
25 
26 namespace rclcpp
27 {
28 
29 class Clock;
30 
31 class Time
32 {
33 public:
35  Time(int32_t seconds, uint32_t nanoseconds, rcl_clock_type_t clock_type = RCL_SYSTEM_TIME);
36 
38  explicit Time(int64_t nanoseconds = 0, rcl_clock_type_t clock = RCL_SYSTEM_TIME);
39 
41  Time(const Time & rhs);
42 
44  Time(
45  const builtin_interfaces::msg::Time & time_msg,
46  rcl_clock_type_t ros_time = RCL_ROS_TIME);
47 
49  explicit Time(const rcl_time_point_t & time_point);
50 
52  virtual ~Time();
53 
55  operator builtin_interfaces::msg::Time() const;
56 
58  Time &
59  operator=(const Time & rhs);
60 
62  Time &
63  operator=(const builtin_interfaces::msg::Time & time_msg);
64 
66  bool
67  operator==(const rclcpp::Time & rhs) const;
68 
70  bool
71  operator!=(const rclcpp::Time & rhs) const;
72 
74  bool
75  operator<(const rclcpp::Time & rhs) const;
76 
78  bool
79  operator<=(const rclcpp::Time & rhs) const;
80 
82  bool
83  operator>=(const rclcpp::Time & rhs) const;
84 
86  bool
87  operator>(const rclcpp::Time & rhs) const;
88 
90  Time
91  operator+(const rclcpp::Duration & rhs) const;
92 
94  Duration
95  operator-(const rclcpp::Time & rhs) const;
96 
98  Time
99  operator-(const rclcpp::Duration & rhs) const;
100 
103  nanoseconds() const;
104 
106  static Time
107  max();
108 
113  double
114  seconds() const;
115 
118  get_clock_type() const;
119 
120 private:
121  rcl_time_point_t rcl_time_;
122  friend Clock; // Allow clock to manipulate internal data
123 };
124 
125 Time
126 operator+(const rclcpp::Duration & lhs, const rclcpp::Time & rhs);
127 
128 } // namespace rclcpp
129 
130 #endif // RCLCPP__TIME_HPP_
bool operator>=(const rclcpp::Time &rhs) const
rcl_clock_type_t get_clock_type() const
static Time max()
bool operator>(const rclcpp::Time &rhs) const
virtual ~Time()
rcl_clock_type_t
This header provides the get_node_topics_interface() template function.
Definition: allocator_common.hpp:24
bool operator!=(const rclcpp::Time &rhs) const
Time operator+(const rclcpp::Duration &rhs) const
bool operator<=(const rclcpp::Time &rhs) const
Definition: duration.hpp:26
Duration operator-(const rclcpp::Time &rhs) const
rcutils_time_point_value_t rcl_time_point_value_t
Time(int32_t seconds, uint32_t nanoseconds, rcl_clock_type_t clock_type=RCL_SYSTEM_TIME)
RCL_SYSTEM_TIME
bool operator==(const rclcpp::Time &rhs) const
rcl_time_point_value_t nanoseconds() const
RCL_ROS_TIME
bool operator<(const rclcpp::Time &rhs) const
Definition: clock.hpp:49
double seconds() const
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Definition: time.hpp:31
Time & operator=(const Time &rhs)