TinyMPC / tinympc-matlab

MATLAB interactive interface for TinyMPC
https://tinympc.org
11 stars 5 forks source link

The function "TinyMPC.get_u()" only get the first row of u #1

Open Ukua opened 9 months ago

Ukua commented 9 months ago

class TinyMPC:

function u = get_u(obj, verbose_int)
            coder.extrinsic('libpointer','calllib');

            u_soln = zeros(1, obj.N - 1,'single');
            u_soln_ptr = libpointer('singlePtr', u_soln);
            calllib(obj.lib_name, 'get_u', u_soln_ptr, int32(verbose_int));
            u = get(u_soln_ptr, 'Value');
        end

If output dim >1,the function "get_u" always get a 1dim matrix and Matlab will crush. Changeu_soln = zeros(1, obj.N - 1,'single'); to u_soln = zeros(obj.m, obj.N - 1,'single'); can fix.

xkhainguyen commented 8 months ago

@elakhya-nedumaran can you check this issue?