Setting custom parameter

Hello, I am working with ArduCopter 4.1, trying to set parameter values in a arducopter.apj file. I can create a custom parameter, no problem, as described here: Adding a New Parameter to Copter — Dev documentation.

When I added the parameter to Parameters.h (snippet below) I incremented the k_param_vehicle to 266 from 265.
.
.
.
k_param_auto_config_enabled,
k_param_blade_hung_up_current,
k_param_my_test_parm,

    k_param_vehicle = 266, // vehicle common block of parameters

    // the k_param_* space is 9-bits in size
    // 511: reserved
};

Then using the apj_tool.py script, I try to initialize this new parameter. BEFORE modifying the .apj file, the scripts shows the following:

python apj_tool.py --show .\arducopter.apj
Loaded apj file of length 1715532
Found param defaults max_length=8192 length=254

setup correct defaults for battery monitoring for cube power brick

BATT2_CURR_PIN 4
BATT2_VOLT_PIN 13
BATT_AMP_PERVLT 39.877
BATT_VOLT_MULT 12.02
BATT2_AMP_PERVLT 39.877
BATT2_VOLT_MULT 12.02

setup ADSB

ADSB_TYPE 1
SERIAL5_BAUD 57
SERIAL5_PROTOCOL 1

I created a .parm file that contains settings for 1 parameter shown below:

Default parameter file for vehicleX

MY_TEST_PARM 30567 @READONLY # users will not be able to modify this parameter

I run the configure process:

python apj_tool.py --set-file newParms.parm .\arducopter.apj
Loaded apj file of length 1715532
Found param defaults max_length=8192 length=254
Setting defaults from newParms.parm
Saved apj of length 1715532

Then show it again:

python apj_tool.py --show .\arducopter.apj
Loaded apj file of length 1715532
Found param defaults max_length=8192 length=118

Notice: 1) The length is now 118 and was 254!
2) None of the original original parameters appear in the second show command.

Also, the new parameter does not get set to the value in the .parm file, and it is not READ ONLY.

Can someone provide some guidance on this?

Thank you.

I am not familiar with APJ Tools… so I can’t help you so much… But, I think you have a misconcept here:

The informations beginning with ‘@’ are just a guideline for an output file that can be provided to GCS in order to display information inside the parameters visualization. It will not make your parameter read only. You have to change the way your parameter is created inside code… take a look on the AP_Stats library for instance and see how these parameters beginning with STAT_ are initialized, they are truly read-only, you can in someway copy this implementation.

1 Like