Hello there,
I tried creating an OCP with parametric cost functions, but when I tried to set the parameters using
AcadosOcp.set()
, I got the following error:
acados_update_params: trying to set 0 parameters for external functions. External function has 17 parameters. Exiting.
I actually got the same one when I ran acados/examples/acados_python/tests/test_parametric_nonlinear_constrain_h.py
.
Is that normal ?
Thanks a lot for your help.
Best,
Tudor
FreyJo
October 20, 2022, 7:34am
2
Hi Tudor,
the test definitely works for me and on our CI pipeline.
Did you modify the test in some way?
If so, can you clearly state what you modified?
Best,
Jonathan
Hi,
I did not modify the file, but I have actually built acados from a slightly older commit (44ddf35db7fa11f26dfc36d5c9b0f3e30343530e, posted on sept 28) as I had trouble building acados with the latest commit. Should I try to ?
Best,
Tudor
P.S.: I should mention I am using acados on a M2 Mac, so maybe there are some deeper bugs coming from that
FreyJo
October 20, 2022, 11:17am
4
It might really be specific to your system.
Somehow
value_.shape[0]
is 0
for you in this line:
stage = c_int(stage_)
# treat parameters separately
if field_ == 'p':
getattr(self.shared_lib, f"{self.model_name}_acados_update_params").argtypes = [c_void_p, c_int, POINTER(c_double)]
getattr(self.shared_lib, f"{self.model_name}_acados_update_params").restype = c_int
value_data = cast(value_.ctypes.data, POINTER(c_double))
assert getattr(self.shared_lib, f"{self.model_name}_acados_update_params")(self.capsule, stage, value_data, value_.shape[0])==0
else:
if field_ not in constraints_fields + cost_fields + out_fields:
raise Exception(f"AcadosOcpSolver.set(): '{field}' is not a valid argument.\n"
f" Possible values are {constraints_fields + cost_fields + out_fields + ['p']}.")
self.shared_lib.ocp_nlp_dims_get_from_attr.argtypes = \
[c_void_p, c_void_p, c_void_p, c_int, c_char_p]
self.shared_lib.ocp_nlp_dims_get_from_attr.restype = c_int
dims = self.shared_lib.ocp_nlp_dims_get_from_attr(self.nlp_config, \
I hope you can debug this a bit further on your system.
I debugged the code to inspect value_.shape[0]
and it is 42 just as it should be . Could the arguments not be in the right order ?
FreyJo
October 20, 2022, 4:11pm
6
I think this was the issue:
acados:master
← acados:fix_python_param_set
opened 04:10PM - 20 Oct 22 UTC
Please let me know if that solves it for you.
Yes everything runs as it should, thank you very much for your quick corrections
1 Like