ROS 2 rclcpp + rcl - humble  humble
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 : node_base_(node_base),
29  node_topics_(node_topics),
30  node_graph_(node_graph),
31  node_services_(node_services),
32  node_logging_(node_logging),
33  ros_clock_(std::make_shared<rclcpp::Clock>(RCL_ROS_TIME))
34 {}
35 
36 NodeClock::~NodeClock()
37 {}
38 
39 rclcpp::Clock::SharedPtr
41 {
42  return ros_clock_;
43 }
44 
45 rclcpp::Clock::ConstSharedPtr
47 {
48  return ros_clock_;
49 }
Implementation of the NodeClock part of the Node API.
Definition: node_clock.hpp:35
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:40
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
@ RCL_ROS_TIME
Use ROS time.
Definition: time.h:66