How to add a parameter to quadplane code? - (repost in a more obvious spot)

I’m currently hacking away at the Quadplane code to make it do a bi-copter with independently tilting wing and rotors and I would like to add an extra parameter to specify the tilt limits for pitch control in the same way that is done for vectored yaw.

The parameter setup in Quadplane looks quite different to that described in the Copter add parameter notes which I’ve read up on but I’m having some difficulties getting functional code to compile when I add a parameter in quadplane.cpp (in the second group) The code will actually compile but it won’t run and connect to X-plane, so it’s probably getting hung up somewhere because of this additional parameter.

Could some kind soul point out the relevant Quadplane equivalents of the four-step Copter process?

(currently I’m working in SITL but will migrate to the real world when something works)

Hi there Andrew, are you looking to add a parameter below this one?

   // @Param: TRANS_DECEL
    // @DisplayName: Transition deceleration
    // @Description: This is deceleration rate that will be used in calculating the stopping distance when transitioning from fixed wing flight to multicopter flight.
    // @Units: m/s/s
    // @Increment: 0.1
    // @Range: 0.2 5
    // @User: Standard
    AP_GROUPINFO("TRANS_DECEL", 1, QuadPlane, transition_decel, 2.0),

It seems like just adding a line like:

AP_GROUPINFO("<your_param_name", 2, QuadPlane, <your_variable_name>, <initial_value>),

just below that, but above AP_GROUPEND should do the trick. Could you paste a code snippet of how you tried to add the param here if you’re still stuck?

1 Like

Probably best to ping @tridge with this one - he has the deepest knowledge (sorry mate - I know you’re busy).

That’s pretty much what I have done, Sriram. I’ll dig the actual code up and post when I get back to my laptop

The code compiles but doesn’t initalize X-plane

When I cut this addition out (A-B-A testing style) I get my comms with X-plane back again, so it’s definitely something with what I’m adding here.

This is the code changes I’m adding:

// second table of user settable parameters for quadplanes, this
// allows us to go beyond the 64 parameter limit
const AP_Param::GroupInfo QuadPlane::var_info2[] = {
// @Param: TRANS_DECEL
// @DisplayName: Transition deceleration
// @Description: This is deceleration rate that will be used in calculating the stopping distance when transitioning from fixed wing flight to multicopter flight.
// @Units: m/s/s
// @Increment: 0.1
// @Range: 0.2 5
// @User: Standard
AP_GROUPINFO(“TRANS_DECEL”, 1, QuadPlane, transition_decel, 2.0),

// @DisplayName: Tilt pitch control angle semi-limit
// @Description: This is the (half) angle of the wing tilt to be used for pitch control when in VTOL mode. 
// @Range: 0 15
AP_GROUPINFO("TILT_PITCH_ANGLE", 2, QuadPlane, tilt.tilt_pitch_angle, 0),



(Arggh! I don’t know why it’s formatted like that!)

What type is your tilt_pitch_angle variable? That’s the only thing I can imagine right now, hmm…

I’ve defined it in quadplane.h as a float. Duplicating as far as possible the code for tilt.tilt_yaw_angle in an attempt to make it work.

Do you mean AP_Float? Just to be sure.

Sorry, I’m being a bit loose with my terms!

    AP_Int8  max_angle_deg;
    AP_Int8  tilt_type;
    AP_Float tilt_yaw_angle;
    AP_Float tilt_pitch_angle;
    float current_tilt;
    float pitch_tilt;

is what I’ve got in quadplane.h

Interestingly, I swapped the positions in the definition section of code for TILT_PITCH_ANGLE and TILT_YAW_ANGLE and, with or without the extra parameter in the second group (YAW this time) it won’t communicate, despite compiling without error. so clearly something is wrong with my implementation of tilt.tilt_pitch_angle. Hmmm…

Is this a problem with communication with X-Plane alone? Or does the basic SITL instance itself not even run - can you connect to it with Mission Planner for e.g.?

It fires up and allows MAVproxy to run but sits there “waiting for a heartbeat” because SITL is waiting to hear from X-plane and X-plane is waiting to hear from SITL to set the correct data parameters in X-plane. In any case, if I delete this parameter, all is well - no other changes.

Hi Andrew, I might have found your problem.

I get this error when I run my SITL file manually:

check_group_info:194: suffix is too long in TILT_PITCH_ANGLE
Bad parameter table

I’ve found out that you can just change your parameter name from TILT_PITCH_ANGLE to TILT_PITCH_ANG and the problem disappears :slight_smile: - looks like your parameter name was just a bit too long.

1 Like

Thanks Sriram! I think that’s done it!

The 16-character limit must also include the Q_ prefix, which seems pretty obvious in retrospect.

No problem :slight_smile:

@Andrew_Rabbitt If you run with -D and -G switches, you’ll get a gdb terminal window which should tell you about errors such as parameter names that are too long.

Thanks for the tips and all the help! I’ll give that a try, Mark. You can tell I’m a code novice with huge ambition and no clue! Your patience and guidance is seriously appreciated