[Fail log] Creating custom mavlink message for px4 firmware

This is my failure log for creating custom mavlink message in px4

I was trying to create a module “z_estimator” dedicated for estimating earth fixed height estimator for accurate altitude hold control.
To do so, I need to create a custom mavlink message for data transmission between modules such as mc_pos_control.
So I type edited common.xml under /px4/mavlink/include/mavlink/v2.0/message_definitions/ with followings

<message id="240" name="Z_ESTIMATE">
  <field type="uint64_t" name="time_usec" units="us">Timestamp</field>
  <field type="float" name="z">Estimated z in earth NED</field>
  <field type="float" name="vz">Estimated vz in earth NED</field>
  <field type="float" name="ref_alt">Reference altitude in earth NED</field>
  <field type="float" name="dist_bottom">Distance from bottom</field>
</message>

Then I git cloned mavlink generator from https://github.com/mavlink/mavlink.git
and copied the common.xml to the generator folder.

Run mavlink generator by entering $ python mavgenerate.py
and picked as follows

Copied newly generated *.h files under /output/common to /px4/mavlink/include/mavlink/v2.0/common folder and *.h files under /output to /px4/mavlink/include/mavlink/v2.0/ folder

in px4 firmware I did
$ make clean
$ make px4fmu-v2_default
and got following errors
…/…/mavlink/include/mavlink/v2.0/standard/standard.h:59:0: error: “MAVLINK_MESSAGE_INFO” redefined [-Werror]
So I commented out above relate file and rebuild.
Then I uploaded fw to the board however QGC cannot detect the board anymore.
I am still investigating in which part did I miss something during the process.

Getting this in a bit late for you but for for posterity’s sake I just ran into the same problem and found a fix.

When you append custom messages into the common dialect header file you have to rebuild the standard header, with the mavgenerate tool, as it the standard dialect is built using the common enums and messages.