# Custom MAV\_CMD to trigger a control method switch in PX4

**URL:** <https://discuss.px4.io/t/custom-mav-cmd-to-trigger-a-control-method-switch-in-px4/39027>\
**Category:** MAVLink\
**Created:** [June 2, 2024, 6:52am UTC](https://discuss.px4.io/t/custom-mav-cmd-to-trigger-a-control-method-switch-in-px4/39027 "2024-06-02T06:52:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaowenxuan0617](https://discuss.px4.io/user_avatar/discuss.px4.io/gaowenxuan0617/32/16542_2.png) [@gaowenxuan0617](https://discuss.px4.io/u/gaowenxuan0617)\
**Post date:** [June 2, 2024, 6:52am UTC](https://discuss.px4.io/t/custom-mav-cmd-to-trigger-a-control-method-switch-in-px4/39027/1 "2024-06-02T06:52:43Z")

</div>

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, px4firmwareplugins.cc, and vehicle.cc 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.

---

<div class="post-metadata">

**Author:** ![gaowenxuan0617](https://discuss.px4.io/user_avatar/discuss.px4.io/gaowenxuan0617/32/16542_2.png) [@gaowenxuan0617](https://discuss.px4.io/u/gaowenxuan0617)\
**Post date:** [June 2, 2024, 12:06pm UTC](https://discuss.px4.io/t/custom-mav-cmd-to-trigger-a-control-method-switch-in-px4/39027/2 "2024-06-02T12:06:09Z")

</div>

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.
