PX4-Devguide icon indicating copy to clipboard operation
PX4-Devguide copied to clipboard

Adding new air-frame for multicopter.

Open chuong98 opened this issue 7 years ago • 23 comments

We want to do an experiment with a new configuration, as illustrated in the Fig quad_ct The idea is: M1 is the big motor at the Center of the Gravity to create 99% thrust, and facing down. M2 is small motor to control positive pitch, facing up M3,M4 are the small motor, M2 tilts 45deg, and M4 tilts -45deg, to create yaw moment to balance with the big motor, while also control roll and pitch.

Take the center motor at the origin, and follow NED coordinate, the position of motor is #motor (x,y,z) (direction in (x,y,z) ) M1 (0,0,0) (0,0,1) M2 (-R,0,0) (0,0,-1) M3 (-R/2,R,0) (cos(45),0, -cos(45)) M4 (-R/2,R,0) (-cos(45), 0,-cos(45))

I would like to create quad_cT config in the mixer file, how should I do it. Thanks for your help.

chuong98 avatar Jan 19 '18 21:01 chuong98

@chuong98 cool design! If I may suggest something, M3 and M4 will create more pitch moment than M2 so you should either place M3 and M4 closer to the CG, or tilt them at 60° instead of 45°.

Step 1 Geometry

1-a Geometry file

Add a geometry file in the folder src/lib/mixer/geometries/ named quad_ct.toml with the following content:

# Experimental multirotor

[info]
key = "4ct"
description = "Experimental multirotor"

[rotor_default]
direction = "CW"
axis      = [0.0, 0.0, -1.0]
Ct        = 1.0
Cm        = 0.05

[[rotors]]
name      = "M1"
position  = [0.0, 0.0, 0.0]
Ct = 100
Cm = 5

[[rotors]]
name      = "M2"
position  = [-1.0, 0.0, 0.0]
direction = "CCW"

[[rotors]]
name     = "M3"
position = [0.5, -1.0, 0.0]
axis = [0.7071, 0.0, -0.7071]
direction = "CCW"

[[rotors]]
name     = "M4"
position = [0.5, 1.0, 0.0]
axis = [-0.7071, 0.0, -0.7071]
direction = "CCW"

Ct are the thrust coefficients and Cm are moment coefficients, I put arbitrarily larger values for M1 but you will have to adjust it to your motors. For this you can measure the thrust ratio between M1 and M2 and use the same ratio for the respective Ct-s. Same thing for the moment coefficients.

1-b Cmakelists

Add quad_ct.toml to the geometry list here: https://github.com/PX4/Firmware/blob/master/src/lib/mixer/CMakeLists.txt#L45

jlecoeur avatar Jan 19 '18 22:01 jlecoeur

Step 2 Mixer file

Add a mixer file in the folder ROMFS/px4fmu_common/mixers/ named quad_ct.main.mix You can follow the existing guide: https://github.com/PX4/Devguide/blob/master/en/airframes/adding_a_new_frame.md Your mixer file will be similar to quad_x.main.mix, just replace 4x by 4ct.

Step 3 Airframe file

Add an Airframe file in the folder ROMFS/px4fmu_common/init.d/ Again you can follow the devguide (link above)

Step 4 Send us the video!

jlecoeur avatar Jan 19 '18 22:01 jlecoeur

Wonderful. I will make it and update the status. Thanks so much for your super fast reply.

chuong98 avatar Jan 20 '18 00:01 chuong98

So, I followed your instructions, but there are three points I want to confirm:

  1. SInce the M1 facing down, should I add the axis [0,0,1] as follow.
 [[rotors]]
name      = "M1"
position  = [0.0, 0.0, 0.0]
axis = [0.0, 0.0, 1.0]
Ct = 100
Cm = 5
  1. How is the name 4ct created. Should I make any changes in the file multi_table.py? How does it know that 4ct will link to quad_cT.toml.

  2. I ran the command make px4fmu-v4_default and checked the file mixer_multirotor.generated.h in /build/px4fmu-v4 folder, but I dont see the mixer matrix of _config_quad_cT. I think I am still missing something Thanks for your suggestion. Indeed, we placed M2,M3 about R/4, but I just gave an example R/2 to match with the fig. Thank so much for your help again.

