How to add X and Y control in custom airframe/mixer

Hello all,

I have successfully managed to implement my custom mixer for my Tilt-Quadrotor project. As can be seen here:

The next step is to add X and Y control, which this platform, can achieve without tilting its central core.

Iddeally I would add this to my custom aux mixer (the x and y movements are very simple on a platform/mixer level I just don’t know how to implement this). However there are two issues:

What flight mode/flight group do I use?

and how do I modify this on a RC level, i.e. Ideally I’d use the right joystick (commonly used for Roll/Pitch commands) to instead send X/Yspeed commands, while the Roll/Pitch commands stay at 0º always.

At a first stage the X and Yspeed commands don’t need any feedback from the autopilot. I’m running indoors so no GPS, and the position will be controlled by the pilot manually.

Idk if I got my point/issue accross but any help would be appreciated.



Though I don’t know I understand well your question, it seems be related to ‘offboard’ mode of PX4.

First of all thanks for the help.

However I don’t think your link is what I’m looking for. I think putting MAVLink into the subject is complicating it a bit too much. I’ll put my question in simpler terms. There are 2 main parts.

1 - I have a custom mixer and I want to add the lines for X and Y control. However there is only Roll,Pitch,Yaw and Thrust.

I guess I could “adapt” 4 - flaps and 5 - spoilers (honestly at this point. X is enough so 4 is enough). the mixer scaling is trivial so that is fixed. However question 2

2 - How do I “map” input 4 in QGC and in my RC. Ideally I’d map it with the Roll/Pitch Joystick , but once again in a first iteration maybe I can work with a button. But how do I do this?

To sync thinking each other let’s say more long.

In the video that is a quite special drone. It seems that the position and attitude controllers of PX4 are not used but a special mixer seems to be made for attitude control for this special drone.

So now a position control method, ‘X-Y control’, is needed to it. If the X-Y means the two axes of the quadcopter body it is simple to move toward those axes by just tilting roll and pitch so the position controller is not needed.

But if the X-Y axes means the two axes of fixed world it shoud know current heading direction and compare it to the target direction and then calculate adequate roll and pitch angles. So this is a position controller.

In this position control, the RC sticks command the X-Y velocity of the drone in world coordinates frame as a stick is moved left, right, up and down. For X-Y-Z and heading control, 4 control inputs of RC are used. The 4 inputs may be generated by QGC by making push buttons on the screen by change the code of QGC.

Is it right?

ok maybe I didn’t make myself clear.

So I do not want to use the Position controller. I want to do X and Y control manually, i.e. the pilot will send inputs with the joysticks which will be mapped directly to the outputs via the mixer (which I already have).

The issue is that, like you said, it’s a special drone so it is possible to move in the X and Y (body-fixed frame) without the need to roll and pitch (like it is doing in the video). It achieves that by tilting 2 servo motors for X and another 2 for Y. All this part is in the mixer wich is trivial.

However the part I am struggling with is how do I send those commands from RC (or QGC but ideally RC command) to the pixhawk which will then be included in the mixer.

I think getting the position controller into the mix is harder because I’m testing in a lab, so very short distances, and no GPS. plus doing it manually is more than enough.

Bottom line is: Imagine I’m mid flight and I want to move a servo motor. (it’s for X movement but ignore the purpose). It’s just a servo motor like I have in the aux.mixer. How do I do this? do I map it into the flight group 4 - flaps and use that for the mixer?

I hope the question is clearer now.

P.s. if you are on the px4 slack let me know. it would be a bit easier. we’re on very diferent time zones but I always go to bed late xD

However the part I am struggling with is how do I send those commands from RC (or QGC but ideally RC command) to the pixhawk which will then be included in the mixer.

In the video you already pilot it with RC. Then your mixer seems to get the RC command signals.

If not, ‘manual_control_setpoint’ message should be read in your mixer to get the RC stick value. C/C++ source code should be changed.

RC receiver connection to Pixhawk is described in here.

Do you want to do it without c/c++ source code change only by mixer script file change? I thought you changed a mixer source code because you wrote that you suceeded ‘to implement my custom mixer’.

And what is the ‘flight group 4’?

Yes I pilot with the RC but using Roll/Pich. I want to use this different configuration that I will set up in the mixer.

Yes I wrote my own mixer but I’d rather not change anything else in the other files.

Flight Group 4 is called flaps and it’s what I’ll try to use to map my “X movement configuration”, i.e. just move the servos. I just need to map one of my RC buttons/knobs to it.

  1. Is the mixer file you changed that in this folder in PX4?

  2. Does the ‘Flight Group 4’ means ‘Control Group #4’ in this document?

that is the airframe file but yes I have one there

The mixer files are in the next folder. You can see them here in my own repo:

(old versions but they are similar)

my airframe file (also outdated but similar):

Q2. What I mean with four is input 4 of Control Group #0 (Flight Control) so it’s 4: flaps (-1…1)

Oh I understood now. You made custom mixer files for MAIN and AUX output channels but you did not changed any c / c++ source codes for mixers. And you want send another command signal from RC to mixer using Control Input 4 (flap) of Control Group #0. But you don’t know how to set in QGC and RC to send that command signal.

1 . Setting in QGC

As in this document, you can find RC_MAP_FLAPS parameter in QGC. Change the value to the RC channel number you want to use.

2 . Setting in RC transmitter

By using manual of your RC transmitter, set a button/knob to the channel number you used in QGC above.

What RC transmitter do you use?

p.s. But I couldn’t understand exactly the XY control you want. But this may be not related to the answer now.

1 Like

Yes! the first part is spot on.

It’s a Futaba T8J.

The XY control is like I said. Asssuming X control only (cuz not enough knobs) I’ll rotate the knob >> mixer >> Servos will tilt >> Quadrotor will move in X direction. But like you said it’s not part of the problem. That is dealt in the mixer and I know what to do.

This looks the solution I needed!! Thank you so much.

I’ll try this when I can but I’ll ask part 2 of my question now that we are on the subject.

So assume now that instead of using button/knob in the RC I want to use the right joystick (wich is normally used for Roll/Pitch). This is because if this works well I will have no need to send Roll/Pitch input signals from the RC, i.e. they will always be zero. However the controller needs to know it’s always zero to perform automatic stabilization.

Idk if this made any sense so I’ll try and explain in a different way.

Imagine my RC has 3 joysticks 1 - Thrust/Yaw, 2-Roll/Pitch (up to this point its a normal RC) and 3 - X/Y (once again ignore all the position control etc. It’s 2 signals [-1,1] and all the hard weird part is done in the mixer). If I had this RC, the way I want things set up Joystick #2 is always centered, i.e. 0.0. and I will only use joystick 3.

So since #2 is always centered, is there a way (in a normal RC) to use the right joystick as joystick #3?

Anyways thanks again, and if that doesn’t work your solution will have to do as I don’t have much time before my projects presentation. It was still a great help

Fyi (and for anyone else finding this thread in the future) the way described above did not work

However I just used in my mixer Control Group #3 (Manual Passthrough) inputs 5-7 and those can be set to channels in QGC.

Working like a charm now

Hi Riccardo, well done on setting up your custom mixer. I still don’t understand how to implement a custom mixer for a multicopter following the guidance on the px4 website. Could you please point me to an example of a mixer (preferably one with a servo) which I can use as a working example? Thank you.

So after a nice long chat with @RicardoM17, I have some idea of how mixing works. This is to confirm that I understood correctly and for any one in the future who stumbles on this post like I did.

So let’s take an example with the quadrotor in + configuration, where the numbering starts from the top (motor 1) then to the right (motor 2), and then the bottom (motor 3) and finally ends at the left (motor 4).

The mixer file can contain something like the following:
Motor 1

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

  • here, the first line M:3 means, the motor takes in 3 inputs.
    -The next line S: simply declares a mixer. The next no. 0 implies actuator control group #0 - flight control (see Mixing and Actuators · PX4 Developer Guide).
    -the next no 1. signifies the ‘pitch’ channel,
    -the next two nos., each 10000 represent scaled values of the input (-1…1). In this case motor 1 will increase speed in order to ‘pitch up’.
    -For the last three numbers, the first is a 0, which is just an offset, the next two specify min and max output values typically -1 to +1 represented as scaled values of -10000 and 10000.

  • The second and third lines have similar values as described already. the difference is the numbers ‘2’ and ‘3’ after the actuator control group #0 specification. This stands for ‘yaw’ and ‘thrust’ respectively as also given here Mixing and Actuators · PX4 Developer Guide

It follows similar idea for the remainder of the motors.

Motor 2
M: 3
S: 0 0 -10000 -10000 0 -10000 10000
S: 0 2 10000 10000 0 -10000 10000
S: 0 3 10000 10000 0 -10000 10000

Motor 3

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

Motor 4

M: 3
S: 0 0 10000 10000 0 -10000 10000
S: 0 2 10000 10000 0 -10000 10000
S: 0 3 10000 10000 0 -10000 10000

Hope that helps, and if anything is off, for those who are more experienced in this, kindly correct me. Thank you.