Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Controller [WIP] Quaternion based PID controller

Discussion in 'Tools In Progress' started by VacuumBreather, Jun 23, 2015.

  1. VacuumBreather

    VacuumBreather

    Joined:
    Oct 30, 2013
    Posts:
    68
    Have you ever run into the problem of wanting to control the rotation of a physics based actor with the same elegance that PID controllers offer you for the translation axis?

    Well I have found a quaternion based algorithm for a PID control and implemented it. I am working on finalizing a package and you will be able to access it on the Unity asset store soon.

    Demo: http://media.wcsaga.net/keldorkatarn/quaterniondemo/

    Tell me if you think this is an interesting script you would like to see.
     
  2. combatdave1

    combatdave1

    Joined:
    Dec 17, 2014
    Posts:
    11
    Yes please!
     
  3. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    156
    Second that :)
     
  4. VacuumBreather

    VacuumBreather

    Joined:
    Oct 30, 2013
    Posts:
    68


    I already submitted it as a draft for the asset store.
     
  5. combatdave1

    combatdave1

    Joined:
    Dec 17, 2014
    Posts:
    11
    You beauty!
     
  6. VacuumBreather

    VacuumBreather

    Joined:
    Oct 30, 2013
    Posts:
    68
  7. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    If the target is constantly moving, does it work well?
     
  8. VacuumBreather

    VacuumBreather

    Joined:
    Oct 30, 2013
    Posts:
    68
    Depends on what you want to achieve. If you just want the object to keep matching the target's rotation, then yes that doesn't matter. If you talk about perfect target tracking like for example to aim a gun at something, that's a bit tricky but can be done. I'm still looking into the prefect way of achieving target tracking since that's also what I'm going to use this for. Once I find the perfect way to do that I'll add a tutorial video to its asset store page. My current approach is to pre-calculate the "look at rotation" by precalculating the target position a number of frames into the future, to compensate for the lag. But there are numeric solutions to compensate for this kind of lag in PID controllers, I just need to figure out how to do it for this specific problem. That's a general problem to be solved when using a PID controller however, it's not specific to this one, it'd be a problem for linear movement too.
    But I'm definitely interested in that as well, so I'll keep you updated on that.
     
    Eluem likes this.
  9. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57

    If you don't mind, I'd like to learn more about the algorithm itself. I'd like to try and implement it myself, if I can. Can you point me to where you found the algorithm, a white paper or something? It would be a great learning exercise for me, and I'd like to develop my own implementation to use in a character controller asset I'd like to release.

    Any assistance would be massively appreciated!

    Edit: Is this the paper?
    http://ltu.diva-portal.org/smash/get/diva2:1010947/FULLTEXT01.pdf


    Any update on figuring this out, btw?
     
    Last edited: May 29, 2021
  10. VacuumBreather

    VacuumBreather

    Joined:
    Oct 30, 2013
    Posts:
    68
    It's actually this paper: https://arc.aiaa.org/doi/10.2514/6.2012-5028
    And no sorry no further progress, I have been busy with other projects in the mean time. I'm sure I'll come back to this eventually but it'll be a while. Right now I'm working more on the UI side of things. :)

    That paper actually goes way further than what I did. The Quaternion controller is basically the groundwork they put down before moving on to what they actually want to do :D
     
    Eluem likes this.
  11. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57
    Thanks for the info! This will be very helpful. Yeah menus are a whole art of their own. Maybe you can add some PID animations to them :p

    Good luck with your projects!
     
  12. VacuumBreather

    VacuumBreather

    Joined:
    Oct 30, 2013
    Posts:
    68
    Thank you. I'm working on something with the Noesis guys :)
     
    OUTTAHERE and Eluem like this.