60 #if defined __ROS_VERSION && __ROS_VERSION == 2 61 static rclcpp::Clock s_wrapper_clock;
68 #if defined __ROS_VERSION && __ROS_VERSION == 1 70 #elif defined __ROS_VERSION && __ROS_VERSION == 2 71 rclcpp::NodeOptions node_options;
72 node_options.allow_undeclared_parameters(
true);
73 nh = rclcpp::Node::make_shared(node_name,
"", node_options);
77 ROS_WARN_STREAM(
"## ERROR ROS::createNode(): time confusion, ROS::secondsSinceStart(ROS::now()) returned negative seconds " << timestamp_sec);
81 #if defined __ROS_VERSION && __ROS_VERSION == 2 83 void ROS::init(
int argc,
char** argv,
const std::string nodename)
85 rclcpp::init(argc, argv);
90 #if defined __ROS_VERSION && __ROS_VERSION == 1 91 void ROS::spin(ROS::NodePtr nh)
100 #if defined __ROS_VERSION && __ROS_VERSION == 1 112 std::this_thread::sleep_for(std::chrono::microseconds((int64_t)(1.0e6*seconds)));
118 #if defined __ROS_VERSION && __ROS_VERSION == 1 120 #elif defined __ROS_VERSION && __ROS_VERSION == 2 121 return s_wrapper_clock.now();
130 #if defined __ROS_VERSION && __ROS_VERSION == 1 132 nanoseconds = time.nsec;
133 #elif defined __ROS_VERSION && __ROS_VERSION == 2 134 seconds = (uint32_t)(time.nanoseconds() / 1000000000);
135 nanoseconds = (uint32_t)(time.nanoseconds() - 1000000000 *
seconds);
142 #if defined __ROS_VERSION && __ROS_VERSION == 1 144 nanoseconds = time.nsec;
145 #elif defined __ROS_VERSION && __ROS_VERSION == 2 146 seconds = (uint32_t)(time.nanoseconds() / 1000000000);
147 nanoseconds = (uint32_t)(time.nanoseconds() - 1000000000 *
seconds);
154 return ROS::Time(std::max(0,(int32_t)msg_header->stamp.sec), msg_header->stamp.NSEC);
163 int32_t i32seconds = (int32_t)(seconds);
164 int32_t i32nanoseconds = (int32_t)(1000000000 * (seconds - i32seconds));
165 return ROS::Time(std::max(0,i32seconds), std::max(0,i32nanoseconds));
174 int32_t i32seconds = (int32_t)(seconds);
175 int32_t i32nanoseconds = (int32_t)(1000000000 * (seconds - i32seconds));
176 return ROS::Duration(i32seconds, i32nanoseconds);
182 #if defined __ROS_VERSION && __ROS_VERSION == 1 183 return duration.toSec();
184 #elif defined __ROS_VERSION && __ROS_VERSION == 2 185 return duration.seconds();
194 static ROS::Time s_wrapper_start_time =
ROS::now();
201 #if defined __ROS_VERSION && __ROS_VERSION == 1 202 return (uint64_t)(time.sec * 1000) + (uint64_t)(time.nsec / 1000000);
203 #elif defined __ROS_VERSION && __ROS_VERSION == 2 204 return (uint64_t)(time.nanoseconds() / 1000000);
double secondsSinceStart(const ROS::Time &time)
void deleteNode(ROS::NodePtr &node)
void splitTime(ROS::Duration time, uint32_t &seconds, uint32_t &nanoseconds)
ROS::Duration durationFromSec(double seconds)
#define ROS_WARN_STREAM(args)
ROS::Time timeFromHeader(const std_msgs::Header *msg_header)
uint64_t timestampMilliseconds(const ROS::Time &time)
ROS::NodePtr createNode(const std::string &node_name="sick_scan")
ROS::Time timeFromSec(double seconds)
void sleep(double seconds)
double seconds(ROS::Duration duration)