From 96c2440fe184d5c4315babd1e8264d9af84d9f88 Mon Sep 17 00:00:00 2001 From: Jonathan Arreguit Date: Fri, 27 Sep 2024 09:25:27 +0200 Subject: [PATCH 1/6] [MODEL] Support for spawn constraints in animats --- farms_core/model/options.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/farms_core/model/options.py b/farms_core/model/options.py index 23ff329..0de748f 100644 --- a/farms_core/model/options.py +++ b/farms_core/model/options.py @@ -1,6 +1,6 @@ """Animat options""" -from enum import IntEnum +from enum import IntEnum, StrEnum, auto from typing import List, Dict, Union from ..options import Options @@ -11,6 +11,17 @@ class SpawnLoader(IntEnum): PYBULLET = 1 +class SpawnMode(StrEnum): + FREE = auto() + FIXED = auto() + SAGITTAL = auto() # Longitudinal + SAGITTAL3 = auto() + CORONAL = auto() # Frontal + CORONAL3 = auto() + TRANSVERSE = auto() # Horizontal + TRANSVERSE3 = auto() + + class MorphologyOptions(Options): """Morphology options""" @@ -88,8 +99,10 @@ class SpawnOptions(Options): def __init__(self, **kwargs): super().__init__() self.loader: SpawnLoader = kwargs.pop('loader') + self.mode: SpawnMode = kwargs.pop('mode', SpawnMode.FREE) self.pose: List[float] = [*kwargs.pop('pose')] self.velocity: List[float] = [*kwargs.pop('velocity')] + self.extras: Dict = kwargs.pop('extras', {}) assert len(self.pose) == 6 assert len(self.velocity) == 6 if kwargs: @@ -99,8 +112,8 @@ def __init__(self, **kwargs): def from_options(cls, kwargs: Dict): """From options""" options = {} - # Loader options['loader'] = kwargs.pop('spawn_loader', SpawnLoader.FARMS) + options['mode'] = kwargs.pop('spawn_mode', SpawnMode.FREE) options['pose'] = ( # Position in [m] list(kwargs.pop('spawn_position', [0, 0, 0])) From 02a3a5fd590e81174fcdfb83287cb9f29c5736c2 Mon Sep 17 00:00:00 2001 From: Jonathan Arreguit Date: Tue, 29 Oct 2024 15:33:14 +0100 Subject: [PATCH 2/6] [MODEL] Enum for spawn constraints instead of StrEnum Using Enum instead of StrEnum for Python 3.10 compatibility until EOL --- farms_core/model/options.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/farms_core/model/options.py b/farms_core/model/options.py index 0de748f..1e9a5b9 100644 --- a/farms_core/model/options.py +++ b/farms_core/model/options.py @@ -1,6 +1,6 @@ """Animat options""" -from enum import IntEnum, StrEnum, auto +from enum import IntEnum, Enum from typing import List, Dict, Union from ..options import Options @@ -11,15 +11,15 @@ class SpawnLoader(IntEnum): PYBULLET = 1 -class SpawnMode(StrEnum): - FREE = auto() - FIXED = auto() - SAGITTAL = auto() # Longitudinal - SAGITTAL3 = auto() - CORONAL = auto() # Frontal - CORONAL3 = auto() - TRANSVERSE = auto() # Horizontal - TRANSVERSE3 = auto() +class SpawnMode(str, Enum): # Not using StrEnum until Python 3.10 EOL + FREE = 'free' + FIXED = 'fixed' + SAGITTAL = 'sagital' # Longitudinal + SAGITTAL3 = 'sagital3' + CORONAL = 'coronal' # Frontal + CORONAL3 = 'coronal3' + TRANSVERSE = 'transverse' # Horizontal + TRANSVERSE3 = 'transverse3' class MorphologyOptions(Options): From d5ff1fc297d6b928ce83125f061d7fe21fe9dca1 Mon Sep 17 00:00:00 2001 From: Jonathan Arreguit Date: Tue, 29 Oct 2024 15:35:26 +0100 Subject: [PATCH 3/6] [MODEL] Added spawn plane constraints with 1 DoF rotation --- farms_core/model/options.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/farms_core/model/options.py b/farms_core/model/options.py index 1e9a5b9..44141ad 100644 --- a/farms_core/model/options.py +++ b/farms_core/model/options.py @@ -15,10 +15,13 @@ class SpawnMode(str, Enum): # Not using StrEnum until Python 3.10 EOL FREE = 'free' FIXED = 'fixed' SAGITTAL = 'sagital' # Longitudinal + SAGITTAL1 = 'sagital1' SAGITTAL3 = 'sagital3' CORONAL = 'coronal' # Frontal + CORONAL1 = 'coronal1' CORONAL3 = 'coronal3' TRANSVERSE = 'transverse' # Horizontal + TRANSVERSE1 = 'transverse1' TRANSVERSE3 = 'transverse3' From 2bc53c69918cdfc1fadb32a72fc56fc52529bf84 Mon Sep 17 00:00:00 2001 From: Jonathan Arreguit Date: Tue, 29 Oct 2024 17:14:18 +0100 Subject: [PATCH 4/6] [MODEL] Renamed plane constraints 1 to 0 DoF --- farms_core/model/options.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/farms_core/model/options.py b/farms_core/model/options.py index 44141ad..f5d861f 100644 --- a/farms_core/model/options.py +++ b/farms_core/model/options.py @@ -15,13 +15,13 @@ class SpawnMode(str, Enum): # Not using StrEnum until Python 3.10 EOL FREE = 'free' FIXED = 'fixed' SAGITTAL = 'sagital' # Longitudinal - SAGITTAL1 = 'sagital1' + SAGITTAL0 = 'sagital0' SAGITTAL3 = 'sagital3' CORONAL = 'coronal' # Frontal - CORONAL1 = 'coronal1' + CORONAL0 = 'coronal0' CORONAL3 = 'coronal3' TRANSVERSE = 'transverse' # Horizontal - TRANSVERSE1 = 'transverse1' + TRANSVERSE0 = 'transverse0' TRANSVERSE3 = 'transverse3' From ead92af3a396664feb96fcb7a9297146ab3d0801 Mon Sep 17 00:00:00 2001 From: Jonathan Arreguit Date: Tue, 29 Oct 2024 17:15:10 +0100 Subject: [PATCH 5/6] [MODEL] Added 1 DoF rotation spawn constraints --- farms_core/model/options.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/farms_core/model/options.py b/farms_core/model/options.py index f5d861f..4401d28 100644 --- a/farms_core/model/options.py +++ b/farms_core/model/options.py @@ -14,6 +14,9 @@ class SpawnLoader(IntEnum): class SpawnMode(str, Enum): # Not using StrEnum until Python 3.10 EOL FREE = 'free' FIXED = 'fixed' + ROTX = 'rotx' + ROTY = 'roty' + ROTZ = 'rotz' SAGITTAL = 'sagital' # Longitudinal SAGITTAL0 = 'sagital0' SAGITTAL3 = 'sagital3' From a15dd13ad88970e00e8a3ec7d50d04875da88dda Mon Sep 17 00:00:00 2001 From: Jonathan Arreguit Date: Fri, 25 Jul 2025 23:16:08 +0200 Subject: [PATCH 6/6] [SPAWN] Fixed constraints spelling --- farms_core/model/options.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/farms_core/model/options.py b/farms_core/model/options.py index 4401d28..33e8ba4 100644 --- a/farms_core/model/options.py +++ b/farms_core/model/options.py @@ -17,9 +17,9 @@ class SpawnMode(str, Enum): # Not using StrEnum until Python 3.10 EOL ROTX = 'rotx' ROTY = 'roty' ROTZ = 'rotz' - SAGITTAL = 'sagital' # Longitudinal - SAGITTAL0 = 'sagital0' - SAGITTAL3 = 'sagital3' + SAGITTAL = 'sagittal' # Longitudinal + SAGITTAL0 = 'sagittal0' + SAGITTAL3 = 'sagittal3' CORONAL = 'coronal' # Frontal CORONAL0 = 'coronal0' CORONAL3 = 'coronal3'