6 #include <boost/math/special_functions/round.hpp>
7 #include <rclcpp/create_timer.hpp>
8 #include "rclcpp/rclcpp.hpp"
16 using Timer = ::rclcpp::TimerBase::SharedPtr;
20 return ::rclcpp::Duration(::std::chrono::duration<double>(d));
25 return nh->node()->get_clock()->
now();
28 inline void sleep(
double t)
37 int64_t sec64 =
static_cast<int64_t
>(floor(t));
38 if (sec64 < 0 || sec64 > ::std::numeric_limits<uint32_t>::max())
39 throw ::std::runtime_error(
"Time is out of dual 32-bit range");
40 uint32_t sec =
static_cast<uint32_t
>(sec64);
41 uint32_t nsec =
static_cast<uint32_t
>(boost::math::round((t - sec) * 1e9));
43 sec += (nsec / 1000000000ul);
50 #define TIMER_CALLBACK_DECLARATION_ARGS
52 #define TIMER_CALLBACK_DEFINITION_ARGS
54 #define CREATE_TIMER(nh, duration_in_seconds, callback_ref, object_ptr) \
55 ::rclcpp::create_timer(nh->get_base_interface(), nh->get_timers_interface(), nh->get_clock_interface()->get_clock(), \
56 ensenso::ros::durationFromSeconds(duration_in_seconds), \
57 ensenso::std::bind(callback_ref, object_ptr));
73 return ::ros::Duration(
d);
94 #define TIMER_CALLBACK_DECLARATION_ARGS ensenso::ros::TimerEvent const& timerEvent = ensenso::ros::TimerEvent()
96 #define TIMER_CALLBACK_DEFINITION_ARGS ensenso::ros::TimerEvent const& timerEvent
98 #define CREATE_TIMER(nh, duration_in_seconds, callback_ref, object_ptr) \
99 nh.createTimer(ensenso::ros::durationFromSeconds(duration_in_seconds), callback_ref, object_ptr)