SOLVED! (See Edit)
I am trying to initialize an couple of arrays that are private members of a class. I am trying to use a public function to initialize these private arrays. My code looks like this:
void AP_PitchController::initGains(void){
_fvelArray[] = {20, 25, 30, 60, 90, 130, 160, 190, 220, 250, 280};
_kpgArray[] = {6.0, 6.0, 8.0, 4.0, 3.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5};
_kdgArray[] = {2000, 2000, 1900, 300, 300, 200, 200, 200, 200, 200, 200};
_kigArray[] = {0.1, 0.1, 0.2, 0.25, 0.3, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
}
These arrays are found in the header file AP_PitchController where they are declared private. When I try to compile the code, I get one of these messages for each initialization:
/../AP_PitchController.cpp:106: error: expected primary-expression before ']' token /../AP_PitchController.cpp:106: error: expected primary-expression before '{' token /../AP_PitchController.cpp:106: error: expected `;' before '{' token
And here are my private declarations:
Private:
uint8_t _fvelArray[];
float _kpgArray[];
float _kdgArray[];
float _kigArray[];
Does anyone know what I am doing wrong to initialize these arrays upon the call of initGains()?
EDIT:
I found the answer in one of the related questions.
All i need to do is provide an array size for the initialization:
static float _kpgArray[11];
And then initialize it outside of a function in the .cpp file:
uint8_t AP_PitchController::_fvelArray[11] = {20, 25, 30, 60, 90, 130, 160, 190, 220, 250, 280};
Thank you for your input!