From 33c5c768daae255d9d5f6e3763351a9af66548e7 Mon Sep 17 00:00:00 2001 From: alekskl01 Date: Sun, 4 Feb 2024 14:58:14 +0100 Subject: [PATCH] Added buffer to voltage and current logging --- mission/internal_status/src/battery_monitor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mission/internal_status/src/battery_monitor.py b/mission/internal_status/src/battery_monitor.py index fadfcb7bb..8ed022da0 100755 --- a/mission/internal_status/src/battery_monitor.py +++ b/mission/internal_status/src/battery_monitor.py @@ -90,9 +90,12 @@ def system_cb(self, event): # Write voltage to CSV file current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) - self.csv_writer.writerow( - [current_time, self.system_voltage, - self.system_current]) # 'None' for current placeholder + self.buffer.append([current_time, self.system_voltage, self.system_current]) # 'None' for current placeholder + + if len(self.buffer) >= 100: + for data in self.buffer: + self.csv_writer.writerow(data) + self.buffer.clear() if self.system_voltage < self.critical_level: rospy.logerr(