Skip to content

Commit

Permalink
little zookeeper fixes (#24861)
Browse files Browse the repository at this point in the history
* little zookeeper fixes

* bump that up
  • Loading branch information
adeebshihadeh authored Jun 15, 2022
1 parent f8f4337 commit 6757e23
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 74 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ subprocess32 = "*"
tenacity = "*"
mpld3 = "*"
carla = {version = "==0.9.13", markers="platform_system != 'Darwin'"}
ft4222 = "*"

[packages]
atomicwrites = "*"
Expand Down
135 changes: 81 additions & 54 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions tools/zookeeper/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env python3

# Python library to control Zookeeper

import ft4222 # pylint: disable=import-error
import ft4222.I2CMaster # pylint: disable=import-error
import ft4222
import ft4222.I2CMaster

DEBUG = False

Expand Down
28 changes: 14 additions & 14 deletions tools/zookeeper/power_monitor.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#!/usr/bin/env python

#!/usr/bin/env python3
import sys
import time
from tools.zookeeper import Zookeeper

# Usage: check_consumption.py <averaging_time_sec> <max_average_power_W>
# Exit code: 0 -> passed
# 1 -> failed
from common.realtime import Ratekeeper
from common.filter_simple import FirstOrderFilter
from tools.zookeeper import Zookeeper

if __name__ == "__main__":
z = Zookeeper()
z.set_device_power(True)
z.set_device_ignition(False)

duration = None
if len(sys.argv) > 1:
duration = int(sys.argv[1])

rate = 123
rk = Ratekeeper(rate, print_delay_threshold=None)
fltr = FirstOrderFilter(0, 5, 1. / rate, initialized=False)

try:
start_time = time.monotonic()
measurements = []
while duration is None or time.monotonic() - start_time < duration:
p = z.read_power()
print(round(p, 3), "W")
measurements.append(p)
time.sleep(0.25)
fltr.update(z.read_power())
if rk.frame % rate == 0:
print(f"{fltr.x:.2f} W")
rk.keep_time()
except KeyboardInterrupt:
pass
finally:
average_power = sum(measurements)/len(measurements)
print(f"Average power: {round(average_power, 4)}W")
1 change: 0 additions & 1 deletion tools/zookeeper/requirements.txt

This file was deleted.

0 comments on commit 6757e23

Please sign in to comment.