Skip to content

Commit 22d7f72

Browse files
committed
Fix dynamics function and linting
1 parent c37b666 commit 22d7f72

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

drone_estimators/estimator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ def __init__(
8585
estimate_dist_t: If the disturbance torques should be estimated, defaults to False.
8686
initial_obs: Optional, the initial observation of the environment's state. See the environment's observation space for details.
8787
"""
88-
8988
fx = dynamics_function(model, config)
90-
hx = observation_function()
89+
hx = observation_function
9190
# fx = jax.jit(dynamics_numeric(model, config))
9291
# hx = jax.jit(observation_function)
9392

drone_estimators/utils/dynamics.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from functools import partial
5+
import importlib
66
from typing import TYPE_CHECKING
77

88
from drone_models.core import parametrize
@@ -13,13 +13,16 @@
1313
from array_api_typing import Array
1414

1515

16-
def dynamics_function(model:str, config:str):
17-
"""TODO."""
18-
# Idea:
19-
# from drone_models.{model}.model import dynamics as fn
20-
21-
# return parametrize(fn, config)
22-
...
16+
def dynamics_function(model: str, config: str) -> Callable:
17+
"""Imports and return the correct dynamics function from the drone-models."""
18+
# Dynamically import the module
19+
module = importlib.import_module(f"drone_models.{model}.model")
20+
21+
# Get the `dynamics` function from the module
22+
fn = getattr(module, "dynamics")
23+
24+
# Parametrize it with the config
25+
return parametrize(fn, config)
2326

2427

2528
def observation_function(

0 commit comments

Comments
 (0)