From d4efda507c469f567d2a04e68722aa76ad7021fa Mon Sep 17 00:00:00 2001 From: Nathan Gill Date: Wed, 29 Oct 2025 09:47:25 +0000 Subject: [PATCH 1/2] rename marker types for consistency with docs and rulebook --- robot/game_config/__init__.py | 3 +++ robot/game_config/markers.py | 6 +++--- robot/game_config/targets.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/robot/game_config/__init__.py b/robot/game_config/__init__.py index f97ba60..60f778c 100644 --- a/robot/game_config/__init__.py +++ b/robot/game_config/__init__.py @@ -17,8 +17,11 @@ BLUE = (255, 0, 0) # Blue WHITE = (255, 255, 255) # White +SECTOR = TEAM # 2026 ONLY, ALIAS `TEAM` AS `SECTOR` + __all__ = ( "TEAM", + "SECTOR", "TARGET_TYPE", "MARKER", "TARGET_MARKER", diff --git a/robot/game_config/markers.py b/robot/game_config/markers.py index de875f5..41c5884 100644 --- a/robot/game_config/markers.py +++ b/robot/game_config/markers.py @@ -24,7 +24,7 @@ class MARKER_TYPE(enum.Enum): # Keep something like this to determine if a marker is a wall or not. TARGET = enum.auto() ARENA = enum.auto() - ARENA_OBJECT = enum.auto() + TREE = enum.auto() class BASE_MARKER: # Base marker class that TARGET_MARKER and ARENA_MARKER derive from. @@ -79,10 +79,10 @@ def __repr__(self) -> str: class ARENA_OBJECT_MARKER(BASE_MARKER): # A non-interactable object in the arena, that is not a wall. def __init__(self, id: int) -> None: - super().__init__(id, MARKER_TYPE.ARENA_OBJECT) + super().__init__(id, MARKER_TYPE.TREE) def __repr__(self) -> str: - return f"" + return f"" class TARGET_MARKER(BASE_MARKER): # This is a game object rather than a wall. Add properties you want to keep track of def __init__( diff --git a/robot/game_config/targets.py b/robot/game_config/targets.py index c4f777d..cd27e3c 100644 --- a/robot/game_config/targets.py +++ b/robot/game_config/targets.py @@ -5,8 +5,8 @@ """ class TARGET_TYPE(enum.Enum): - SUPPLY_L = "SUPPLY_L" # This matches T0, for example. - SUPPLY_H = "SUPPLY_H" + SUPPLY_CRATE = "SUPPLY_L" # This matches T0, for example. + SUPPLY_DROP = "SUPPLY_H" # There is no T value for ARENA, so there is no way that the assignment of team to a marker can accidentally assign ARENA if the logic goes wrong. From 7c13868ecf699918f8ae86041578825ae8f39b1b Mon Sep 17 00:00:00 2001 From: Nathan Gill Date: Wed, 29 Oct 2025 09:59:51 +0000 Subject: [PATCH 2/2] add safe fallback for battery voltage on older revisions --- robot/greengiant.py | 11 +++++++++-- robot/wrapper.py | 13 +++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/robot/greengiant.py b/robot/greengiant.py index de8d339..f2b24f8 100644 --- a/robot/greengiant.py +++ b/robot/greengiant.py @@ -160,6 +160,7 @@ def _decrement_pin_index(index): _GG_MOTOR_ERROR_STATE = 40 _GG_SYSTEM_ERROR_STATE = 41 +V_ZEN = (10.1) def read_high_low_data(bus, address): """Fetches and combines data stored across two bytes""" @@ -250,8 +251,14 @@ def get_version(self): return self._bus.read_byte_data(_GG_I2C_ADDR, _GG_VERSION) def get_battery_voltage(self): - # both GG and PiLow use a 1/3 divider and a 4.096v reference giving a max readable voltage of ~12.3v - return read_high_low_data(self._bus, _GG_BATTERY_V_H) + # Firmware version 12 and later reports voltage differently + if self._version < 12: + # both GG and PiLow use a 1/3 divider and a 4.096v reference giving a max readable voltage of ~12.3v + return read_high_low_data(self._bus, _GG_BATTERY_V_H) * _GG_BATTERY_MAX_READING / _GG_BATTERY_ADC_MAX + else: + # Hardware change for Cambridge brains in Nov 2025 to use a zener diode + return ((read_high_low_data(self._bus, _GG_BATTERY_V_H) / 65535) * 4.096) + V_ZEN + def get_fvr_reading(self): """Return the fixed voltage reading. The number read here is sampling the 4.096v reference using the VCC rail (GG only) diff --git a/robot/wrapper.py b/robot/wrapper.py index 501e992..065709d 100644 --- a/robot/wrapper.py +++ b/robot/wrapper.py @@ -34,8 +34,6 @@ class to their respecitve classes # this boot cycle. This is to highlight weird behaviour in the arena COPY_STAT_FILE = "/tmp/usb_file_uploaded" -V_ZEN = (10.1) - def setup_logging(level): """Display the just the message when logging events Sets the logging level to `level`""" @@ -167,14 +165,13 @@ def report_hardware_status(self): """Print out a nice log message at the start of each robot init with the hardware status""" - battery_voltage = ((self._green_giant.get_battery_voltage() / 65535) * 4.096) + V_ZEN + battery_voltage = self._green_giant.get_battery_voltage() battery_str = "Battery Voltage: %.2fv" % battery_voltage # GG cannot read voltages above 12.2v - #if battery_voltage > 12.2: - # battery_str = "Battery Voltage: > 12.2v" - # if battery_voltage < 11.5: - # self._warnings.append("Battery voltage below 11.5v, consider " - # "changing for a charged battery") + if battery_voltage > 12.2: + battery_str = "Battery Voltage: > 12.2v" + elif battery_voltage < 11.5: + self._warnings.append("Battery voltage below 11.5v, consider changing for a charged battery") if self._gg_version < 3: self._warnings.append(