Fork of ROS Serial Library

Dependencies:   BufferedSerial

Files at this revision

API Documentation at this revision

Comitter:
garyservin
Date:
Sat Dec 31 00:59:58 2016 +0000
Parent:
0:9e9b7db60fd5
Child:
2:e75264f7cf89
Commit message:
Add missing round() method

Changed in this revision

ros/duration.h Show annotated file Show diff for this revision Revisions of this file
ros/time.h Show annotated file Show diff for this revision Revisions of this file
--- a/ros/duration.h	Sat Dec 31 00:48:34 2016 +0000
+++ b/ros/duration.h	Sat Dec 31 00:59:58 2016 +0000
@@ -53,6 +53,7 @@
         normalizeSecNSecSigned(sec, nsec);
       }
 
+      double round(double number) { return number < 0.0 ? ceil(number - 0.5): floor(number + 0.5); }
       double toSec() const { return (double)sec + 1e-9*(double)nsec; };
       void fromSec(double t) { sec = (uint32_t) floor(t); nsec = (uint32_t) round((t-sec) * 1e9); };
 
--- a/ros/time.h	Sat Dec 31 00:48:34 2016 +0000
+++ b/ros/time.h	Sat Dec 31 00:59:58 2016 +0000
@@ -54,6 +54,7 @@
         normalizeSecNSec(sec, nsec);
       }
 
+      double round(double number) { return number < 0.0 ? ceil(number - 0.5): floor(number + 0.5); }
       double toSec() const { return (double)sec + 1e-9*(double)nsec; };
       void fromSec(double t) { sec = (uint32_t) floor(t); nsec = (uint32_t) round((t-sec) * 1e9); };