Custom MAV_CMD to trigger a control method switch in PX4

I’m trying to customize a MAV_CMD so that the corresponding VEHICLE_CMD in PX4 directory can control a switch between PID and a self-designed control strategy.

I have followed the guide in MAVLINK and QGC documents and modified XML definition files of MAV_CMD, joystick plugins,, and in QGC src directory. But whenever I open QGC and press the button assigned to the new MAV CMD, QGC shows an error message with “MAV_CMD command not supported”. Another fact is that when QGC emits this error message, the PX4 code running in SITL does receive the corresponding VEHICLE_CMD and prints a message on the screen.

So it seems that the QGC does not recognize the MAV_CMD even though the PX4 has already got that signal. I guess I have missed some files that need to be modified in QGC directory, but I have no idea what files I should work on. Thanks for any hints or help about how to create a new MAV_CMD and get it into work.

Oh, I solved this problem after several days. It turned out that I forgot to modify the code dealing with command acknowledge message in PX4 directory. In detail, in the files Commander.cpp or other files dealing with VEHICLE_CMDs. You need to assign VEHICLE_CMD_RESULT_ACCEPTED to a variable and send it back using command_ack.