chuong98 avatar Jan 20 '18 00:01 chuong98

Ok. So, if I make the name is quad_ct.toml (instead of quad_cT.toml) then every thing is compiled correctly. It works now. Thanks again.

chuong98 avatar Jan 20 '18 01:01 chuong98

No problem, let me know how it goes!

  1. No, what matters is the thrust axis, as it is pushing upwards then the axis is [0.0, 0.0 -1.0]
  2. 4ct is the key that you provide in the info section of quad_ct.toml. mixer_table.py is not used anymore (it was even removed in master), the new script is px_generate_mixers.py. This script does not have to be changed, it knows quad_ct.toml because you added it in the CMakelists.
  3. You can rename quad_ct.toml to quad_cT.toml if you wish (and update the CMakelists accordingly). Also you will see that the geometry file, mixer file and airframe file do not need to be named the same. It could be quad_ct_geom.toml, quad_ct_mixer.main.mix and 12345_quad_ct_airframe.

jlecoeur avatar Jan 20 '18 07:01 jlecoeur

@jlecoeur As a result of this discussion, is there anything that needs to be added to to (that is missing from) the devguide? Brief scan seems to indicate that we don't have anything about the geometries file, is this something you could add to the instructions for building an airframe?

hamishwillee avatar Jan 30 '18 22:01 hamishwillee

The tutorial in the previous discussion is complete to add new configuration. no additional information is needed.

chuong98 avatar Jan 30 '18 23:01 chuong98

@jlecoeur Ignore my comment above, I see you have an action to do this update in Add documentation on multicopter mixer #349 - any ETA on this?

Other docs related to this include

hamishwillee avatar Jan 30 '18 23:01 hamishwillee

@chuong98 were your tests successful? Your platform covers many features of the mixer generator and toml files. It would make a perfect tutorial in the documentation. Are you able to share pictures of the platform, and a video of the flight?

jlecoeur avatar Apr 12 '18 15:04 jlecoeur

@jlecoeur Hi Jlecoeure, I already graduated and my team is still working on it. We have a competition of designing a new prototype for sUAV at Arizona State University. At this moment, we can not release much the information. I will ask the team about the picture and send you if they are ok with that.

chuong98 avatar Apr 12 '18 16:04 chuong98

Hi Jlecoeure, I'm working on this sUAV prototype. I found out the moment and thrust coefficients for M1 which leads to yaw equilibrium. But, the sUAV seems to pitch forward and flip over everytime I increase the throttle. Could you let me know how I can incorporate this into my mixer geometry.

hlal1 avatar Apr 16 '18 23:04 hlal1

@jlecoeur ,

Thank you so much for your explanation, it has actually giving us a good picture on how to add a new frame. The script is quite straight forward, however besides the [rotor_default] part. Could you please elaborate each of the code line, such as the reason and meaning as well as the logic to find the value of Ct&Cm.

Appreciated your reply. Thanks again!

tzehwei avatar Apr 26 '18 10:04 tzehwei

@jlecoeur This has been sitting around for a while, can you please give me an updated ETA? If we can't do a proper job, would it not be useful to create a placeholder linking to all these open issues on the topic:

Are there any other resources we might add?

In addition, could you advise on http://discuss.px4.io/t/mixer-and-geometry-for-new-vehicle-documentation-and-help/8843 ?

hamishwillee avatar Dec 12 '18 22:12 hamishwillee

So some take aways from questions I ended up asking myself trying this on my own awhile back and as @hamishwillee noted, with scattered information this only gets more difficult.

A clear actual walkthrough, with some only topical reasoning behind it would be good. Deep theory is not needed.

