ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
node_clock.cpp
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 #include "rclcpp/node_interfaces/node_clock.hpp"
16 
17 #include <memory>
18 #include <string>
19 
21 
22 NodeClock::NodeClock(
23  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
24  rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr node_topics,
25  rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph,
26  rclcpp::node_interfaces::NodeServicesInterface::SharedPtr node_services,
27  rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging,
28  rcl_clock_type_t clock_type)
29 : node_base_(node_base),
30  node_topics_(node_topics),
31  node_graph_(node_graph),
32  node_services_(node_services),
33  node_logging_(node_logging),
34  clock_(std::make_shared<rclcpp::Clock>(clock_type))
35 {}
36 
37 NodeClock::~NodeClock()
38 {}
39 
40 rclcpp::Clock::SharedPtr
42 {
43  return clock_;
44 }
45 
46 rclcpp::Clock::ConstSharedPtr
48 {
49  return clock_;
50 }
Implementation of the NodeClock part of the Node API.
Definition: node_clock.hpp:36
RCLCPP_PUBLIC rclcpp::Clock::SharedPtr get_clock() override
Get a clock which will be kept up to date by the node.
Definition: node_clock.cpp:41
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
enum rcl_clock_type_e rcl_clock_type_t
Time source type, used to indicate the source of a time measurement.