Adding a GGROUP

Hello.

I am trying to implement a new control design using the AC_PID.cpp.
But while trying to enter the new parameters for the new pid object in parameters.h and parameters.cpp (Using this documentation: Adding a New Parameter to Copter — Dev documentation), I encounter this error from the compiler.

ArduSub/Parameters.h: In constructor ‘Parameters::Parameters()’:
ArduSub/Parameters.h:649:30: error: ‘NEW_P’ was not declared in this scope
new_pid(NEW_P,NEW_I,NEW_D,NEW_IMAX,NEW_FILT_HZ,NEW_DT)

The initializer new_pid is called below the legacy P controller.
The parameter k_param_new_pid was added and AC_PID new_PID; is declared in Parameters.h

The GGROUP(new_pid,“NEW_”,AC_PID) is also added in Parameters.cpp.

NOTE: When the initializer is removed and I try to compile, I receive this error:

/opt/workspace/ArduSub/Parameters.h: In constructor ‘Parameters::Parameters()’:
/opt/workspace/ArduSub/Parameters.h:647:127: error: no matching function for call to ‘AC_PID::AC_PID()’
pid_accel_z(ACCEL_Z_P, ACCEL_Z_I, ACCEL_Z_D, ACCEL_Z_IMAX, ACCEL_Z_FILT_HZ, MAIN_LOOP_SECONDS).

Adding a GSCALAR parameter doesn’t cause any problem though.

Thank

Thanks.

Do you know how to use git? if you can commit your changes, and push them to github, then I can take a look at your code and find out what is missing better.

Your first error is because you never declared NEW_P. The compiler doesn’t know what NEW_P is, it should be a number but what number? You can change the NEW_P, NEW_I… to numbers you want your default gains to be instead.

Note the case needs to match between these two (both need to be new_pid):
k_param_new_pid
AC_PID new_PID

Thank you, I fixed the issue. The parameters were wrongly declared into the config.h and the compiler couldn’t recognize them. I thought that only declare to initialize each parameter to 0 would work

#ifndef NEW_
#define NEW_ 0
#endif

Doing

#ifndef NEW_P
#define NEW_P 0
#define NEW_I 0
#define NEW_D 0

#endif

did work.