From: Erik Andresen Date: Sat, 25 Nov 2017 11:15:18 +0000 (+0100) Subject: analyzers: rename voltage to power and add current value X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=commitdiff_plain;h=c25e62e7fc33b0c130a95f5c50c360d9edbba278 analyzers: rename voltage to power and add current value --- diff --git a/config/analyzers.yaml b/config/analyzers.yaml index 8215e23..ab0ae08 100644 --- a/config/analyzers.yaml +++ b/config/analyzers.yaml @@ -9,7 +9,7 @@ analyzers: path: Reset startswith: 'Reset' timeout: -1 - voltage: + power: type: diagnostic_aggregator/GenericAnalyzer - path: Voltage - startswith: 'Voltage' + path: Power + startswith: 'Power' diff --git a/scripts/wt_node.py b/scripts/wt_node.py index 4a6af7b..e234058 100755 --- a/scripts/wt_node.py +++ b/scripts/wt_node.py @@ -94,7 +94,7 @@ class WTBase: #print struct.unpack(">B", i2c_read_reg(0x50, 0xA2, 1))[0] # count test self.get_motor_err() self.get_odom() - self.get_voltage() + self.get_power() if ir_count == 0: self.get_dist_left() @@ -206,21 +206,20 @@ class WTBase: msg.status.append(stat) self.pub_diag.publish(msg) - def get_voltage(self): + def get_power(self): volt = struct.unpack(">h", i2c_read_reg(0x52, 0x09, 2))[0]/100.0 + current = struct.unpack(">h", i2c_read_reg(0x52, 0x0D, 2))[0]/1000.0 msg = DiagnosticArray() msg.header.stamp = rospy.Time.now() stat = DiagnosticStatus() - stat.name = "Voltage" - stat.level = DiagnosticStatus.ERROR if volt < 7 else DiagnosticStatus.OK - stat.message = "%.2fV" % volt + stat.name = "Power" + stat.level = DiagnosticStatus.ERROR if volt < 7 or current > 5 else DiagnosticStatus.OK + stat.message = "%.2fV, %.2fA" % (volt, current) msg.status.append(stat) self.pub_diag.publish(msg) - current = struct.unpack(">h", i2c_read_reg(0x52, 0x0D, 2))[0]/1000.0 - if self.pub_battery.get_num_connections() > 0: batmsg = BatteryState() batmsg.header.stamp = rospy.Time.now()