test/time.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <vector>
31 
32 #include <gtest/gtest.h>
33 #include <ros/rate.h>
34 #include <ros/time.h>
35 #ifndef _WIN32
36 #include <sys/time.h>
37 #endif
38 
39 #include <boost/date_time/posix_time/ptime.hpp>
40 
41 using namespace ros;
42 
44 
45 double epsilon = 1e-9;
46 
47 void seed_rand()
48 {
49  //Seed random number generator with current microseond count
50 #ifndef _WIN32
51  timeval temp_time_struct;
52  gettimeofday(&temp_time_struct,NULL);
53  srand(temp_time_struct.tv_usec);
54 #else
55  srand(time(nullptr));
56 #endif
57 };
58 
59 void generate_rand_times(uint32_t range, uint64_t runs, std::vector<ros::Time>& values1, std::vector<ros::Time>& values2)
60 {
61  seed_rand();
62  values1.clear();
63  values2.clear();
64  values1.reserve(runs);
65  values2.reserve(runs);
66  for ( uint32_t i = 0; i < runs ; i++ )
67  {
68  values1.push_back(ros::Time( (rand() * range / RAND_MAX), (rand() * 1000000000ULL/RAND_MAX)));
69  values2.push_back(ros::Time( (rand() * range / RAND_MAX), (rand() * 1000000000ULL/RAND_MAX)));
70  }
71 }
72 
73 void generate_rand_durations(uint32_t range, uint64_t runs, std::vector<ros::Duration>& values1, std::vector<ros::Duration>& values2)
74 {
75  seed_rand();
76  values1.clear();
77  values2.clear();
78  values1.reserve(runs * 4);
79  values2.reserve(runs * 4);
80  for ( uint32_t i = 0; i < runs ; i++ )
81  {
82  // positive durations
83  values1.push_back(ros::Duration( (rand() * range / RAND_MAX), (rand() * 1000000000ULL/RAND_MAX)));
84  values2.push_back(ros::Duration( (rand() * range / RAND_MAX), (rand() * 1000000000ULL/RAND_MAX)));
85  EXPECT_GE(values1.back(), ros::Duration(0,0));
86  EXPECT_GE(values2.back(), ros::Duration(0,0));
87 
88  // negative durations
89  values1.push_back(ros::Duration( -(rand() * range / RAND_MAX), -(rand() * 1000000000ULL/RAND_MAX)));
90  values2.push_back(ros::Duration( -(rand() * range / RAND_MAX), -(rand() * 1000000000ULL/RAND_MAX)));
91  EXPECT_LE(values1.back(), ros::Duration(0,0));
92  EXPECT_LE(values2.back(), ros::Duration(0,0));
93 
94  // positive and negative durations
95  values1.push_back(ros::Duration( (rand() * range / RAND_MAX), (rand() * 1000000000ULL/RAND_MAX)));
96  values2.push_back(ros::Duration( -(rand() * range / RAND_MAX), -(rand() * 1000000000ULL/RAND_MAX)));
97  EXPECT_GE(values1.back(), ros::Duration(0,0));
98  EXPECT_LE(values2.back(), ros::Duration(0,0));
99 
100  // negative and positive durations
101  values1.push_back(ros::Duration( -(rand() * range / RAND_MAX), -(rand() * 1000000000ULL/RAND_MAX)));
102  values2.push_back(ros::Duration( (rand() * range / RAND_MAX), (rand() * 1000000000ULL/RAND_MAX)));
103  EXPECT_LE(values1.back(), ros::Duration(0,0));
104  EXPECT_GE(values2.back(), ros::Duration(0,0));
105  }
106 }
107 
108 TEST(Time, size)
109 {
110  ASSERT_EQ(sizeof(Time), 8);
111  ASSERT_EQ(sizeof(Duration), 8);
112 }
113 
114 TEST(Time, Comparitors)
115 {
116  std::vector<ros::Time> v1;
117  std::vector<ros::Time> v2;
118  generate_rand_times(100, 1000, v1,v2);
119 
120  for (uint32_t i = 0; i < v1.size(); i++)
121  {
122  if (v1[i].sec * 1000000000ULL + v1[i].nsec < v2[i].sec * 1000000000ULL + v2[i].nsec)
123  {
124  EXPECT_LT(v1[i], v2[i]);
125  // printf("%f %d ", v1[i].toSec(), v1[i].sec * 1000000000ULL + v1[i].nsec);
126  //printf("vs %f %d\n", v2[i].toSec(), v2[i].sec * 1000000000ULL + v2[i].nsec);
127  EXPECT_LE(v1[i], v2[i]);
128  EXPECT_NE(v1[i], v2[i]);
129  }
130  else if (v1[i].sec * 1000000000ULL + v1[i].nsec > v2[i].sec * 1000000000ULL + v2[i].nsec)
131  {
132  EXPECT_GT(v1[i], v2[i]);
133  EXPECT_GE(v1[i], v2[i]);
134  EXPECT_NE(v1[i], v2[i]);
135  }
136  else
137  {
138  EXPECT_EQ(v1[i], v2[i]);
139  EXPECT_LE(v1[i], v2[i]);
140  EXPECT_GE(v1[i], v2[i]);
141  }
142 
143  }
144 
145 }
146 
147 TEST(Time, ToFromDouble)
148 {
149  std::vector<ros::Time> v1;
150  std::vector<ros::Time> v2;
151  generate_rand_times(100, 1000, v1,v2);
152 
153  for (uint32_t i = 0; i < v1.size(); i++)
154  {
155  EXPECT_EQ(v1[i].toSec(), v1[i].fromSec(v1[i].toSec()).toSec());
156 
157  }
158 
159 }
160 
161 TEST(Time, RoundingError)
162 {
163  double someInt = 1031.0; // some integer
164  double t = std::nextafter(someInt, 0); // someint - epsilon
165  // t should be 1031.000000
166 
167  ros::Time exampleTime;
168  exampleTime.fromSec(t);
169 
170  // if rounded incorrectly, sec may be 1030
171  // and nsec may be 1e9.
172  EXPECT_EQ(exampleTime.sec, 1031);
173  EXPECT_EQ(exampleTime.nsec, 0);
174 }
175 
176 TEST(Time, OperatorPlus)
177 {
178  Time t(100, 0);
179  Duration d(100, 0);
180  Time r = t + d;
181  EXPECT_EQ(r.sec, 200UL);
182  EXPECT_EQ(r.nsec, 0UL);
183 
184  t = Time(0, 100000UL);
185  d = Duration(0, 100UL);
186  r = t + d;
187  EXPECT_EQ(r.sec, 0UL);
188  EXPECT_EQ(r.nsec, 100100UL);
189 
190  t = Time(0, 0);
191  d = Duration(10, 2000003000UL);
192  r = t + d;
193  EXPECT_EQ(r.sec, 12UL);
194  EXPECT_EQ(r.nsec, 3000UL);
195 }
196 
197 TEST(Time, OperatorMinus)
198 {
199  Time t(100, 0);
200  Duration d(100, 0);
201  Time r = t - d;
202  EXPECT_EQ(r.sec, 0UL);
203  EXPECT_EQ(r.nsec, 0UL);
204 
205  t = Time(0, 100000UL);
206  d = Duration(0, 100UL);
207  r = t - d;
208  EXPECT_EQ(r.sec, 0UL);
209  EXPECT_EQ(r.nsec, 99900UL);
210 
211  t = Time(30, 0);
212  d = Duration(10, 2000003000UL);
213  r = t - d;
214  EXPECT_EQ(r.sec, 17UL);
215  EXPECT_EQ(r.nsec, 999997000ULL);
216 }
217 
218 TEST(Time, OperatorPlusEquals)
219 {
220  Time t(100, 0);
221  Duration d(100, 0);
222  t += d;
223  EXPECT_EQ(t.sec, 200UL);
224  EXPECT_EQ(t.nsec, 0UL);
225 
226  t = Time(0, 100000UL);
227  d = Duration(0, 100UL);
228  t += d;
229  EXPECT_EQ(t.sec, 0UL);
230  EXPECT_EQ(t.nsec, 100100UL);
231 
232  t = Time(0, 0);
233  d = Duration(10, 2000003000UL);
234  t += d;
235  EXPECT_EQ(t.sec, 12UL);
236  EXPECT_EQ(t.nsec, 3000UL);
237 }
238 
239 TEST(Time, OperatorMinusEquals)
240 {
241  Time t(100, 0);
242  Duration d(100, 0);
243  t -= d;
244  EXPECT_EQ(t.sec, 0UL);
245  EXPECT_EQ(t.nsec, 0UL);
246 
247  t = Time(0, 100000UL);
248  d = Duration(0, 100UL);
249  t -= d;
250  EXPECT_EQ(t.sec, 0UL);
251  EXPECT_EQ(t.nsec, 99900UL);
252 
253  t = Time(30, 0);
254  d = Duration(10, 2000003000UL);
255  t -= d;
256  EXPECT_EQ(t.sec, 17UL);
257  EXPECT_EQ(t.nsec, 999997000ULL);
258 }
259 
260 TEST(Time, SecNSecConstructor)
261 {
262  Time t(100, 2000003000UL);
263  EXPECT_EQ(t.sec, 102UL);
264  EXPECT_EQ(t.nsec, 3000UL);
265 }
266 
267 TEST(Time, DontMungeStreamState)
268 {
269  std::ostringstream oss;
270  Time t(100, 2000003000UL);
271  oss << std::setfill('N');
272  oss << std::setw(13);
273  oss << t;
274 
275  EXPECT_EQ(oss.width(), 13);
276  EXPECT_EQ(oss.fill(), 'N');
277 }
278 
279 TEST(Time, ToFromBoost)
280 {
281  std::vector<ros::Time> v1;
282  std::vector<ros::Time> v2;
283  generate_rand_times(100, 1000, v1,v2);
284 
285  for (uint32_t i = 0; i < v1.size(); i++)
286  {
287  Time t = v1[i];
288  // dont assume that nanosecond are available
289  t.nsec = uint32_t(t.nsec / 1000.0) * 1000;
290  boost::posix_time::ptime b = t.toBoost();
291  Time tt = Time::fromBoost(b);
292  EXPECT_EQ(t, tt);
293  }
294 }
295 
296 TEST(Time, CastFromDoubleExceptions)
297 {
298  ros::Time::init();
299 
300  Time t1, t2, t3;
301  // Valid values to cast, must not throw exceptions
302  EXPECT_NO_THROW(t1.fromSec(4294967295.0));
303  EXPECT_NO_THROW(t2.fromSec(4294967295.999));
304  EXPECT_NO_THROW(t3.fromSec(0.0000001));
305 
306  // The next casts all incorrect.
307  EXPECT_THROW(t1.fromSec(4294967296.0), std::runtime_error);
308  EXPECT_THROW(t2.fromSec(-0.0001), std::runtime_error);
309  EXPECT_THROW(t3.fromSec(-4294967296.0), std::runtime_error);
310 }
311 
312 TEST(Time, OperatorMinusExceptions)
313 {
314  ros::Time::init();
315 
316  Time t1(2147483648, 0);
317  Time t2(2147483647, 999999999);
318  Time t3(2147483647, 999999998);
319  Time t4(4294967295, 999999999);
320  Time t5(4294967295, 999999998);
321  Time t6(0, 1);
322 
323  Duration d1(2147483647, 999999999);
324  Duration d2(-2147483648, 0);
325  Duration d3(-2147483648, 1);
326  Duration d4(0, 1);
327 
328  EXPECT_NO_THROW(t1 - t2);
329  EXPECT_NO_THROW(t3 - t2);
330  EXPECT_NO_THROW(t4 - t5);
331 
332  EXPECT_NO_THROW(t1 - d1);
333  EXPECT_NO_THROW(t5 - d1);
334 
335  EXPECT_THROW(t4 - t6, std::runtime_error);
336  EXPECT_THROW(t4 - t3, std::runtime_error);
337 
338  EXPECT_THROW(t1 - d2, std::runtime_error);
339  EXPECT_THROW(t2 - d2, std::runtime_error);
340  EXPECT_THROW(t4 - d3, std::runtime_error);
341 }
342 
343 TEST(Time, OperatorPlusExceptions)
344 {
345  ros::Time::init();
346 
347  Time t1(2147483648, 0);
348  Time t2(2147483647, 999999999);
349  Time t4(4294967295, 999999999);
350  Time t5(4294967295, 999999998);
351 
352  Duration d1(2147483647, 999999999);
353  Duration d2(-2147483648, 1);
354  Duration d3(0, 2);
355  Duration d4(0, 1);
356 
357  EXPECT_NO_THROW(t2 + d2);
358  EXPECT_NO_THROW(t1 + d1);
359 
360  EXPECT_THROW(t4 + d4, std::runtime_error);
361  EXPECT_THROW(t4 + d1, std::runtime_error);
362  EXPECT_THROW(t5 + d3, std::runtime_error);
363 }
364 
365 
366 /************************************* Duration Tests *****************/
367 
368 TEST(Duration, Comparitors)
369 {
370  std::vector<ros::Duration> v1;
371  std::vector<ros::Duration> v2;
372  generate_rand_durations(100, 1000, v1,v2);
373 
374  for (uint32_t i = 0; i < v1.size(); i++)
375  {
376  if (v1[i].sec * 1000000000LL + v1[i].nsec < v2[i].sec * 1000000000LL + v2[i].nsec)
377  {
378  EXPECT_LT(v1[i], v2[i]);
379 // printf("%f %lld ", v1[i].toSec(), v1[i].sec * 1000000000LL + v1[i].nsec);
380 // printf("vs %f %lld\n", v2[i].toSec(), v2[i].sec * 1000000000LL + v2[i].nsec);
381  EXPECT_LE(v1[i], v2[i]);
382  EXPECT_NE(v1[i], v2[i]);
383  }
384  else if (v1[i].sec * 1000000000LL + v1[i].nsec > v2[i].sec * 1000000000LL + v2[i].nsec)
385  {
386  EXPECT_GT(v1[i], v2[i]);
387 // printf("%f %lld ", v1[i].toSec(), v1[i].sec * 1000000000LL + v1[i].nsec);
388 // printf("vs %f %lld\n", v2[i].toSec(), v2[i].sec * 1000000000LL + v2[i].nsec);
389  EXPECT_GE(v1[i], v2[i]);
390  EXPECT_NE(v1[i], v2[i]);
391  }
392  else
393  {
394  EXPECT_EQ(v1[i], v2[i]);
395  EXPECT_LE(v1[i], v2[i]);
396  EXPECT_GE(v1[i], v2[i]);
397  }
398 
399  }
400 }
401 
402 TEST(Duration, ToFromSec)
403 {
404  std::vector<ros::Duration> v1;
405  std::vector<ros::Duration> v2;
406  generate_rand_durations(100, 1000, v1,v2);
407 
408  for (uint32_t i = 0; i < v1.size(); i++)
409  {
410  EXPECT_EQ(v1[i].toSec(), v1[i].fromSec(v1[i].toSec()).toSec());
411  EXPECT_GE(ros::Duration(v1[i].toSec()).nsec, 0);
412  }
413 
414  EXPECT_EQ(ros::Duration(-0.5), ros::Duration(-1LL, 500000000LL));
415  EXPECT_EQ(ros::Duration(-0.5), ros::Duration(0, -500000000LL));
416 }
417 
418 
419 TEST(Duration, OperatorPlus)
420 {
421  std::vector<ros::Duration> v1;
422  std::vector<ros::Duration> v2;
423  generate_rand_durations(100, 1000, v1,v2);
424 
425  for (uint32_t i = 0; i < v1.size(); i++)
426  {
427  EXPECT_NEAR(v1[i].toSec() + v2[i].toSec(), (v1[i] + v2[i]).toSec(), epsilon);
428  ros::Duration temp = v1[i];
429  EXPECT_NEAR(v1[i].toSec() + v2[i].toSec(), (temp += v2[i]).toSec(), epsilon);
430 
431  }
432 
433 }
434 
435 TEST(Duration, OperatorMinus)
436 {
437  std::vector<ros::Duration> v1;
438  std::vector<ros::Duration> v2;
439  generate_rand_durations(100, 1000, v1,v2);
440 
441  for (uint32_t i = 0; i < v1.size(); i++)
442  {
443  EXPECT_NEAR(v1[i].toSec() - v2[i].toSec(), (v1[i] - v2[i]).toSec(), epsilon);
444  ros::Duration temp = v1[i];
445  EXPECT_NEAR(v1[i].toSec() - v2[i].toSec(), (temp -= v2[i]).toSec(), epsilon);
446 
447  EXPECT_NEAR(- v2[i].toSec(), (-v2[i]).toSec(), epsilon);
448 
449  }
450 
451 }
452 
453 TEST(Duration, OperatorTimes)
454 {
455  std::vector<ros::Duration> v1;
456  std::vector<ros::Duration> v2;
457  generate_rand_durations(100, 1000, v1,v2);
458 
459  for (uint32_t i = 0; i < v1.size(); i++)
460  {
461  EXPECT_NEAR(v1[i].toSec() * v2[i].toSec(), (v1[i] * v2[i].toSec()).toSec(), epsilon);
462  ros::Duration temp = v1[i];
463  EXPECT_NEAR(v1[i].toSec() * v2[i].toSec(), (temp *= v2[i].toSec()).toSec(), epsilon);
464 
465  }
466 
467 }
468 
469 TEST(Duration, OperatorPlusEquals)
470 {
471  Duration t(100, 0);
472  Duration d(100, 0);
473  t += d;
474  EXPECT_EQ(t.sec, 200L);
475  EXPECT_EQ(t.nsec, 0L);
476 
477  t = Duration(0, 100000L);
478  d = Duration(0, 100L);
479  t += d;
480  EXPECT_EQ(t.sec, 0L);
481  EXPECT_EQ(t.nsec, 100100L);
482 
483  t = Duration(0, 0);
484  d = Duration(10, 2000003000L);
485  t += d;
486  EXPECT_EQ(t.sec, 12L);
487  EXPECT_EQ(t.nsec, 3000L);
488 }
489 
490 TEST(Duration, OperatorMinusEquals)
491 {
492  Duration t(100, 0);
493  Duration d(100, 0);
494  t -= d;
495  EXPECT_EQ(t.sec, 0L);
496  EXPECT_EQ(t.nsec, 0L);
497 
498  t = Duration(0, 100000L);
499  d = Duration(0, 100L);
500  t -= d;
501  EXPECT_EQ(t.sec, 0L);
502  EXPECT_EQ(t.nsec, 99900L);
503 
504  t = Duration(30, 0);
505  d = Duration(10, 2000003000L);
506  t -= d;
507  EXPECT_EQ(t.sec, 17L);
508  EXPECT_EQ(t.nsec, 999997000L);
509 }
510 
511 void alarmHandler(int sig)
512 {
513 
514 }
515 
516 TEST(Duration, sleepWithSignal)
517 {
518 #ifndef _WIN32
519  signal(SIGALRM, alarmHandler);
520  alarm(1);
521 #endif
522 
523  Time start = Time::now();
524  Duration d(2.0);
525  bool rc = d.sleep();
526  Time end = Time::now();
527 
528  ASSERT_GT(end - start, d);
529  ASSERT_TRUE(rc);
530 }
531 
532 TEST(Rate, constructFromDuration){
533  Duration d(4, 0);
534  Rate r(d);
535  EXPECT_EQ(r.expectedCycleTime(), d);
536 }
537 
538 TEST(Rate, sleep_return_value_true){
539  Rate r(Duration(0.2));
540  Duration(r.expectedCycleTime() * 0.5).sleep();
541  EXPECT_TRUE(r.sleep());
542 }
543 
544 TEST(Rate, sleep_return_value_false){
545  Rate r(Duration(0.2));
546  Duration(r.expectedCycleTime() * 2).sleep();
547  EXPECT_FALSE(r.sleep()); // requested rate cannot be achieved
548 }
549 
550 TEST(WallRate, constructFromDuration){
551  Duration d(4, 0);
552  WallRate r(d);
553  WallDuration wd(4, 0);
554  EXPECT_EQ(r.expectedCycleTime(), wd);
555 }
556 
558 // WallTime/WallDuration
560 
561 
563 // SteadyTime/WallDuration
565 
566 TEST(SteadyTime, sleep){
567  SteadyTime start = SteadyTime::now();
568  WallDuration d(2.0);
569  bool rc = d.sleep();
570  SteadyTime end = SteadyTime::now();
571 
572  ASSERT_GT(end - start, d);
573  ASSERT_TRUE(rc);
574 }
575 
576 TEST(SteadyTime, sleepUntil){
577  SteadyTime start = SteadyTime::now();
578  SteadyTime end = start + WallDuration(2.0);
579  bool rc = SteadyTime::sleepUntil(end);
580  SteadyTime finished = SteadyTime::now();
581 
582  ASSERT_GT(finished, end);
583  ASSERT_TRUE(rc);
584 }
585 
586 int main(int argc, char **argv){
587  testing::InitGoogleTest(&argc, argv);
588  ros::Time::init();
589  return RUN_ALL_TESTS();
590 }
double epsilon
Definition: test/time.cpp:45
void seed_rand()
Definition: test/time.cpp:47
Time representation. May either represent wall clock time or ROS clock time.
Definition: time.h:180
uint32_t sec
Definition: time.h:133
bool sleep() const
sleep for the amount of time specified by this Duration. If a signal interrupts the sleep...
Definition: src/time.cpp:461
Class to help run loops at a desired frequency.
Definition: rate.h:51
Duration representation for use with the WallTime class.
Definition: duration.h:136
uint32_t nsec
Definition: time.h:133
int32_t nsec
Definition: duration.h:75
void alarmHandler(int sig)
Definition: test/time.cpp:511
Class to help run loops at a desired frequency. This version always uses wall-clock time...
Definition: rate.h:92
void generate_rand_durations(uint32_t range, uint64_t runs, std::vector< ros::Duration > &values1, std::vector< ros::Duration > &values2)
Definition: test/time.cpp:73
bool sleep() const
sleep for the amount of time specified by this Duration. If a signal interrupts the sleep...
Definition: src/time.cpp:545
static bool sleepUntil(const SteadyTime &end)
Sleep until a specific time has been reached.
Definition: src/time.cpp:450
static SteadyTime now()
Returns the current steady (monotonic) clock time.
Definition: src/time.cpp:523
TEST(Time, size)
Definition: test/time.cpp:108
Duration expectedCycleTime() const
Get the expected cycle time – one over the frequency passed in to the constructor.
Definition: rate.h:81
static void init()
Definition: src/time.cpp:326
Time representation. Always steady-clock time.
Definition: time.h:270
bool sleep()
Sleeps for any leftover time in a cycle. Calculated from the last time sleep, reset, or the constructor was called.
Definition: rate.cpp:56
Duration representation for use with the Time class.
Definition: duration.h:108
WallDuration expectedCycleTime() const
Get the expected cycle time – one over the frequency passed in to the constructor.
Definition: rate.h:122
T & fromSec(double t)
Definition: time.h:154
static Time now()
Retrieve the current time. If ROS clock time is in use, this returns the time according to the ROS cl...
Definition: src/time.cpp:298
static Time fromBoost(const boost::posix_time::ptime &t)
Definition: src/time.cpp:369
boost::posix_time::ptime toBoost() const
Definition: impl/time.h:164
void generate_rand_times(uint32_t range, uint64_t runs, std::vector< ros::Time > &values1, std::vector< ros::Time > &values2)
Definition: test/time.cpp:59
int main(int argc, char **argv)
Definition: test/time.cpp:586


rostime
Author(s): Josh Faust
autogenerated on Mon Aug 6 2018 02:22:28