rclcpp  master
C++ ROS Client Library API
Public Member Functions | List of all members
rclcpp::Clock Class Reference

#include <clock.hpp>

Public Member Functions

 Clock (rcl_clock_type_t clock_type=RCL_SYSTEM_TIME)
 Default c'tor. More...
 
 ~Clock ()
 
Time now ()
 
bool ros_time_is_active ()
 
rcl_clock_tget_clock_handle () noexcept
 
rcl_clock_type_t get_clock_type () const noexcept
 
JumpHandler::SharedPtr create_jump_callback (JumpHandler::pre_callback_t pre_callback, JumpHandler::post_callback_t post_callback, const rcl_jump_threshold_t &threshold)
 

Constructor & Destructor Documentation

◆ Clock()

rclcpp::Clock::Clock ( rcl_clock_type_t  clock_type = RCL_SYSTEM_TIME)
explicit

Default c'tor.

Initializes the clock instance with the given clock_type.

Parameters
clock_typetype of the clock.
Exceptions
anythingrclcpp::exceptions::throw_from_rcl_error can throw.

◆ ~Clock()

rclcpp::Clock::~Clock ( )

Member Function Documentation

◆ now()

Time rclcpp::Clock::now ( )

Returns current time from the time source specified by clock_type.

Returns
current time.
Exceptions
anythingrclcpp::exceptions::throw_from_rcl_error can throw.

◆ ros_time_is_active()

bool rclcpp::Clock::ros_time_is_active ( )

Returns the clock of the type RCL_ROS_TIME is active.

Returns
true if the clock is active
Exceptions
anythingrclcpp::exceptions::throw_from_rcl_error can throw if the current clock does not have the clock_type RCL_ROS_TIME.

◆ get_clock_handle()

rcl_clock_t* rclcpp::Clock::get_clock_handle ( )
noexcept

◆ get_clock_type()

rcl_clock_type_t rclcpp::Clock::get_clock_type ( ) const
noexcept

◆ create_jump_callback()

JumpHandler::SharedPtr rclcpp::Clock::create_jump_callback ( JumpHandler::pre_callback_t  pre_callback,
JumpHandler::post_callback_t  post_callback,
const rcl_jump_threshold_t threshold 
)

These callback functions must remain valid as long as the returned shared pointer is valid.

Function will register callbacks to the callback queue. On time jump all callbacks will be executed whose threshold is greater then the time jump; The logic will first call selected pre_callbacks and then all selected post_callbacks.

Function is only applicable if the clock_type is RCL_ROS_TIME

Parameters
pre_callback.Must be non-throwing
post_callback.Must be non-throwing.
threshold.Callbacks will be triggered if the time jump is greater then the threshold.
Exceptions
anythingrclcpp::exceptions::throw_from_rcl_error can throw.
std::bad_allocif the allocation of the JumpHandler fails.
Warning
the instance of the clock must remain valid as long as any created JumpHandler.

The documentation for this class was generated from the following file: