From 30db3756e031c0f625427be5c142a6751c7021f7 Mon Sep 17 00:00:00 2001 From: Luis Camero Date: Mon, 23 Oct 2023 17:20:47 -0400 Subject: [PATCH 1/7] Update commit --- clearpath_config/platform/battery.py | 155 ++++++++++++++++++ clearpath_config/platform/platform.py | 35 +++- .../sample/a200/a200_default.yaml | 3 + .../sample/a200/a200_dual_laser.yaml | 3 + clearpath_config/sample/a200/a200_sample.yaml | 3 + .../sample/a200/a200_velodyne.yaml | 3 + .../sample/j100/j100_default.yaml | 3 + .../sample/j100/j100_dual_laser.yaml | 3 + clearpath_config/sample/j100/j100_sample.yaml | 3 + .../sample/j100/j100_velodyne.yaml | 3 + 10 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 clearpath_config/platform/battery.py diff --git a/clearpath_config/platform/battery.py b/clearpath_config/platform/battery.py new file mode 100644 index 0000000..1f3aaeb --- /dev/null +++ b/clearpath_config/platform/battery.py @@ -0,0 +1,155 @@ +# Software License Agreement (BSD) +# +# @author Luis Camero +# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of Clearpath Robotics nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +from clearpath_config.common.types.config import BaseConfig +from clearpath_config.common.types.platform import Platform +from clearpath_config.common.utils.dictionary import flip_dict + + +class BatteryConfig(BaseConfig): + BATTERY = "battery" + + # Models + MODEL = "model" + UNKNOWN = "unknown" + # Husky Lead Acid + ES20_12C = "ES20-12C" + # Husky/Jackal Li_ION + HE2613 = "HE2613" + # Warthog Lead Acid + U1_35 = "U1-35" + # Warthog LiFEPO4 + ALM12V35 = "ALM12V35" + U24_12XP = "U24-12XP" + U27_12XP = "U27-12XP" + + # Configurations + CONFIGURATION = "configuration" + _2S1P = "2S1P" + _1S3P = "1S3P" + _1S4P = "1S4P" + _1S1P = "1S1P" + _4S3P = "4S3P" + _4S1P = "4S1P" + + VALID = { + Platform.GENERIC: { + UNKNOWN: [UNKNOWN] + }, + Platform.A200: { + ES20_12C: [_2S1P], + HE2613: [_1S3P, _1S4P], + }, + Platform.J100: { + HE2613: [_1S1P], + }, + Platform.W200: { + U1_35: [_4S3P], + ALM12V35: [_4S3P], + U24_12XP: [_4S1P], + U27_12XP: [_4S1P], + }, + } + + TEMPLATE = { + BATTERY: { + MODEL: MODEL, + CONFIGURATION: CONFIGURATION + } + } + + KEYS = flip_dict(TEMPLATE) + + DEFAULTS = { + MODEL: UNKNOWN, + CONFIGURATION: UNKNOWN + } + + def __init__( + self, + config: dict = {}, + model: str = DEFAULTS[MODEL], + configuration: str = DEFAULTS[CONFIGURATION], + ) -> None: + # Initialization + self._config = {} + self.model = model + self.configuration = configuration + # Setter Template + setters = { + self.KEYS[self.MODEL]: BatteryConfig.model, + self.KEYS[self.CONFIGURATION]: BatteryConfig.configuration, + } + super().__init__(setters, config, self.BATTERY) + + def update(self, serial_number: bool = False) -> None: + if serial_number: + platform = BaseConfig.get_platform_model() + self.model = list(self.VALID[platform])[0] + self.configuration = list(self.VALID[platform][self.model])[0] + + @property + def model(self) -> str: + self.set_config_param( + key=self.KEYS[self.MODEL], + value=self._model + ) + return self._model + + @model.setter + def model(self, value: str) -> None: + platform = BaseConfig.get_platform_model() + assert platform in self.VALID, ( + "Platform must be one of: %s" % self.VALID + ) + assert value in self.VALID[platform], ( + "Battery model for platform '%s' must be one of: %s" % (platform, self.VALID[platform]) + ) + self._model = value + + @property + def configuration(self) -> str: + self.set_config_param( + key=self.KEYS[self.CONFIGURATION], + value=self._configuration + ) + return self._configuration + + @configuration.setter + def configuration(self, value: str) -> None: + platform = BaseConfig.get_platform_model() + assert platform in self.VALID, ( + "Platform must be one of: %s" % self.VALID + ) + assert self.model in self.VALID[platform], ( + "Battery model for platform '%s' must be one of: %s" % (platform, self.VALID[platform]) + ) + assert value in self.VALID[platform][self.model], ( + "Battery configuration for platform '%s', and battery model '%s' must be one of: %s" % ( + platform, self.model, self.VALID[platform][self.model]) + ) + self._configuration = value diff --git a/clearpath_config/platform/platform.py b/clearpath_config/platform/platform.py index 453f471..32501da 100644 --- a/clearpath_config/platform/platform.py +++ b/clearpath_config/platform/platform.py @@ -27,6 +27,7 @@ # POSSIBILITY OF SUCH DAMAGE. from clearpath_config.common.types.config import BaseConfig from clearpath_config.common.utils.dictionary import flip_dict +from clearpath_config.platform.battery import BatteryConfig from clearpath_config.platform.extras import ExtrasConfig from clearpath_config.platform.attachments.config import BaseAttachmentsConfig from clearpath_config.platform.attachments.mux import AttachmentsConfigMux @@ -38,15 +39,19 @@ class PlatformConfig(BaseConfig): # Controllers PS4 = "ps4" LOGITECH = "logitech" + CONTROLLER = "controller" ATTACHMENTS = "attachments" # Extras EXTRAS = "extras" + # Battery + BATTERY = "battery" TEMPLATE = { PLATFORM: { CONTROLLER: CONTROLLER, ATTACHMENTS: ATTACHMENTS, + BATTERY: BATTERY, EXTRAS: EXTRAS } } @@ -57,7 +62,8 @@ class PlatformConfig(BaseConfig): # PLATFORM CONTROLLER: PS4, ATTACHMENTS: {}, - EXTRAS: ExtrasConfig.DEFAULTS + BATTERY: BatteryConfig.DEFAULTS, + EXTRAS: ExtrasConfig.DEFAULTS, } def __init__( @@ -65,17 +71,20 @@ def __init__( config: dict = {}, controller: str = DEFAULTS[CONTROLLER], attachments: str = DEFAULTS[ATTACHMENTS], - extras: str = DEFAULTS[EXTRAS] + battery: dict = DEFAULTS[BATTERY], + extras: dict = DEFAULTS[EXTRAS], ) -> None: # Initialization self._config = {} self.controller = controller self.attachments = attachments + self._battery = BatteryConfig(battery) self._extras = ExtrasConfig(extras) # Setter Template setters = { self.KEYS[self.CONTROLLER]: PlatformConfig.controller, self.KEYS[self.ATTACHMENTS]: PlatformConfig.attachments, + self.KEYS[self.BATTERY]: PlatformConfig.battery, self.KEYS[self.EXTRAS]: PlatformConfig.extras } super().__init__(setters, config, self.PLATFORM) @@ -87,6 +96,8 @@ def update(self, serial_number=False) -> None: # TODO: Set PACS Profile # Reload extras self.extras.update(serial_number=serial_number) + # Reload battery + self.battery.update(serial_number=serial_number) @property def controller(self) -> str: @@ -139,3 +150,23 @@ def extras(self, value: dict | ExtrasConfig) -> None: def get_controller(self) -> str: return self.controller + + @property + def battery(self) -> BatteryConfig: + self.set_config_param( + key=self.KEYS[self.BATTERY], + value=self._battery.config[self.BATTERY] + ) + return self._battery + + @battery.setter + def battery(self, value: dict | BatteryConfig) -> None: + if isinstance(value, dict): + self._battery.config = value + elif isinstance(value, BatteryConfig): + self._battery = value + else: + assert isinstance(value, dict) or ( + isinstance(value, BatteryConfig)), ( + "Battery configuration must be of type 'dict' or 'BatteryConfig'" + ) diff --git a/clearpath_config/sample/a200/a200_default.yaml b/clearpath_config/sample/a200/a200_default.yaml index 8d25bd2..ab11934 100644 --- a/clearpath_config/sample/a200/a200_default.yaml +++ b/clearpath_config/sample/a200/a200_default.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: ES20-12C + configuration: 2S1P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_dual_laser.yaml b/clearpath_config/sample/a200/a200_dual_laser.yaml index 64bd89e..a91d85b 100644 --- a/clearpath_config/sample/a200/a200_dual_laser.yaml +++ b/clearpath_config/sample/a200/a200_dual_laser.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: ES20-12C + configuration: 2S1P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_sample.yaml b/clearpath_config/sample/a200/a200_sample.yaml index 13e1b08..ba38865 100644 --- a/clearpath_config/sample/a200/a200_sample.yaml +++ b/clearpath_config/sample/a200/a200_sample.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: ES20-12C + configuration: 2S1P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_velodyne.yaml b/clearpath_config/sample/a200/a200_velodyne.yaml index a8eb08e..f57e28c 100644 --- a/clearpath_config/sample/a200/a200_velodyne.yaml +++ b/clearpath_config/sample/a200/a200_velodyne.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: ES20-12C + configuration: 2S1P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/j100/j100_default.yaml b/clearpath_config/sample/j100/j100_default.yaml index f727899..44ac95f 100644 --- a/clearpath_config/sample/j100/j100_default.yaml +++ b/clearpath_config/sample/j100/j100_default.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: HE2613 + configuration: 1S1P attachments: front_fender: enabled: true diff --git a/clearpath_config/sample/j100/j100_dual_laser.yaml b/clearpath_config/sample/j100/j100_dual_laser.yaml index 4d46089..cb60f78 100644 --- a/clearpath_config/sample/j100/j100_dual_laser.yaml +++ b/clearpath_config/sample/j100/j100_dual_laser.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: HE2613 + configuration: 1S1P attachments: front_fender: enabled: true diff --git a/clearpath_config/sample/j100/j100_sample.yaml b/clearpath_config/sample/j100/j100_sample.yaml index b0b3485..55cf5f5 100644 --- a/clearpath_config/sample/j100/j100_sample.yaml +++ b/clearpath_config/sample/j100/j100_sample.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: HE2613 + configuration: 1S1P attachments: front_fender: enabled: true diff --git a/clearpath_config/sample/j100/j100_velodyne.yaml b/clearpath_config/sample/j100/j100_velodyne.yaml index 9e51798..6c5f1d7 100644 --- a/clearpath_config/sample/j100/j100_velodyne.yaml +++ b/clearpath_config/sample/j100/j100_velodyne.yaml @@ -15,6 +15,9 @@ system: workspaces: [] platform: controller: ps4 + battery: + model: HE2613 + configuration: 1S1P attachments: front_fender: enabled: true From b06766d2d2f079db20b80e908b63c5d1c97f0c55 Mon Sep 17 00:00:00 2001 From: Luis Camero Date: Mon, 23 Oct 2023 17:38:16 -0400 Subject: [PATCH 2/7] Switched configurations --- clearpath_config/platform/battery.py | 38 ++++++++++--------- .../sample/a200/a200_default.yaml | 2 +- .../sample/a200/a200_dual_laser.yaml | 2 +- clearpath_config/sample/a200/a200_sample.yaml | 2 +- .../sample/a200/a200_velodyne.yaml | 2 +- .../sample/j100/j100_default.yaml | 2 +- .../sample/j100/j100_dual_laser.yaml | 2 +- clearpath_config/sample/j100/j100_sample.yaml | 2 +- .../sample/j100/j100_velodyne.yaml | 2 +- 9 files changed, 28 insertions(+), 26 deletions(-) diff --git a/clearpath_config/platform/battery.py b/clearpath_config/platform/battery.py index 1f3aaeb..8992c77 100644 --- a/clearpath_config/platform/battery.py +++ b/clearpath_config/platform/battery.py @@ -49,29 +49,29 @@ class BatteryConfig(BaseConfig): # Configurations CONFIGURATION = "configuration" - _2S1P = "2S1P" - _1S3P = "1S3P" - _1S4P = "1S4P" - _1S1P = "1S1P" - _4S3P = "4S3P" - _4S1P = "4S1P" + S2P1 = "S2P1" + S1P3 = "S1P3" + S1P4 = "S1P4" + S1P1 = "S1P1" + S4P3 = "S4P3" + S4P1 = "S4P1" VALID = { Platform.GENERIC: { UNKNOWN: [UNKNOWN] }, Platform.A200: { - ES20_12C: [_2S1P], - HE2613: [_1S3P, _1S4P], + ES20_12C: [S2P1], + HE2613: [S1P3, S1P4], }, Platform.J100: { - HE2613: [_1S1P], + HE2613: [S1P1], }, Platform.W200: { - U1_35: [_4S3P], - ALM12V35: [_4S3P], - U24_12XP: [_4S1P], - U27_12XP: [_4S1P], + U1_35: [S4P3], + ALM12V35: [S4P3], + U24_12XP: [S4P1], + U27_12XP: [S4P1], }, } @@ -124,10 +124,11 @@ def model(self) -> str: def model(self, value: str) -> None: platform = BaseConfig.get_platform_model() assert platform in self.VALID, ( - "Platform must be one of: %s" % self.VALID + "Platform must be one of: %s" % list(self.VALID) ) assert value in self.VALID[platform], ( - "Battery model for platform '%s' must be one of: %s" % (platform, self.VALID[platform]) + "Battery model for platform '%s' must be one of: %s" % ( + platform, list(self.VALID[platform])) ) self._model = value @@ -143,13 +144,14 @@ def configuration(self) -> str: def configuration(self, value: str) -> None: platform = BaseConfig.get_platform_model() assert platform in self.VALID, ( - "Platform must be one of: %s" % self.VALID + "Platform must be one of: %s" % list(self.VALID) ) assert self.model in self.VALID[platform], ( - "Battery model for platform '%s' must be one of: %s" % (platform, self.VALID[platform]) + "Battery model for platform '%s' must be one of: %s" % ( + platform, list(self.VALID[platform])) ) assert value in self.VALID[platform][self.model], ( "Battery configuration for platform '%s', and battery model '%s' must be one of: %s" % ( - platform, self.model, self.VALID[platform][self.model]) + platform, self.model, list(self.VALID[platform][self.model])) ) self._configuration = value diff --git a/clearpath_config/sample/a200/a200_default.yaml b/clearpath_config/sample/a200/a200_default.yaml index ab11934..2f1bc5d 100644 --- a/clearpath_config/sample/a200/a200_default.yaml +++ b/clearpath_config/sample/a200/a200_default.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20-12C - configuration: 2S1P + configuration: S21P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_dual_laser.yaml b/clearpath_config/sample/a200/a200_dual_laser.yaml index a91d85b..c7870d0 100644 --- a/clearpath_config/sample/a200/a200_dual_laser.yaml +++ b/clearpath_config/sample/a200/a200_dual_laser.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20-12C - configuration: 2S1P + configuration: S21P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_sample.yaml b/clearpath_config/sample/a200/a200_sample.yaml index ba38865..788830b 100644 --- a/clearpath_config/sample/a200/a200_sample.yaml +++ b/clearpath_config/sample/a200/a200_sample.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20-12C - configuration: 2S1P + configuration: S21P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_velodyne.yaml b/clearpath_config/sample/a200/a200_velodyne.yaml index f57e28c..b10f65f 100644 --- a/clearpath_config/sample/a200/a200_velodyne.yaml +++ b/clearpath_config/sample/a200/a200_velodyne.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20-12C - configuration: 2S1P + configuration: S21P attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/j100/j100_default.yaml b/clearpath_config/sample/j100/j100_default.yaml index 44ac95f..07c5bdb 100644 --- a/clearpath_config/sample/j100/j100_default.yaml +++ b/clearpath_config/sample/j100/j100_default.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: HE2613 - configuration: 1S1P + configuration: S1P1 attachments: front_fender: enabled: true diff --git a/clearpath_config/sample/j100/j100_dual_laser.yaml b/clearpath_config/sample/j100/j100_dual_laser.yaml index cb60f78..e811177 100644 --- a/clearpath_config/sample/j100/j100_dual_laser.yaml +++ b/clearpath_config/sample/j100/j100_dual_laser.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: HE2613 - configuration: 1S1P + configuration: S1P1 attachments: front_fender: enabled: true diff --git a/clearpath_config/sample/j100/j100_sample.yaml b/clearpath_config/sample/j100/j100_sample.yaml index 55cf5f5..2762668 100644 --- a/clearpath_config/sample/j100/j100_sample.yaml +++ b/clearpath_config/sample/j100/j100_sample.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: HE2613 - configuration: 1S1P + configuration: S1P1 attachments: front_fender: enabled: true diff --git a/clearpath_config/sample/j100/j100_velodyne.yaml b/clearpath_config/sample/j100/j100_velodyne.yaml index 6c5f1d7..9d008a7 100644 --- a/clearpath_config/sample/j100/j100_velodyne.yaml +++ b/clearpath_config/sample/j100/j100_velodyne.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: HE2613 - configuration: 1S1P + configuration: S1P1 attachments: front_fender: enabled: true From 61d5259e1022cb579acb05532e1b35a77d580ffb Mon Sep 17 00:00:00 2001 From: Luis Camero Date: Mon, 23 Oct 2023 17:42:59 -0400 Subject: [PATCH 3/7] Updated battery model --- clearpath_config/platform/battery.py | 16 ++++++++-------- clearpath_config/sample/a200/a200_default.yaml | 2 +- .../sample/a200/a200_dual_laser.yaml | 2 +- clearpath_config/sample/a200/a200_sample.yaml | 2 +- clearpath_config/sample/a200/a200_velodyne.yaml | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clearpath_config/platform/battery.py b/clearpath_config/platform/battery.py index 8992c77..0d5b7f9 100644 --- a/clearpath_config/platform/battery.py +++ b/clearpath_config/platform/battery.py @@ -37,15 +37,15 @@ class BatteryConfig(BaseConfig): MODEL = "model" UNKNOWN = "unknown" # Husky Lead Acid - ES20_12C = "ES20-12C" + ES20_12C = "ES20_12C" # Husky/Jackal Li_ION HE2613 = "HE2613" # Warthog Lead Acid - U1_35 = "U1-35" + U1_35 = "U1_35" # Warthog LiFEPO4 - ALM12V35 = "ALM12V35" - U24_12XP = "U24-12XP" - U27_12XP = "U27-12XP" + NEC_ALM12V35 = "NEC_ALM12V35" + VALENCE_U24_12XP = "VALENCE_U24_12XP" + VALENCE_U27_12XP = "VALENCE_U27_12XP" # Configurations CONFIGURATION = "configuration" @@ -69,9 +69,9 @@ class BatteryConfig(BaseConfig): }, Platform.W200: { U1_35: [S4P3], - ALM12V35: [S4P3], - U24_12XP: [S4P1], - U27_12XP: [S4P1], + NEC_ALM12V35: [S4P3], + VALENCE_U24_12XP: [S4P1], + VALENCE_U27_12XP: [S4P1], }, } diff --git a/clearpath_config/sample/a200/a200_default.yaml b/clearpath_config/sample/a200/a200_default.yaml index 2f1bc5d..a85b7d5 100644 --- a/clearpath_config/sample/a200/a200_default.yaml +++ b/clearpath_config/sample/a200/a200_default.yaml @@ -16,7 +16,7 @@ system: platform: controller: ps4 battery: - model: ES20-12C + model: ES20_12C configuration: S21P attachments: front_bumper: diff --git a/clearpath_config/sample/a200/a200_dual_laser.yaml b/clearpath_config/sample/a200/a200_dual_laser.yaml index c7870d0..2227ae4 100644 --- a/clearpath_config/sample/a200/a200_dual_laser.yaml +++ b/clearpath_config/sample/a200/a200_dual_laser.yaml @@ -16,7 +16,7 @@ system: platform: controller: ps4 battery: - model: ES20-12C + model: ES20_12C configuration: S21P attachments: front_bumper: diff --git a/clearpath_config/sample/a200/a200_sample.yaml b/clearpath_config/sample/a200/a200_sample.yaml index 788830b..d9cde29 100644 --- a/clearpath_config/sample/a200/a200_sample.yaml +++ b/clearpath_config/sample/a200/a200_sample.yaml @@ -16,7 +16,7 @@ system: platform: controller: ps4 battery: - model: ES20-12C + model: ES20_12C configuration: S21P attachments: front_bumper: diff --git a/clearpath_config/sample/a200/a200_velodyne.yaml b/clearpath_config/sample/a200/a200_velodyne.yaml index b10f65f..c322567 100644 --- a/clearpath_config/sample/a200/a200_velodyne.yaml +++ b/clearpath_config/sample/a200/a200_velodyne.yaml @@ -16,7 +16,7 @@ system: platform: controller: ps4 battery: - model: ES20-12C + model: ES20_12C configuration: S21P attachments: front_bumper: From 56a447eb7eb9f395b8f3c3ab7f67375bf7c1bd01 Mon Sep 17 00:00:00 2001 From: Luis Camero Date: Mon, 23 Oct 2023 17:52:07 -0400 Subject: [PATCH 4/7] Fixed typo in samples --- clearpath_config/sample/a200/a200_default.yaml | 2 +- clearpath_config/sample/a200/a200_dual_laser.yaml | 2 +- clearpath_config/sample/a200/a200_sample.yaml | 2 +- clearpath_config/sample/a200/a200_velodyne.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clearpath_config/sample/a200/a200_default.yaml b/clearpath_config/sample/a200/a200_default.yaml index a85b7d5..e5bb4ee 100644 --- a/clearpath_config/sample/a200/a200_default.yaml +++ b/clearpath_config/sample/a200/a200_default.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20_12C - configuration: S21P + configuration: S2P1 attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_dual_laser.yaml b/clearpath_config/sample/a200/a200_dual_laser.yaml index 2227ae4..843063a 100644 --- a/clearpath_config/sample/a200/a200_dual_laser.yaml +++ b/clearpath_config/sample/a200/a200_dual_laser.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20_12C - configuration: S21P + configuration: S2P1 attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_sample.yaml b/clearpath_config/sample/a200/a200_sample.yaml index d9cde29..48d5576 100644 --- a/clearpath_config/sample/a200/a200_sample.yaml +++ b/clearpath_config/sample/a200/a200_sample.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20_12C - configuration: S21P + configuration: S2P1 attachments: front_bumper: enabled: true diff --git a/clearpath_config/sample/a200/a200_velodyne.yaml b/clearpath_config/sample/a200/a200_velodyne.yaml index c322567..5baeb66 100644 --- a/clearpath_config/sample/a200/a200_velodyne.yaml +++ b/clearpath_config/sample/a200/a200_velodyne.yaml @@ -17,7 +17,7 @@ platform: controller: ps4 battery: model: ES20_12C - configuration: S21P + configuration: S2P1 attachments: front_bumper: enabled: true From 753dcbc2f58142ea68ebeb60a7577f3fdd6c0789 Mon Sep 17 00:00:00 2001 From: Luis Camero Date: Mon, 23 Oct 2023 18:03:24 -0400 Subject: [PATCH 5/7] Detailed errors --- clearpath_config/platform/battery.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/clearpath_config/platform/battery.py b/clearpath_config/platform/battery.py index 0d5b7f9..6410e3e 100644 --- a/clearpath_config/platform/battery.py +++ b/clearpath_config/platform/battery.py @@ -123,13 +123,15 @@ def model(self) -> str: @model.setter def model(self, value: str) -> None: platform = BaseConfig.get_platform_model() - assert platform in self.VALID, ( + assert platform in self.VALID, (( + "Platform %s is invalid. " % platform + "Platform must be one of: %s" % list(self.VALID) - ) - assert value in self.VALID[platform], ( + )) + assert value in self.VALID[platform], (( + "Battery model %s is invalid. " % value + "Battery model for platform '%s' must be one of: %s" % ( platform, list(self.VALID[platform])) - ) + )) self._model = value @property @@ -143,15 +145,18 @@ def configuration(self) -> str: @configuration.setter def configuration(self, value: str) -> None: platform = BaseConfig.get_platform_model() - assert platform in self.VALID, ( + assert platform in self.VALID, (( + "Platform %s is invalid. " % platform + "Platform must be one of: %s" % list(self.VALID) - ) - assert self.model in self.VALID[platform], ( + )) + assert self.model in self.VALID[platform], (( + "Battery model %s in invalid. " % self.model + "Battery model for platform '%s' must be one of: %s" % ( platform, list(self.VALID[platform])) - ) - assert value in self.VALID[platform][self.model], ( - "Battery configuration for platform '%s', and battery model '%s' must be one of: %s" % ( + )) + assert value in self.VALID[platform][self.model], (( + "Battery configuration %s invalid. " % value + + "For platform '%s' and battery model '%s', it must be one of: %s" % ( platform, self.model, list(self.VALID[platform][self.model])) - ) + )) self._configuration = value From 2edcc429a0946f5e71f685ac6530bf9cfee4e1a3 Mon Sep 17 00:00:00 2001 From: Luis Camero Date: Tue, 24 Oct 2023 17:10:14 -0400 Subject: [PATCH 6/7] Re-define DEFAULTS based on platform --- clearpath_config/platform/battery.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/clearpath_config/platform/battery.py b/clearpath_config/platform/battery.py index 6410e3e..9008008 100644 --- a/clearpath_config/platform/battery.py +++ b/clearpath_config/platform/battery.py @@ -97,8 +97,16 @@ def __init__( ) -> None: # Initialization self._config = {} - self.model = model - self.configuration = configuration + if model == self.DEFAULTS[self.MODEL] or model == self.UNKNOWN: + self.update_defaults() + self.model = self.DEFAULTS[self.MODEL] + else: + self.model = model + if configuration == self.DEFAULTS[self.CONFIGURATION] or model == self.UNKNOWN: + self.update_defaults() + self.configuration = self.DEFAULTS[self.CONFIGURATION] + else: + self.configuration = configuration # Setter Template setters = { self.KEYS[self.MODEL]: BatteryConfig.model, @@ -106,11 +114,16 @@ def __init__( } super().__init__(setters, config, self.BATTERY) + def update_defaults(self) -> None: + platform = BaseConfig.get_platform_model() + self.DEFAULTS[self.MODEL] = list(self.VALID[platform])[0] + self.DEFAULTS[self.CONFIGURATION] = list(self.VALID[platform][self.DEFAULTS[self.MODEL]])[0] + def update(self, serial_number: bool = False) -> None: if serial_number: - platform = BaseConfig.get_platform_model() - self.model = list(self.VALID[platform])[0] - self.configuration = list(self.VALID[platform][self.model])[0] + self.update_defaults() + self.model = self.DEFAULTS[self.MODEL] + self.configuration = self.DEFAULTS[self.CONFIGURATION] @property def model(self) -> str: From d5e94d3c215ec831c6e157c858677a240755adf8 Mon Sep 17 00:00:00 2001 From: Luis Camero Date: Wed, 25 Oct 2023 10:24:00 -0400 Subject: [PATCH 7/7] Fixed long line for linter --- clearpath_config/platform/battery.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clearpath_config/platform/battery.py b/clearpath_config/platform/battery.py index 9008008..47d17ca 100644 --- a/clearpath_config/platform/battery.py +++ b/clearpath_config/platform/battery.py @@ -117,7 +117,8 @@ def __init__( def update_defaults(self) -> None: platform = BaseConfig.get_platform_model() self.DEFAULTS[self.MODEL] = list(self.VALID[platform])[0] - self.DEFAULTS[self.CONFIGURATION] = list(self.VALID[platform][self.DEFAULTS[self.MODEL]])[0] + self.DEFAULTS[self.CONFIGURATION] = list( + self.VALID[platform][self.DEFAULTS[self.MODEL]])[0] def update(self, serial_number: bool = False) -> None: if serial_number: