# Flight control for tiltrotor

**URL:** <https://discuss.px4.io/t/flight-control-for-tiltrotor/15870>\
**Category:** PX4 Autopilot\
**Created:** [March 25, 2020, 11:22am UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870 "2020-03-25T11:22:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gkashyap](https://discuss.px4.io/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@gkashyap](https://discuss.px4.io/u/gkashyap)\
**Post date:** [March 25, 2020, 11:22am UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/1 "2020-03-25T11:22:04Z")

</div>

![Airframe](https://discuss.px4.io/uploads/default/original/2X/6/63d0c02837903a4568064af2b17d30bc07f4310e.png)  
I have this new airframe and the following controls  
Main outputs: 8 VTOL motors  
Aux outputs:  
1 elevator  
2 aileron  
1 rudder  
1 aux for 4 tilt motors

Because the motors will tilt the leading edge rotors, I’m wondering how to modify pixhawk software flight control so that it is aware of tilt motors and takes care of transition from VTOL to cruise and back.  
On my RC, I have one toggle switch to signal transition. What I’m struggling with is how to correctly modify pixhawk flight control software?  
I’m using pixhaw 2.4.8.  
Any help on flight control is appreciated.  
@LorenzMeier @bresch Could you please share your expert opinion?

Thanks for all your help.

---

<div class="post-metadata">

**Author:** ![gkashyap](https://discuss.px4.io/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@gkashyap](https://discuss.px4.io/u/gkashyap)\
**Post date:** [March 25, 2020, 11:56am UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/2 "2020-03-25T11:56:28Z")

</div>

Let me share the way, I think I will implement it. Please correct me if I’m wrong.

When the transition switch is toggled, the aircraft starts to transition from MC to fixed wing flight. I know the airspeed at which the tilt motor should be powered to tilt the leading edge rotors for forward flight. Using an airspeed data, software can send a command to tilt motors and switch of trailing edge rotors off. This can happen for both VTOL transitions  
mode::TRANSITION\_TO\_FW and mode::TRANSITION\_TO\_MC in the VtolAttitudeControl::Run() method.

My doubt is about the mixer generated based on geometry because it is generated for one position of rotors when they are vertical. How will the thrust components be resolved and handled during forward and reverse transition? What I’d like to see is a smooth transition without pitch up or down during transitions.  
Please help!  
Thanks,  
Kashyap

---

<div class="post-metadata">

**Author:** ![bresch](https://discuss.px4.io/user_avatar/discuss.px4.io/bresch/32/2343_2.png) [@bresch](https://discuss.px4.io/u/bresch)\
**Post date:** [March 25, 2020, 4:26pm UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/3 "2020-03-25T16:26:32Z")

</div>

Hi, @gkashyap I think your airframe isn’t really different from a standard tiltrotor (such as the Convergence). Isn’t it working using the usual tiltrotor airframe config + mapping the outputs properly?

Just in case, @sfuhrer is more up-to-date with the current tiltrotor code.

---

<div class="post-metadata">

**Author:** ![sfuhrer](https://discuss.px4.io/user_avatar/discuss.px4.io/sfuhrer/32/3931_2.png) [@sfuhrer](https://discuss.px4.io/u/sfuhrer)\
**Post date:** [March 25, 2020, 5:16pm UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/4 "2020-03-25T17:16:32Z")

</div>

Hi @gkashyap, as @bresch mentions your setup doesn’t strongly differ from other tiltrotor systems that are officially supported by PX4 - like the Convergence. The mixing problem you mention (roll/yaw coupling) is absolutely correct - though normally it doesn’t prevent the vehicle from doing stable transitions.

- Front-transitions: Due to the nature of tiltrotors, you have a lot of possible forward thrust that accelerates the vehicle quite fast to an airspeed region that starts providing aerodynamic stability, such that actually little control actuation is needed to keep it stable (make sure that your vehicle is aerodynamically well designed)
- Back-transitions: motors are immediately tilted upwards, without tilt - thus no problem here.

While the static mixer doesn’t really prevent stable transitions on most vehicles, we still are currently working on adapting the control pipeline to replace the mixers with a dynamic control allocation. Any contributions/flights testing there would be highly appreciated! [https://github.com/PX4/Firmware/pull/13351](https://github.com/PX4/Firmware/pull/13351). With that in, we could also e.g. support a hybrid flight mode where the user can fly the vehicle with any motor tilt.

---

<div class="post-metadata">

**Author:** ![gkashyap](https://discuss.px4.io/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@gkashyap](https://discuss.px4.io/u/gkashyap)\
**Post date:** [March 26, 2020, 6:09am UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/5 "2020-03-26T06:09:19Z")

</div>

Thanks for pitching in @bresch @sfuhrer. I agree with you. I was a concerned because I didn’t want to lose my aircraft again.  
I did some digging into the code last night and I saw that there is a Tiltrotor class. I’ll start my work from there and adapt the code to my needs.  
Sure, I’ll be happy to contribute to the control allocation development. Let me first go through and analyze the code and will start when I develop a good understanding.  
Thanks for your time. 😃

Kind regards,  
Kashyap

---

<div class="post-metadata">

**Author:** ![tugbakara](https://discuss.px4.io/user_avatar/discuss.px4.io/tugbakara/32/9581_2.png) [@tugbakara](https://discuss.px4.io/u/tugbakara)\
**Post date:** [November 29, 2021, 1:07pm UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/6 "2021-11-29T13:07:14Z")

</div>

Hi Kashyap, I want to change airframe wrt my airframe , I don’t want to reinvent the wheel but I don’t know where and which folders or files can be changable , I know your post is old but I don’t find anything about changing existing airframe with clear explanation maybe they were easiy but I am beginner of beginner. 😑

---

<div class="post-metadata">

**Author:** ![gkashyap](https://discuss.px4.io/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@gkashyap](https://discuss.px4.io/u/gkashyap)\
**Post date:** [December 10, 2021, 12:59pm UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/7 "2021-12-10T12:59:34Z")

</div>

Hi Tugbakara,  
Sorry for the late response. I’m not active on the forum these days.  
If the directory structure has changed slightly, you should still be able to find these files and make changes. It is not described anywhere and I understand your frustration. It took a bit of digging and detective work to determine everything.

Here are the steps, I’ve used ‘\_tr’ suffix to differentiate the new file.

Add a new config file as defined here: [Adding a New Airframe · PX4 Developer Guide](https://dev.px4.io/v1.9.0/en/airframes/adding_a_new_frame.html)  
It is best to start by reusing and modifying a config file which most closely resembles the aircraft that we have. In this case it was “13010\_claire”.  
a. The first airframe file is defined to be 13020\_tr and is added to src/Firmware/ROMFS/px4fmu\_common/init.d/airframes.  
b. Update the CMakeLists.txt in /src/Firmware/ROMFS/px4fmu\_common/init.d/airframes to include 13020\_tr in the build.  
c. Define the mixers: main and aux files here: /src/Firmware/ROMFS/px4fmu\_common/mixers (tr.main.mix and tr.aux.mix).  
d. Update the CMakeLists.txt in /src/Firmware/ROMFS/px4fmu\_common/mixers where the mixers were defined.  
e. For SITL configuration define the mixer in /src/Firmware/ROMFS/px4fmu\_common/mixers-sitl and update the CMakeList.txt file.  
f. Update the toml file in /src/Firmware/src/lib/mixer/MultirotorMixer/geometries. This file is tr.toml.  
g. Update the CMakeLists.txt in /src/Firmware/src/lib/mixer/MultirotorMixer for the new toml file added for mixer.  
h. In the file “Firmware/src/modules/simulator/simulator\_mavlink.cpp” modify the case statement “case MAV\_TYPE\_VTOL\_TILTROTOR” to update “n = 8” for 8 motors. Adjust as per your case.  
i. Run the “make airframe\_metadata” command from /src/Firmware to build the metadata used by QGroundControl for new airframe.  
j. Build px4.  
k. Build  
j. Launch QGroundControl and connect with pixhawk board to check that new airframe is displayed in the group to which airframe was added. The airframe can be seen only after flashing the firmware. It should appear in VTOL tiltrotors group.

Thanks,  
Kashyap

---

<div class="post-metadata">

**Author:** ![gkashyap](https://discuss.px4.io/letter_avatar_proxy/v4/letter/g/ce73a5/32.png) [@gkashyap](https://discuss.px4.io/u/gkashyap)\
**Post date:** [December 10, 2021, 1:06pm UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/8 "2021-12-10T13:06:11Z")

</div>

In addition you have the following examples:

> <https://github.com/PX4/PX4-Autopilot/blob/master/ROMFS/px4fmu_common/init.d/airframes/13012_convergence>

> <https://github.com/PX4/PX4-Autopilot/blob/master/ROMFS/px4fmu_common/init.d/airframes/13030_generic_vtol_quad_tiltrotor>

---

<div class="post-metadata">

**Author:** ![tugbakara](https://discuss.px4.io/user_avatar/discuss.px4.io/tugbakara/32/9581_2.png) [@tugbakara](https://discuss.px4.io/u/tugbakara)\
**Post date:** [January 7, 2022, 10:56am UTC](https://discuss.px4.io/t/flight-control-for-tiltrotor/15870/9 "2022-01-07T10:56:32Z")

</div>

Hi gkashyap, thanks for reply Ichanged this airframe a little and I added its aux.mix file into sd card of the fc with the same name on ~/PX4-Autopilot/ROMFS/px4fmu\_common/mixers ,and then I replug the sd and I opened QGC but nothing happened, I don’t know when I changed existing airframe aux file something has to happen or shown me in QGC?  
And this is the changes in my aux file because I just want to eliminate 2 tilt servos which are in the back for two motors, and the elevator and rudder I wan to make them as one for vtail. Here is my changes what I made, but I don’t get it it’s working or not:  
I summirize the steps as mentioned in [doc forum](https://docs.px4.io/master/en/concept/mixing.html#mixer-loading):

1. I create etc/mixers folder in SD card of fc.

2. In the mixer folder I create which its name is vtol\_TTTTAAER.aux.mix ( same as in folder ~/PX4-Autopilot/ROMFS/px4fmu\_common/mixers.

3. That’s is the changes that I made:

```auto
# Generic quadplane tiltrotor servo mixer

# @board px4_fmu-v2 exclude

# Tilt mechanism servo mixer
---------------------------
# front left up:2000 down:1000
M: 1
S: 1 4 0 -20000 10000 -10000 10000

# front right up:1000 down:2000
M: 1
S: 1 4 0 20000 -10000 -10000 10000

Z:

Z:

# Aileron mixer
# ---------------------------------
M: 1
S: 1 0 10000 10000 0 -10000 10000

M: 1
S: 1 0 10000 10000 0 -10000 10000

# Vtail mixer
#-------------
M: 1
S: 1 1 10000 10000 0 -10000 10000
S: 1 2 -10000 -10000 0 -10000 10000

M: 1
S: 1 1 10000 10000 0 -10000 10000
S: 1 2 10000 10000 0 -10000 10000

```

Then I added in sd card /etc/mixers folder config.txt as:

```auto
set MIXER_AUX vtol_TTTTAAER
set PWM_AUX_OUT 1234
set PWM_AUX_DISARMED 1500
set PWM_AUX_MIN 1000
set PWM_AUX_MAX 2000
set PWM_AUX_RATE 50

```

I repluged my SD card to my fc , then I open it in QGC nothing happened.
