Mismatching dimension for field "x" with dimension (np.int32(3), np.int32(0)) (you have (2, 0))

Hi :wave:

Hi guys, I have a question regarding the calculation of next states in MPC simulation model. For instance, I have two states variables (y, yaw) defined by MX and 1 control (kappa) input in internal model and get the prediction states which contains these two(y, yaw). And then I passed them to the simulation model to get the update of them. But the simulation model I set contains 3 states (x, y, yaw) and 2 control inputs (delta, acc). When I’m gonna call the function below to calculate the next states.
The error turns out:

raise Exception(f'AcadosSimSolver.set(): mismatching dimension' \
Exception: AcadosSimSolver.set(): mismatching dimension for field "x" with dimension (np.int32(3), np.int32(0)) (you have (2, 0)).
def sim_x_next_compute(x, u, sim_x_next_integrator):
    # Set initial state
    sim_x_next_integrator.set("x", x)
    sim_x_next_integrator.set("u", u)
    # Solve the simulation
    status = sim_x_next_integrator.solve()
    if status != 0:
        raise Exception('acados returned status {}. Exiting.'.format(status))
    # Get the solution
    x_next_sim = sim_x_next_integrator.get('x')

    return x_next_sim

Should I always keep the same dimensions for both models? Only that could I be able to continue the simulation?

Best regards
zikhuan

Hi :wave:

in a standard setting, the simulator and the model used by the controller would be the same. Compare e.g. the minimal closed-loop example.

Why do you need different models for the simulator and the controller?

Best, Katrin

Hi Katrin,

thanks for your reply! I would like to try more complex simulation model since the prediction model only focuses on the y direction and yaw, which means it aims to minimize the lateral deviation. So you mean the two models are basically the same, especially the states?

Best

Have the two models the same control inputs?

Nope, dimension is also different. I would like to simulate in different ways. Like adding x direction states, and trying another different control inputs. Do you think it makes sense? Or at least the control inputs should be consistent.

It’s of course possible to have an integrator which uses a different model with potentially more states and controls. But then you need a way to come up with the extra controls which are not provided by the solver.

1 Like