How to add a Vector3 parameter

Sorry, if this is a very elementary problem. But I haven't able to solve it for 3 straight coding days. :(

I'm developing a different type of quatrotor controller with ArduCopter V3.3-dev according to some papers. And for those controller, I need some additional parameters, some of them (e,g. inertia) are in vector form.

I've read about the article on how to add a parameters but still unable to pass the compiler:

http://dev.ardupilot.com/wiki/apmcopter-code-overview/code-overview-adding-a-new-parameter/#adding_a_parameter_to_the_main_code

Here is what I've done(for one of the parameter):

  • add parameter number k_param_ew_inertia @ Parameters.h
  • add variable declaration AP_Vector3f inertia below @ Parameters.h  (AP_Vector3 won't work as stated in the guiding page)
  • trying to get it work in Parameters.pde like:

    // @Param: EW_IXX
    // @DisplayName: Ewing inertia Ixx
    // @Description: inertia Ixx
    // @Range: 0 1000
    // @User: Advanced

    // @Param: EW_IYY
    // @DisplayName: Ewing inertia Iyy
    // @Description: inertia Iyy
    // @Range: 0 1000
    // @User: Advanced

    // @Param: EW_IZZ
    // @DisplayName: Ewing inertia Izz
    // @Description: inertia Izz
    // @Range: 0 1000
    // @User: Advanced
    GSCALAR(inertia,  "INERTIA", INERTIA_V3),

  • with defines in APM_Config.h as follows (Althought the guiding page told me to place in config.h, but config.h told me to do that in APM_Config.h)

#define IXX_DEFAULT             0.002f
#define IYY_DEFAULT             0.002f
#define IZZ_DEFAULT             0.004f
#define INERTIA_V3         Vector3f(IXX_DEFAULT,  IYY_DEFAULT,   IZZ_DEFAULT)

  • the compiler gives the error:

connot convert 'Vector3f {aka Vector3<float>}' to 'const float' in initialization

I do understand since I use the G-SCALAR it should be scalar, right? Then how should I do this right?

I've tried to initialize the AP_Vectors3 in initializers of Parameters.h like:

inertia(IXX_DEFAULT, IYY_DEFAULT, IZZ_DEFAULT),

Then compiler would give:

error: no matching function for call to 'AP_ParamV<Vector3<float>, ( ap_var_type)5u>::AP_ParamV(float, float, float)'

And call that in the constructor won't work either.

So who do I do a Vector3 parameter exactly? Is there anything I've missed or misunderstand?

The parameter part of the code is a little difficult for me and I'm not quite understand it. Again, I appreciate anyone who read this and any advice is wellcome!

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Activity