# Testing new controllers PX4 autopilot

**URL:** <https://discuss.px4.io/t/testing-new-controllers-px4-autopilot/21920>\
**Category:** Pixhawk\
**Created:** [April 13, 2021, 8:26pm UTC](https://discuss.px4.io/t/testing-new-controllers-px4-autopilot/21920 "2021-04-13T20:26:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ranjeet](https://discuss.px4.io/user_avatar/discuss.px4.io/ranjeet/32/6514_2.png) [@Ranjeet](https://discuss.px4.io/u/Ranjeet)\
**Post date:** [April 13, 2021, 8:26pm UTC](https://discuss.px4.io/t/testing-new-controllers-px4-autopilot/21920/1 "2021-04-13T20:26:25Z")

</div>

Hello @bresch ,  
I am working to implement different controllers other than PID and want to test on PX4 autopilot in SITL.

Can you please guide me where do i need to make changes in the firmware stack to test a new controller?  
thanks

---

<div class="post-metadata">

**Author:** ![benasena](https://discuss.px4.io/user_avatar/discuss.px4.io/benasena/32/4666_2.png) [@benasena](https://discuss.px4.io/u/benasena)\
**Post date:** [April 16, 2021, 12:50am UTC](https://discuss.px4.io/t/testing-new-controllers-px4-autopilot/21920/2 "2021-04-16T00:50:58Z")

</div>

Hi @Ranjeet. This might be a good place to start looking:

> <https://github.com/PX4/PX4-Autopilot/blob/master/src/modules/mc_rate_control/RateControl/RateControl.cpp>

---

<div class="post-metadata">

**Author:** ![Ranjeet](https://discuss.px4.io/user_avatar/discuss.px4.io/ranjeet/32/6514_2.png) [@Ranjeet](https://discuss.px4.io/u/Ranjeet)\
**Post date:** [April 16, 2021, 5:56am UTC](https://discuss.px4.io/t/testing-new-controllers-px4-autopilot/21920/3 "2021-04-16T05:56:27Z")

</div>

Hi @benasena @bresch , I have gone through the current PID controller that works at 4 levels (attitude rate, attitude, velocity and position). And, I can see that **mc\_att\_control, mc\_pos\_control and mc\_rate\_control** are modules that deal with controller implemented.

Like, Suppose I just want to implement a position controller (say sliding mode controller), then many parameters (PID gains) will not be required and few parameters has to be added.  
I was thinking of testing different controllers in PX4\_sitl. I am aware that i need to write a module for another controller but what communications are going on among other modules and the present controller, if there is some picture, then that would be great.

---

<div class="post-metadata">

**Author:** ![Zhengtian\_Ma](https://discuss.px4.io/user_avatar/discuss.px4.io/zhengtian_ma/32/8659_2.png) [@Zhengtian\_Ma](https://discuss.px4.io/u/Zhengtian_Ma)\
**Post date:** [April 19, 2021, 6:20am UTC](https://discuss.px4.io/t/testing-new-controllers-px4-autopilot/21920/4 "2021-04-19T06:20:41Z")

</div>

You can probably take a look at this uorb graph to get an idea of message passing between the modules. Do note that some of the topic names maybe changed for the most-updated version.  
[https://dev.px4.io/v1.10\_noredirect/en/middleware/uorb\_graph.html](https://dev.px4.io/v1.10_noredirect/en/middleware/uorb_graph.html)

---

<div class="post-metadata">

**Author:** ![Jaroan](https://discuss.px4.io/user_avatar/discuss.px4.io/jaroan/32/6961_2.png) [@Jaroan](https://discuss.px4.io/u/Jaroan)\
**Post date:** [September 11, 2021, 5:28pm UTC](https://discuss.px4.io/t/testing-new-controllers-px4-autopilot/21920/5 "2021-09-11T17:28:20Z")

</div>

Hello @Ranjeet  
According to the [Multicopter Control Architecture](https://docs.px4.io/master/en/flight_stack/controller_diagrams.html#multicopter-control-architecture) the Position and Velocity Controller Diagram are a mix of P (for position) and PID(for velocity).

I was trying to add a PI/PD/PID controller module instead of the P controller for Position?  
I note the following codes ([mc\_pos\_control module](https://github.com/PX4/PX4-Autopilot/tree/58ea97a699ac6f9ae9c5eeb0e22cf5e2385ad8f0/src/modules/mc_pos_control)) have the controllers.  
I wanted to know if there are other places to be modified for the different types of controllers based on your work. Thank you in anticipation!
