# How to change the dynamic model in the code?

**URL:** <https://discuss.px4.io/t/how-to-change-the-dynamic-model-in-the-code/25675>\
**Category:** PX4 Autopilot\
**Created:** [January 5, 2022, 12:21pm UTC](https://discuss.px4.io/t/how-to-change-the-dynamic-model-in-the-code/25675 "2022-01-05T12:21:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![baozhe](https://discuss.px4.io/letter_avatar_proxy/v4/letter/b/87869e/32.png) [@baozhe](https://discuss.px4.io/u/baozhe)\
**Post date:** [January 5, 2022, 12:21pm UTC](https://discuss.px4.io/t/how-to-change-the-dynamic-model-in-the-code/25675/1 "2022-01-05T12:21:59Z")

</div>

Hello everyone. I’m new to this community and have just started learning px4. Recently, I am trying to implement a control method from a paper [Neural Lander](https://arxiv.org/abs/1811.08027). I have a DJI F450 drone with a pixhawk board on it. The development environment is also ready to use.

From a very high level, the ideal dynamics for a drone is M_a = M_g + thrust. I want to edit this equation by adding a new term about the disturbance force. My question is that which parts of the code should I examine and edit? Has anyone done this before? I would be really appreciated it if you guys could give me some hints. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![sharvit](https://discuss.px4.io/user_avatar/discuss.px4.io/sharvit/32/10458_2.png) [@sharvit](https://discuss.px4.io/u/sharvit)\
**Post date:** [February 8, 2022, 1:07am UTC](https://discuss.px4.io/t/how-to-change-the-dynamic-model-in-the-code/25675/2 "2022-02-08T01:07:47Z")

</div>

Hello. What you are trying to implement is very interesting!

These links helped me dive through the PX4 control-codebase:

1. [Controller Diagrams | PX4 User Guide](http://docs.px4.io/master/en/flight_stack/controller_diagrams.html)
2. [PX4 Architectural Overview | PX4 User Guide](http://docs.px4.io/master/en/concept/architecture.html)

Check out [PX4-Autopilot](https://github.com/PX4/PX4-Autopilot/tree/master/src/modules).  
For Quadcopters, the only relevant files are [mc\_pos\_control](https://github.com/PX4/PX4-Autopilot/tree/master/src/modules/mc_pos_control) and [mc\_att\_control](https://github.com/PX4/PX4-Autopilot/tree/master/src/modules/mc_att_control)

Not sure a dynamics model is explicitly coded in the codebase though (because my naive understanding is that you would do that in the simulation…)  
However, there is a thrust-vector update [here](https://github.com/PX4/PX4-Autopilot/blob/master/src/modules/mc_pos_control/PositionControl/PositionControl.cpp) around Line-73 that might probably help.

I am in the process of attempting to document the PX4 control architecture (code-focused) for my grad research and hopefully for the community in general. Any feedback is welcome 🙂
