Skip to content

Commit

Permalink
Default value for mterm/lterm in MPC
Browse files Browse the repository at this point in the history
Fixes #86
  • Loading branch information
Felix-Mac committed Feb 14, 2022
1 parent 89d5096 commit 7c0b397
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions do_mpc/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,18 @@ def set_objective(self, mterm=None, lterm=None):
if not isinstance(lterm, (casadi.DM, casadi.SX, casadi.MX)):
raise Exception('lterm must be of type casadi.DM, casadi.SX or casadi.MX. You have: {}.'.format(type(lterm)))

self.mterm = mterm
if mterm is None:
self.mterm = DM(0)
else:
self.mterm = mterm
# TODO: This function should be evaluated with scaled variables.
self.mterm_fun = Function('mterm', [_x, _tvp, _p], [mterm])

self.lterm = lterm
if lterm is None:
self.lterm = DM(0)
else:
self.lterm = lterm

self.lterm_fun = Function('lterm', [_x, _u, _z, _tvp, _p], [lterm])

# Check if lterm and mterm use invalid variables as inputs.
Expand Down

0 comments on commit 7c0b397

Please sign in to comment.