Skip to content

Commit c67cf90

Browse files
committed
start porting to new drone model
1 parent 74d5712 commit c67cf90

2 files changed

Lines changed: 12 additions & 34 deletions

File tree

drone_estimators/estimator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ukf_predict_correct,
1515
)
1616
from drone_estimators.structs import SigmaPointsSettings, UKFData, UKFSettings
17-
from drone_estimators.utils.dynamics import get_dynamics, observation_function
17+
from drone_estimators.utils.dynamics import dynamics_function, observation_function
1818

1919
if TYPE_CHECKING:
2020
from array_api_typing import Array
@@ -85,8 +85,9 @@ 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-
fx = get_dynamics(model, config)
89-
hx = observation_function
88+
89+
fx = dynamics_function(model, config)
90+
hx = observation_function()
9091
# fx = jax.jit(dynamics_numeric(model, config))
9192
# hx = jax.jit(observation_function)
9293

drone_estimators/utils/dynamics.py

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,21 @@
55
from functools import partial
66
from typing import TYPE_CHECKING
77

8-
from drone_models.so_rpy_rotor_drag import dynamics as so_rpy_rotor_drag_dynamics
9-
from drone_models.so_rpy_rotor_drag.params import SoRpyRotorDragParams
8+
from drone_models.core import parametrize
109

1110
if TYPE_CHECKING:
1211
from collections.abc import Callable
1312

1413
from array_api_typing import Array
1514

1615

17-
def get_dynamics(
18-
model_type: str, drone_model: str
19-
) -> Callable[
20-
[Array, Array, Array, Array, Array, Array | None, Array | None, Array | None],
21-
tuple[Array, Array, Array, Array, Array | None],
22-
]:
23-
"""Simplifies drone-model dynamics by adding all arguments for the given drone_model."""
24-
match model_type:
25-
case "so_rpy_rotor_drag_dynamics":
26-
params = SoRpyRotorDragParams.load(drone_model)
27-
return partial(
28-
so_rpy_rotor_drag_dynamics,
29-
mass=params.mass,
30-
gravity_vec=params.gravity_vec,
31-
J=params.J,
32-
J_inv=params.J_inv,
33-
KF=params.KF,
34-
KM=params.KM,
35-
thrust_time_coef=params.thrust_time_coef,
36-
acc_coef=params.acc_coef,
37-
cmd_f_coef=params.cmd_f_coef,
38-
rpy_coef=params.rpy_coef,
39-
rpy_rates_coef=params.rpy_rates_coef,
40-
cmd_rpy_coef=params.cmd_rpy_coef,
41-
drag_linear_coef=params.drag_linear_coef,
42-
drag_square_coef=params.drag_square_coef,
43-
)
44-
case _:
45-
raise NotImplementedError(f"Model type {model_type} not supported.")
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+
...
4623

4724

4825
def observation_function(

0 commit comments

Comments
 (0)