Search Unity

AI aircraft steering and physics

Discussion in 'Scripting' started by Jusas, Jan 26, 2014.

  1. Jusas

    Jusas

    Joined:
    Sep 5, 2012
    Posts:
    8
    Ok here goes, I hope I can get some advice...
    I've been developing a game which has a semi-realistic flight model - ie. based on the four basic forces of thrust, lift, drag and weight. The physics themselves aren't really the hard part as I've found out (I'm pretty much just calculating the forces myself right now, I should probably look more into utilizing the Unity physics engine properly), however making an AI that knows how to actually steer a plane seems to be considerably harder.

    The basic problem is this: how to make the aircraft know when and how much to bank, as turning is mainly controlled by the generated lift. Then there's also the angle of attack involved, meaning that the aircraft is not always flying exactly where its nose is pointing. Then there's avoiding stall and trying to avoid excessive angle of attack. Generally speaking a lot of variables and steering to do.
    I've got a pretty decent model for most of this but it's still lacking. What I'm most frustrated about is that there seems to be no material on this subject anywhere. Sure, there are nice physics models of flying and sure, it's easy when you control the stick but when you need to make an autonomous AI it gets a lot more complicated. I think I've got the basics right after a bit of testing but I'm still suffering from things like drifting and the general behaviour just seems rather unstable.

    So... I'd really appreciate any links or information about this subject. I don't expect a straight answer and a solution, I'm simply craving for more material on this subject. There's a bunch of flight simulators out there so I'd imagine there should be plenty of knowledge out there, I just can't seem to find it. Doing this with a fake flight model is easy (just using turning rates and forgetting about lift) and I've constructed a steering model for that already but I really do want an authentic flight model. I'm probably going to get this right at some point even without help but it would be great to know how others have tackled this problem and find "the right way" of doing this if there is one.

    So fire away, any links or insights you may have, please share :)
     
  2. TheShane

    TheShane

    Joined:
    May 26, 2013
    Posts:
    136
    That sounds like a difficult problem. When it comes to games, my guess it is always faked to some extent. Maybe not in some flight simulators.

    If you want an authentic autopilot, then your best bet is to look in how they do it with real planes. Something like the open source drone flying software "OpenPilot"; you would be basically doing the same thing except you always have ideal conditions and perfect sensors. You may have better luck asking for guidance on their forum (or other forum for people who write software control systems for real planes/drones/models). It's pretty specialized information and you'd have to be pretty lucky for someone who really knows about autopilot controllers to come across your thread in the few hours or days it's on the top page of the Unity forums.

    You use the word "game" in your first sentence and not "simulation" so I would probably lean towards creating a really plausible fake system. Maybe if you find some good resources it will end up easier than I think to do the real thing.

    Good luck!
     
    starikcetin likes this.
  3. Jusas

    Jusas

    Joined:
    Sep 5, 2012
    Posts:
    8
    Thanks for your input TheShane!

    I spent the last night thinking about the problem and you're right, it's indeed a complex one. Not to mention how much more complex it can get when dogfights get involved. I'm probably way over my head here and the rabbit hole goes deeper than I thought.

    You're right - what I should do is create a faked system, and that it's a game and not a simulation. The nice part is that I don't necessarily need to abandon everything I've worked out so far. A lot of the same calculations I've used can still be used albeit a bit differently, adding to the authenticity of the flight model - but not being restricted by them. It makes a lot of sense now. Funny enough I first created a fully faked flight model with close to no variables, then decided to go fully physics and now I see the problems and advantages of both :) A lot of time and effort "wasted" but then again not quite wasted at all, now I know what I really should aim for.
     
  4. DenisGLabrecque

    DenisGLabrecque

    Joined:
    Jul 29, 2017
    Posts:
    7
    What conclusion helped you the most? How did your flight model adjust pitch/yaw/rotation? I'm looking into this for creating a simple physics missile, so wondering on your process. Do you still have code around? I've been looking at the airplane controller AI from Unity.
     
  5. newjerseyrunner

    newjerseyrunner

    Joined:
    Jul 20, 2017
    Posts:
    966
    This seems like a good place to evolve a small neural network. Make a small network and tweak the numbers of ten of them, try them and then do it again with the best performers u til it works.
     
    starikcetin likes this.
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,776
    While this is true, as I did 3DoF Gimbal Controller for thruster based space craft,

    replaying to 4 years old thread, asking OP for the advice, is least likely gain any results.
     
  7. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I read somewhere about a project that used actual Quadcopter firmware. The quad was a rigidbody and they added force to each motor point. They fed the motion data into the firmware and it responded correctly.
     
    starikcetin likes this.