def publish(self): self.calculate_voltage() if self.voltage != None and self.current != None and (rospy.Time.now() - self.last_update) < rospy.Duration(1): ps = PowerState() ps.header.stamp = self.last_update ps.voltage = self.voltage ps.current = self.current ps.power_consumption = self.calculate_power_consumption() ps.relative_remaining_capacity = self.calculate_relative_remaining_capacity() ps.charging = self.charging self.pub_power_state.publish(ps)
def publish(self): if self.voltage != None and self.current != None and self.remaining_capacity != None and self.full_charge_capacity != None and self.temperature != None and (rospy.Time.now() - self.last_update) < rospy.Duration(1): ps = PowerState() ps.header.stamp = self.last_update ps.voltage = self.voltage ps.current = self.current ps.power_consumption = self.calculate_power_consumption() ps.remaining_capacity = self.remaining_capacity ps.relative_remaining_capacity = self.calculate_relative_remaining_capacity() ps.charging = self.charging ps.time_remaining = self.calculate_time_remaining() ps.temperature = self.temperature self.pub_power_state.publish(ps) return ps