# Real Drone Simulation with Hinge Joint?

Discussion in 'Physics' started by weizenhuhn, Dec 11, 2016.

1. ### weizenhuhn

Joined:
Dec 5, 2016
Posts:
7
Hi,

i wanna create a drone Simulator as realistic as possible. Currently i created an octocopter drone where the rotors are connected to the propeller with a hinge joint.

Now i'm using just addForce methodes and up-Vectors, what is easy but not accurate i guess.
Is it possible, to let a drone fly only with hinge joint if i adjust the mechanics of a real drone to unity?

2. ### Quakeulf

Joined:
Mar 26, 2013
Posts:
40
u wot m8

Are you meaning that the spin of the propeller will be the factor creating force?

3. ### Dennis_eA

Joined:
Jan 17, 2011
Posts:
250
You should let the propellers rotate with transform.Rotate(Vector3.up * someValue * Time.deltaTime, Space.Self) (in Update!)
or something..making them all rigidbodies itself and adding forces seems to be wrong.
Also hinge joints are not necessary.

What you can do is use AddForceAtPosition for every propeller(position) and increase or decrease the forces there.

Lets say you have your drone (parent) and 8 (empty) children. These are (then moved to) the positions for each propeller. Drag them all into an array

var propeller : Transform[] = new Transform[8];
private var propellerInputForces : float[] = new float[8]; //later in the code, you add or subtract input
private var propellerRotationMultiplyVariable : float = 30.0; //make propellers spin faster
Code (JavaScript):
1. and then, in Fixed Update:
2. for (var i : int = 0, i < 8, i++) {
3.     rb.AddForceAtPosition(transform.up * propellerInputForces[i], propeller[i].position, ForceMode.Acceleration);
4. }
5.
6. In Update:
7. for (var ii : int = 0, ii < 8, ii++) {
8.    propeller[ii].Rotate(Vector3.up * propellerInputForces[ii] * propellerRotationMultiplyVariable * Time.deltaTime, Space.Self);
9. }

weizenhuhn likes this.
4. ### Quakeulf

Joined:
Mar 26, 2013
Posts:
40
How exactly?

For a standard Quadcopter subtraction and addition of forces based on direction and thrust is complex enough.

If you have some sort of system to make this easy to scale for Multicopters of engines over 3 I would be really interested in knowing more about it.

5. ### Dennis_eA

Joined:
Jan 17, 2011
Posts:
250
I don't know anything about drones hehe

But what I mean with input is, that you can set thrust on all propellers seperately.
Controlling all these propellers, that is - of course not part of the (pseudo) code I posted.. I think That would be part of your developing process. Again, I am really not into drones.

I could imagine that you could simulate a quadcopter, and make every second propeller just ummmm cosmetic

6. ### larku

Joined:
Mar 14, 2013
Posts:
1,412
I'm not really following what you're asking for but if you want to simulate a "multi-rotor" or "multi-copter" (the use of the term "drone" just irks me ) I'd start by implementing it the same way as real multi-rotor flight controllers do.

• simulate a gyro
• simulate an accelerometer
• implement a Flight Controller that takes the inputs from the gyro and accelerometer. It's not crazy complex, it's mostly based on these two inputs and the configured P.I.D values.

It's a well understood problem that's been solved.

7. ### weizenhuhn

Joined:
Dec 5, 2016
Posts:
7
Thanks at all. I made it similar to this.
So i used the ForceAtPosition.