Skip to content

Commit 2d439e5

Browse files
committed
adding minor changes to most files, and some modifications to IMM filter.
1 parent 7bfbfe5 commit 2d439e5

9 files changed

Lines changed: 332 additions & 19 deletions

File tree

src/gncpy/control/elqr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ def calculate_control(
832832
print("Starting ELQR optimization loop...")
833833

834834
for ii in range(self.max_iters):
835+
print(f"Loop Iteration : {ii}")
835836
# forward pass
836837
traj = self.forward_pass(
837838
ii,
@@ -844,12 +845,13 @@ def calculate_control(
844845
inv_state_args,
845846
inv_ctrl_args,
846847
)
847-
848+
print("Quadratizing final cost")
848849
# quadratize final cost
849850
traj = self.quadratize_final_cost(
850851
ii, num_timesteps, traj, time_vec, cost_args
851852
)
852853

854+
print("Starting Backward Pass")
853855
# backward pass
854856
traj = self.backward_pass(
855857
ii,

src/gncpy/dynamics/basic/clohessy_wiltshire_orbit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, **kwargs):
2929
else:
3030
self.__model = cpp_bindings.ClohessyWiltshire(0.01, 0.0)
3131
if "control_model" in kwargs and kwargs["control_model"] is not None:
32-
self.__model.set_control_model(kwargs("control_model"))
32+
self.__model.set_control_model(kwargs["control_model"])
3333

3434
@property
3535
def allow_cpp(self):

src/gncpy/dynamics/basic/clohessy_wiltshire_orbit2d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def __init__(self, mean_motion=None, **kwargs):
3030
super().__init__(**kwargs)
3131
self.__controlParams = cpp_control.ControlParams()
3232
self.__stateTransParams = cpp_bindings.StateTransParams()
33-
33+
3434
if self.mean_motion is not None:
3535
self.__model = cpp_bindings.ClohessyWiltshire2D(0.01, mean_motion)
3636
else:
3737
self.__model = cpp_bindings.ClohessyWiltshire2D(0.01, 0.0)
3838
if "control_model" in kwargs and kwargs["control_model"] is not None:
39-
self.__model.set_control_model(kwargs("control_model"))
39+
self.__model.set_control_model(kwargs["control_model"])
4040

4141
@property
4242
def allow_cpp(self):

src/gncpy/dynamics/basic/double_integrator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, **kwargs):
2020
self.__stateTransParams = cpp_bindings.StateTransParams()
2121
self.__model = cpp_bindings.DoubleIntegrator(0.1)
2222
if "control_model" in kwargs and kwargs["control_model"] is not None:
23-
self.__model.set_control_model(kwargs("control_model"))
23+
self.__model.set_control_model(kwargs["control_model"])
2424

2525
@property
2626
def allow_cpp(self):

src/gncpy/filters/extended_kalman_filter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
from gncpy.filters.kalman_filter import KalmanFilter
1111

1212

13+
# def _cont_dyn(self, t, x, *args):
14+
# """Used in integrator if an ode list is specified."""
15+
# out = np.zeros(x.shape)
16+
17+
# for ii, f in enumerate(self._ode_lst):
18+
# out[ii] = f(t, x, *args)
19+
# return out
20+
1321
class ExtendedKalmanFilter(KalmanFilter):
1422
"""Implementation of a continuous-discrete time Extended Kalman Filter.
1523
@@ -127,8 +135,10 @@ def set_state_model(self, dyn_obj=None, ode_lst=None):
127135
msg = "Invalid state model specified. Check arguments"
128136
raise RuntimeError(msg)
129137

138+
# @staticmethod
130139
def _cont_dyn(self, t, x, *args):
131140
"""Used in integrator if an ode list is specified."""
141+
132142
out = np.zeros(x.shape)
133143

134144
for ii, f in enumerate(self._ode_lst):

src/gncpy/filters/interacting_multiple_model.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,16 @@ def correct(self, timestep, meas, *args, **kwargs):
211211
self.cov_list[ii] = filt.cov.copy()
212212
new_weight_list[ii] = meas_fit_prob_list[ii] * self.filt_weights[ii]
213213
out_meas_fit_prob = np.sum(new_weight_list)
214-
if np.sum(new_weight_list) == 0:
215-
new_weight_list = new_weight_list * 0
216-
else:
214+
if np.sum(new_weight_list) != 0:
217215
new_weight_list = new_weight_list / np.sum(new_weight_list)
218-
self.filt_weights = new_weight_list
216+
self.filt_weights = new_weight_list
217+
else:
218+
self.filt_weights = np.array([1/len(new_weight_list) for x in range(1, len(new_weight_list))])
219219

220220
out_state = np.zeros(self.mean_list[0].shape)
221221
for ii in range(len(self.in_filt_list)):
222-
out_state += new_weight_list[ii] * self.mean_list[ii]
222+
out_state += self.filt_weights[ii] * self.mean_list[ii]
223+
# out_state += new_weight_list[ii] * self.mean_list[ii]
223224

224225
self.cur_out_state = out_state
225226
return (out_state, out_meas_fit_prob)

test/unit/test_dynamics.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,13 @@ def test_clohessy_wiltshire_control():
449449

450450
plt.close("all")
451451

452-
test_double_integrator_mat()
453-
test_double_integrator_prop()
454-
test_double_integrator_control()
452+
# test_double_integrator_mat()
453+
# test_double_integrator_prop()
454+
# test_double_integrator_control()
455455

456-
test_clohessy_wiltshire2d_mat()
457-
test_clohessy_wiltshire2d_prop()
458-
test_clohessy_wiltshire2d_control()
456+
# test_clohessy_wiltshire2d_mat()
457+
# test_clohessy_wiltshire2d_prop()
458+
# test_clohessy_wiltshire2d_control()
459459

460460
test_clohessy_wiltshire_mat()
461461
test_clohessy_wiltshire_prop()

0 commit comments

Comments
 (0)