# Implementing my own control loops in the source code

**URL:** <https://discuss.px4.io/t/implementing-my-own-control-loops-in-the-source-code/39401>\
**Category:** PX4 Autopilot\
**Created:** [June 24, 2024, 6:28pm UTC](https://discuss.px4.io/t/implementing-my-own-control-loops-in-the-source-code/39401 "2024-06-24T18:28:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grueling2504](https://discuss.px4.io/letter_avatar_proxy/v4/letter/g/3ab097/32.png) [@Grueling2504](https://discuss.px4.io/u/Grueling2504)\
**Post date:** [June 24, 2024, 6:28pm UTC](https://discuss.px4.io/t/implementing-my-own-control-loops-in-the-source-code/39401/1 "2024-06-24T18:28:16Z")

</div>

Hello,  
I am in the process of implementing a custom flight mode to the PX4 firmware as part of my master’s thesis. In short, I will be creating a flight mode called ‘Position 2’ that will use my own control loops for velocity and attitude control and use PX4’s position and rate controllers for the quadcopter.  
I already tried UAV Toolbox for Simulink and successfully flew SITL with my autopilot; however, that approach gets rid of pre-flight checks, sensor calibration and safety features, which will be essential when I upload the code to the real drone.  
I am having difficulty adding another flight mode to the source code as [existing tutorials](https://uav-lab.org/2017/03/15/px4-research-log-11-adding-a-new-flight-mode-create-application/) are outdated. Has anybody succeeded on doing that and by change can share any resources that I may have missed?

Thanks.

---

<div class="post-metadata">

**Author:** ![dotanAtTrim](https://discuss.px4.io/user_avatar/discuss.px4.io/dotanattrim/32/14833_2.png) [@dotanAtTrim](https://discuss.px4.io/u/dotanAtTrim)\
**Post date:** [June 27, 2024, 6:41am UTC](https://discuss.px4.io/t/implementing-my-own-control-loops-in-the-source-code/39401/2 "2024-06-27T06:41:32Z")

</div>

Try sharing your code, maybe someone from the development team will have a look.  
I’m also interested in looking at it but I’m not part of said team so I can’t really add something of value.
