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: https://www.youtube.com/watch?v=07DglmVEWaI&feature=youtu.be

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.

Thanks!!

Ricardo

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. https://dev.px4.io/en/concept/mixing.html

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):

https://github.com/RicardoM17/Firmware/blob/master/ROMFS/px4fmu_common/init.d/4100_tiltquadrotor

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.

EDIT:
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.