Skip to content

Commit

Permalink
Added feature flag to enable movement without an estop
Browse files Browse the repository at this point in the history
  • Loading branch information
fsinapi committed Jul 21, 2023
1 parent 8cd95c5 commit 15dc4c7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
16 changes: 16 additions & 0 deletions api/src/opentrons/config/advanced_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ class Setting(NamedTuple):
title="Disable the LED status bar on the Flex.",
description="This setting disables the LED status bar on the Flex.",
),
SettingDefinition(
_id="estopNotRequired",
title="If enabled, the Flex gantry can move with no estop attached.",
description="This setting allows the gantry on the Flex to move with no estop attached.",
),
]

if ARCHITECTURE == SystemArchitecture.BUILDROOT:
Expand Down Expand Up @@ -587,6 +592,16 @@ def _migrate26to27(previous: SettingsMap) -> SettingsMap:
return newmap


def _migrate27to28(previous: SettingsMap) -> SettingsMap:
"""Migrate to version 28 of the feature flags file.
- Adds the estopNotRequired config element.
"""
newmap = {k: v for k, v in previous.items()}
newmap["estopNotRequired"] = None
return newmap


_MIGRATIONS = [
_migrate0to1,
_migrate1to2,
Expand Down Expand Up @@ -615,6 +630,7 @@ def _migrate26to27(previous: SettingsMap) -> SettingsMap:
_migrate24to25,
_migrate25to26,
_migrate26to27,
_migrate27to28,
]
"""
List of all migrations to apply, indexed by (version - 1). See _migrate below
Expand Down
5 changes: 5 additions & 0 deletions api/src/opentrons/config/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ def overpressure_detection_enabled() -> bool:
def status_bar_enabled() -> bool:
"""Whether the status bar is enabled."""
return not advs.get_setting_with_env_overload("disableStatusBar")


def require_estop() -> bool:
"""Whether the OT3 should allow gantry movements with no Estop plugged in."""
return not advs.get_setting_with_env_overload("estopNotRequired")
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def requires_estop(func: Wrapped) -> Wrapped:
@wraps(func)
async def wrapper(self: OT3Controller, *args: Any, **kwargs: Any) -> Any:
state = self._estop_state_machine.state
if state == EstopState.NOT_PRESENT:
if state == EstopState.NOT_PRESENT and ff.require_estop():
raise EStopNotPresentError(
message="An Estop must be plugged in to move the robot."
)
Expand Down
17 changes: 16 additions & 1 deletion api/tests/opentrons/config/test_advanced_settings_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@pytest.fixture
def migrated_file_version() -> int:
return 27
return 28


# make sure to set a boolean value in default_file_settings only if
Expand All @@ -27,6 +27,7 @@ def default_file_settings() -> Dict[str, Any]:
"disableStallDetection": None,
"disableStatusBar": None,
"disableOverpressureDetection": None,
"estopNotRequired": None,
}


Expand Down Expand Up @@ -333,6 +334,18 @@ def v27_config(v26_config: Dict[str, Any]) -> Dict[str, Any]:
return r


@pytest.fixture
def v28_config(v27_config: Dict[str, Any]) -> Dict[str, Any]:
r = v27_config.copy()
r.update(
{
"_version": 28,
"estopNotRequired": None,
}
)
return r


@pytest.fixture(
scope="session",
params=[
Expand Down Expand Up @@ -365,6 +378,7 @@ def v27_config(v26_config: Dict[str, Any]) -> Dict[str, Any]:
lazy_fixture("v25_config"),
lazy_fixture("v26_config"),
lazy_fixture("v27_config"),
lazy_fixture("v28_config"),
],
)
def old_settings(request: pytest.FixtureRequest) -> Dict[str, Any]:
Expand Down Expand Up @@ -454,4 +468,5 @@ def test_ensures_config() -> None:
"rearPanelIntegration": None,
"disableStallDetection": None,
"disableStatusBar": None,
"estopNotRequired": None,
}

0 comments on commit 15dc4c7

Please sign in to comment.