The definitions of most steps are quasi there (mixer is but a TOML is not) but the steps arent clear to follow. Why and what a TOML is and how it relates. While this is essentially the physical coordinates, ie geometry but does it effect the mixer itself? Are arm lengths taken into account (yes but it doesnt say that anywhere). Does it effect the actual mixer since they are normalized? We should have an example of a quad without equally spaced arms that are a given distance (12" long for instance) so the user can work backwards to figure it out by looking at the example. List the angles, arm length, etc. Then what the subsequent TOML looks like and then mixer. So essentially, the actual steps to follow and how to enter them. For the TOML files, what is the motor orientation, which should be able to be figured out from above if an example is given and could be possible to guess for most as X,Y,Z with X as forward) same as everything else) but still, state it. How to calculate the input values ([Length of arm * sin(angle in radians), Length_of_arm * cos(Angle in Radians), 0]. And how this is based on the CG so which values should be expected to be negative (for the left and rear sides).

I would also give some notes about what to enter in the mixer after doing this. Does and how does the TOML effect the mixer with equal mixes (-10000 10000)? That's a good thing to clear up.

On the other side of all this is the elusive jupyter notebook @jlecoeur made. That is really what should be used given its robustness. You can pretty much do anything in it but there is not real documentation, you either have to understand the math, trial and error it forever or simply read through every part and work backwards to figure it out. I did the last one and I still only ended up focusing and experimenting with what was relevant to me. But things like motor tilt, actual heigh differences, etc are all possible. Even 6dof which i know is in the python script in the tools folder that reads the TOML (that @jlecoeur also wrote) has it but disabled, but there is a lot of great granular control here, just not documented. So then what does one do needs to be addressed. Imagine I've entered in the correct coordinates (which is done how [the same as for the TOML] but it should state that) and then it kicks out a normalized mix. That's the next questions, not only what to do with it but how. Not linking to follow this other guide from here. It's too complex.

I'm just really scratching the surface but there is a lot here and with some help and brief examples this would be a lot easier for people, it took me quite some time to wrap my head around it initially because simple things are easily forgotten (degrees to radians...) and the notes are spread out through issues but would like to see this available for people to use. Happy to help as required.

ryanjAA avatar Dec 13 '18 23:12 ryanjAA

The April 2020 call for a dev guide on this topic please as I/we too, have a unique config we would like to program in :-)

catchrow1 avatar Apr 27 '20 19:04 catchrow1

@jlecoeur @bkueng FYI, reminder. Beat, at what point do we give up on Julien? For myself I do not have time to commit to this (even to help) for about 2 weeks.

hamishwillee avatar Apr 28 '20 02:04 hamishwillee

I currently don't have time either. Can you ping we when you have time again?

bkueng avatar Apr 28 '20 06:04 bkueng

I'll try, but the way it is looking right now, "not soon".

hamishwillee avatar Apr 29 '20 01:04 hamishwillee

Hi, I have some questions to follow up, as I too, as a first time excursion into this would love a guide!

  1. in the cmakelist file, am i just add in the *.toml file as an extra line, or do i replace or create new add library set?
  2. The reference to 4x and 4ct above- is tha std terminology or can i use my own?
  3. The *.toml file name. I can change the <Name>, but what about ? is that std or made up?

catchrow1 avatar Apr 30 '20 14:04 catchrow1

@chuong98 can you please upload your cmakelist.txt file? Im getting errors at this point and want to see what it should look like! Thanks!

catchrow1 avatar Apr 30 '20 15:04 catchrow1

@ryanjAA would it be possible to share with me the jupyter notebook?, I am myself trying to add a new config but I'm having trouble with the scattered information online.

JARC99 avatar Nov 20 '20 14:11 JARC99

@JARC99 it is here: https://github.com/jlecoeur/servo_mix_matrix

This lets you pretty much do anything needed. Just takes a bit of work to go through not the notebook but the whole TOML process for recompiling, it does however work fine once you spend a little time getting to know what data is wanted, etc.

ryanjAA avatar Nov 24 '20 17:11 ryanjAA