Declaring and using matrices in edumip_balance_ros.cpp

Hy Everyone,

I’m struggling a bit in my school project (Automation Engineering MA1)

Main goal is: implemating a state-space control instead of the PI controllers in the BeagleBone Blue Bot
My simulation of the inverse pendulum is done on Simulink and now I’m trying to start playing with vectors and matrices in the main .cpp
==> I found on the Github the librairies containing all vector / matrices functions as well as the exemple of using them (rc_test_algebra)

I tried several vector or matrix declarations but as I “catkin_make” the projet it crashes: here are my attempts (working in edumip_balance_ros.cpp)

(I give you a bit more of the code so you can figure out where I’am working), main idea here: creating a 2x2 matrix A filled with zeros, error is: expected constructor, destructor, or type conversion before ‘(’ token rc_matrix_zeros(A, 2, 2)

I tried decoupling the code (more lines) or using the rc_matrix_alloc but none of them work :-4

Does anyone have an idea how I could implement a simple matrix or vector using the prefabricated functions in the librairies please ? I’m merely asking for a clue or a good explanation or someone pointing at my bad understanding of C++ and correcting me.

Thank you, Thomas from Brussels

On Mon, 30 Apr 2018 02:58:37 -0700 (PDT),
vandenhove.t.work@gmail.com declaimed the
following:

I tried several vector or matrix declarations but as I "catkin_make" the
projet it crashes: here are my attempts (working in edumip_balance_ros.cpp)

<https://lh3.googleusercontent.com/-3RIZqurWSSc/WubnGWCdQbI/AAAAAAAAAEQ/d6aFbzwC_tcdJorGdCIrwepzudZO6w6dgCLcBGAs/s1600/help1.png&gt;

  Please cut&paste the /text/ in the future -- images are normally
blocked in my client, and stripped out of some newsgroups. Images also make
it difficult for responders to comment on specific lines of code without
somehow retyping the code (and since I can't see the image in the reply
that gets even more difficult)..

  The main thing I see is that you are declaring a POINTER TO "A", but
never allocating memory space for the actual "rc_matrix_t" structure..

  In contrast, the example (which took me a while to find, since you did
not provide a link to it) does NOT declare pointers. It declares an actual
structure, and initializes it with a function call...

  rc_matrix_t A = rc_matrix_empty();

... it later passes the address of the structure to operations

  rc_matrix_random(&A,DIM,DIM);

  You are basically doing the opposite: creating a pointer and passing it
as is. Since the pointer is never initialized, at best you are passing a
NULL, at worst you are passing random memory address.

(I give you a bit more of the code so you can figure out where I'am
working), main idea here: creating a 2x2 matrix A filled with zeros, error
is: *expected constructor, destructor, or type conversion before '(' token
rc_matrix_zeros(A, 2, 2)*

  I'm surprised that a compiler could detect that -- unless
rc_matrix_zeros() (or other) really are major macro expansions that
generate hidden tracking data.