Skip to content

Commit

Permalink
Modified battery state test
Browse files Browse the repository at this point in the history
  • Loading branch information
SantamRC committed Feb 2, 2024
1 parent 48303fa commit fdf8d02
Showing 1 changed file with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,37 @@ def __init__(self):
BatteryState,
"/ap/battery/battery0",
self.battery_callback,
10, # QoS profile depth
10,
)

def battery_callback(self, msg):
# Assert the information here
assert isinstance(msg.header, Header)
assert isinstance(msg.header.stamp, Time)
assert isinstance(msg.voltage, float)
assert isinstance(msg.temperature, float)
assert isinstance(msg.current, float)
assert isinstance(msg.charge, float)
assert isinstance(msg.capacity, float)
assert isinstance(msg.design_capacity, float)
assert isinstance(msg.percentage, float)
assert isinstance(msg.power_supply_status, int)
assert isinstance(msg.power_supply_health, int)
assert isinstance(msg.power_supply_technology, int)
assert isinstance(msg.present, bool)
assert isinstance(msg.cell_voltage, list)
assert isinstance(msg.cell_temperature, list)
assert isinstance(msg.location, str)
assert isinstance(msg.serial_number, str)
try:
# Assert the information here
assert isinstance(msg.header, Header)
assert isinstance(msg.header.stamp, Time)
assert isinstance(msg.voltage, float)
assert isinstance(msg.temperature, float)
assert isinstance(msg.current, float)
assert isinstance(msg.charge, float)
assert isinstance(msg.capacity, float)
assert isinstance(msg.design_capacity, float)
assert isinstance(msg.percentage, float)
assert isinstance(msg.power_supply_status, int)
assert isinstance(msg.power_supply_health, int)
assert isinstance(msg.power_supply_technology, int)
assert isinstance(msg.present, bool)
assert isinstance(msg.cell_voltage, list)
assert isinstance(msg.cell_temperature, list)
assert isinstance(msg.location, str)
assert isinstance(msg.serial_number, str)

print("Assertion passed. Received valid Battery State Message")

except AssertionError as e:
print(f"Assertion failed. Invalid Battery State message: {e}")
finally:
# Stop the ROS node and exit the program
rclpy.shutdown()


def test_battery_state(args=None):
Expand Down

0 comments on commit fdf8d02

Please sign in to comment.