TUM-AAS / neural-mpc

Real-time Neural MPC: Deep Learning Model Predictive Control for Quadrotors and Agile Robotic Platforms
GNU General Public License v3.0
146 stars 16 forks source link

x_dot::init: Initialization failed since variables [gp_p, gp_a, gp_v, gp_r, trigger, f_a, df_a, a] are free #1

Closed alexbuyval closed 1 year ago

alexbuyval commented 1 year ago

Hi there,

First of all, thank you for the excellent work!

I tried to go through from all steps in readme and faced with the following error during a run:

python src/experiments/trajectory_test.py --model_version 9137159 --model_name simple_sim_mlp --model_typ mlp_approx

Traceback (most recent call last):
  File "src/experiments/trajectory_test.py", line 196, in <module>
    main(input_arguments)
  File "src/experiments/trajectory_test.py", line 43, in main
    quad_mpc = prepare_quadrotor_mpc(simulation_options, **params)
  File "/workspaces/neural_mpc/src/neural-mpc/ros_dd_mpc/src/experiments/comparative_experiment.py", line 126, in prepare_quadrotor_mpc
    quad_mpc = Quad3DMPC(my_quad, t_horizon=t_horizon, optimization_dt=node_dt, simulation_dt=simulation_dt,
  File "/workspaces/neural_mpc/src/neural-mpc/ros_dd_mpc/src/quad_mpc/quad_3d_mpc.py", line 88, in __init__
    self.quad_opt = Quad3DOptimizer(my_quad, t_horizon=t_horizon, n_nodes=n_nodes,
  File "/workspaces/neural_mpc/src/neural-mpc/ros_dd_mpc/src/quad_mpc/quad_3d_optimizer.py", line 147, in __init__
    self.quad_xdot[dyn_model_idx] = cs.Function('x_dot', [self.x, self.u], [dyn], ['x', 'u'], ['x_dot'])
  File "/workspaces/neural_mpc/dd_mpc_venv/lib/python3.8/site-packages/casadi/casadi.py", line 23607, in __init__
    this = _casadi.new_Function(*args)
RuntimeError: Error in Function::Function for 'x_dot' [MXFunction] at .../casadi/core/function.cpp:249:
.../casadi/core/function_internal.cpp:145: Error calling MXFunction::init for 'x_dot':
.../casadi/core/mx_function.cpp:406: x_dot::init: Initialization failed since variables [gp_p, gp_a, gp_v, gp_r, trigger, f_a, df_a, a] are free. These symbols occur in the output expressions but you forgot to declare these as inputs. Set option 'allow_free' to allow free variables.

Could somebody point me out how to fix it?

srichste commented 1 year ago

Hi there,

I came across this issue as well. I had originally Casadi 3.6.3 installed. However, the versions of Casadi from 3.6.2 do not support free-floating variables in the optimization problem. I tried two options which both worked in my case:

alexbuyval commented 1 year ago

@srichste Yes, it solved the issue! Thank you so much!