Skip to content

Commit ee8eabe

Browse files
committed
�[200~fix: avoid double-counting of cross-coupling terms in MPC model
1 parent a456db5 commit ee8eabe

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/gem_controllers/mpc_current_controller.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ def control(self, state, reference):
156156
u_in=0, # inputs (or adapt for your motor)
157157
omega=omega
158158
)
159+
# Local indices for motor states
160+
self.local_idx = {name: i for i, name in enumerate(self.motor_state_names)}
161+
162+
# remove duplicated cross-coupling terms from g
163+
g[0] -= self.p * self.l_q / self.l_d * x[self.local_idx['i_sq']]
164+
g[1] += self.p * self.l_d / self.l_q * x[self.local_idx['i_sd']]
159165

160166
# Pass everything needed to _simulate_sequence
161167
_, best_sequence = self._simulate_sequence(

0 commit comments

Comments
 (0)