Skip to content

Commit

Permalink
Adjust pressure range
Browse files Browse the repository at this point in the history
to accomodate for the range Flotilla accepts to run mission
  • Loading branch information
tsundvoll committed Feb 9, 2024
1 parent 72569fb commit 0eab043
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/isar_robot/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@


def _get_battery_level() -> float:
return 100 - random.randrange(0, 100) * 0.5
# Return random float in the range [50, 100]
return random.randint(500, 1000) / 10.0


def _get_pressure_level() -> float:
# Return random float in the range [0.011, 0.079]
min_pressure = 11 # millibar
max_pressure = 79 # millibar
millibar_to_bar: float = 1 / 1000
return (80 - random.randrange(10, 80) * 0.5) * millibar_to_bar
return random.randint(min_pressure, max_pressure) * millibar_to_bar


def _get_obstacle_status() -> bool:
Expand Down
15 changes: 15 additions & 0 deletions tests/test_telemetry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from isar_robot.telemetry import _get_pressure_level, _get_battery_level


def test_get_battery_level():
for _ in range(100):
pressure_level: float = _get_battery_level()
assert pressure_level >= 50
assert pressure_level <= 100


def test_get_pressure_level():
for _ in range(100):
pressure_level: float = _get_pressure_level()
assert pressure_level >= 0.011
assert pressure_level <= 0.079

0 comments on commit 0eab043

Please sign in to comment.