Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion interfaces/acados_template/acados_template/acados_ocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ def __init__(self):
self.__ubx_0 = np.array([])
self.__idxbx_0 = np.array([])
self.__idxbxe_0 = np.array([])
self.__has_x0 = False
# state bounds
self.__lbx = np.array([])
self.__ubx = np.array([])
Expand Down Expand Up @@ -1579,6 +1580,10 @@ def x0(self):
print("idxbxe_0: ", self.__idxbxe_0)
return None

@property
def has_x0(self):
return self.__has_x0

# SETTERS
@constr_type.setter
def constr_type(self, constr_type):
Expand Down Expand Up @@ -1634,14 +1639,14 @@ def idxbxe_0(self, idxbxe_0):
else:
raise Exception('Invalid idxbxe_0 value.')


@x0.setter
def x0(self, x0):
if isinstance(x0, np.ndarray):
self.__lbx_0 = x0
self.__ubx_0 = x0
self.__idxbx_0 = np.arange(x0.size)
self.__idxbxe_0 = np.arange(x0.size)
self.__has_x0 = True
else:
raise Exception('Invalid x0 value.')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ def make_ocp_dims_consistent(acados_ocp: AcadosOcp):
raise Exception('lbx_0, ubx_0 must be column vectors!')
dims.nbx_0 = constraints.lbx_0.size

if constraints.has_x0 and dims.nbx_0 != dims.nx:
raise Exception(f"x0 should have shape nx = {dims.nx}.")
if all(constraints.lbx_0 == constraints.ubx_0) and dims.nbx_0 == dims.nx \
and dims.nbxe_0 is None \
and (constraints.idxbxe_0.shape == constraints.idxbx_0.shape)\
Expand Down