ros melodic library with custom message

Dependents:   Robot_team1_QEI_Douglas Robot_team1

Revision:
1:afa33e06a2ca
Parent:
0:020db18a476d
--- a/ros_lib/ros/time.h	Wed Oct 30 14:59:49 2019 +0000
+++ b/ros_lib/ros/time.h	Tue Nov 12 13:54:52 2019 +0000
@@ -41,41 +41,32 @@
 
 namespace ros
 {
-void normalizeSecNSec(uint32_t &sec, uint32_t &nsec);
+  void normalizeSecNSec(uint32_t &sec, uint32_t &nsec);
 
-class Time
-{
-public:
-  uint32_t sec, nsec;
+  class Time
+  {
+    public:
+      uint32_t sec, nsec;
+
+      Time() : sec(0), nsec(0) {}
+      Time(uint32_t _sec, uint32_t _nsec) : sec(_sec), nsec(_nsec)
+      {
+        normalizeSecNSec(sec, nsec);
+      }
 
-  Time() : sec(0), nsec(0) {}
-  Time(uint32_t _sec, uint32_t _nsec) : sec(_sec), nsec(_nsec)
-  {
-    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); };
 
-  double toSec() const
-  {
-    return (double)sec + 1e-9 * (double)nsec;
+      uint32_t toNsec() { return (uint32_t)sec*1000000000ull + (uint32_t)nsec; };
+      Time& fromNSec(int32_t t);
+
+      Time& operator +=(const Duration &rhs);
+      Time& operator -=(const Duration &rhs);
+
+      static Time now();
+      static void setNow( Time & new_now);
   };
-  void fromSec(double t)
-  {
-    sec = (uint32_t) floor(t);
-    nsec = (uint32_t) round((t - sec) * 1e9);
-  };
-
-  uint32_t toNsec()
-  {
-    return (uint32_t)sec * 1000000000ull + (uint32_t)nsec;
-  };
-  Time& fromNSec(int32_t t);
-
-  Time& operator +=(const Duration &rhs);
-  Time& operator -=(const Duration &rhs);
-
-  static Time now();
-  static void setNow(Time & new_now);
-};
 
 }