Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

AI Planner - v0.1.1-preview Release!

Discussion in 'AI & Navigation Previews' started by TrevorUnity, Aug 30, 2019.

Thread Status:
Not open for further replies.
  1. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    118
    Hello, everyone! Today we are releasing our latest update to the Unity AI Planner, version 0.1.1-preview. Here's a few of the high-level changes you can expect in this release:

    • Enhanced inspectors for domain editing.
    • Assets for holding domain data.
    • Code generation into separate assemblies.
    • Reduced main thread computation.
    • Reduced managed memory allocations.

    You can grab this release via the package manager starting today. The package documentation should be published shortly. Feel free to use this thread for feedback or questions. As a note, we have a few known issues you may run into:

    First, due to the package's heavy reliance on the entity command buffer (from the entities package), you may experience small, repeated allocations on frames when planning occurs. This issue will be fixed in a future release of entities.

    Secondly, we are aware that when using the planner package for prolonged planning, Unity can allocate large amounts of native memory. We're investigating this and will issue a minor fix update in the coming weeks.

    Moving forward, we will continue to focus on the authoring workflow, planner performance, and scene configuration tools. Furthermore, we'll be considering extensions to our trait language to help model an even wider range of planning problems. We'll be previewing some of these features in the coming months, so be sure to check back here!

    Thanks, everyone, for your helpful feedback! We look forward to seeing the many creative ways you use the package!

    Demo Project - Otto: https://github.com/Unity-Technologies/otto
     
    Last edited: Oct 16, 2019
  2. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    exciting news! thanks, taking a look now.
     
  3. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    181
    Thanks for good work, waiting for you update.
     
  4. threedots1

    threedots1

    Joined:
    Oct 9, 2014
    Posts:
    88
    Not working currently on 2019.3.0b1, throws a bunch of
    Code (CSharp):
    1. MissingMethodException: void UnityEngine.UnityAPICompatibilityVersionAttribute..ctor(string,string[])
    Downgraded and it seems to work now.
     
  5. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    181
  6. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Otto Does not work with 2019.2.3f1

    Assets\AI.Planner\Workaholic-Custom\CustomNavigateEffects.cs(3,18): error CS0234: The type or namespace name 'Domains' does not exist in the namespace 'AI.Planner' (are you missing an assembly reference?)
     
  7. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Do you have an Assets\AI.Planner\AI.Domains.Dll in your project?
     
  8. ice-k

    ice-k

    Joined:
    May 9, 2018
    Posts:
    6
    Assets\AI.Planner\Workaholic-Custom\CustomNavigateEffects.cs(3,18): error CS0234: The type or namespace name 'Domains' does not exist in the namespace 'AI.Planner' (are you missing an assembly reference?)
    2019.2.2~2.3 Same error
     
  9. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Yes the DLL is in there, it is what is currently in Otto

    https://drive.google.com/open?id=12a_T8w_rPdyttXwxcbKB4YRTNQKLTyVJ


    Assets\AI.Planner\Workaholic-Custom\CustomWorkEffects.cs(3,18): error CS0234: The type or namespace name 'Domains' does not exist in the namespace 'AI.Planner' (are you missing an assembly reference?)

    Assets\AI.Planner\Workaholic-Custom\CustomWorkEffects.cs(8,85): error CS0246: The type or namespace name 'StateData' could not be found (are you missing a using directive or an assembly reference?)

    Failed to load 'C:/Users/vinci/Desktop/otto-master/Assets/Models/Otto/Animation/Item_GrabPocket.anim' because it was serialized with a newer version of Unity. (Has a higher SerializedFile version)

    This last one is weird because the Git hub says Otto was updated to 2019.2.2f1 but I am opening with 2019.2.3f1
     
  10. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Some how
    From this screenshot it looks like the DLLs aren't importing correctly because it shouldn't show it as a Native DLL (it's managed). What is the file size of the DLL? It should be around 26KB.
     
  11. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Well I got it working, I forgot that if you download a zip from GIT it will strip big files.

    Otto must be download via command line or via something like source tree.

    Plus I had to rebuild the library. But Otto is working! Even 2 at the same time!
     
  12. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    I've started a thread within the GitHub community to encourage the ability to disable downloading of .zip files for owners of repositories, but haven't heard back from anyone at GitHub yet. Unfortunately, this causes many issues. In the future, I think we will include samples with the package. Otto is a bit too large to be a sample, which is why we didn't include it.
     
    eterlan and vincismurf like this.
  13. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86

    How did you rebuild the library? I have cloned the project from the command line and have confirmed my Domains file is present and is 26kb, but I still get:

    Assets\AI.Planner\Workaholic-Custom\CustomNavigateEffects.cs(3,18): error CS0234: The type or namespace name 'Domains' does not exist in the namespace 'AI.Planner' (are you missing an assembly reference?)
     
  14. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Close the project, go to the root folder, where the assets, project settings and library folders are. . . . delete the library folder. Re open the project
     
  15. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Ok next problem. . . when I upgrade a project that had the older planner version in it I was not able to create all the scriptable assets, so I removed all the old stuff.

    It started complaining

    Microsoft (R) Visual C# Compiler version 2.9.1.65535 (9d34608e)
    Copyright (C) Microsoft Corporation. All rights reserved.

    error CS2011: Error opening response file 'C:\ASC\DragonsLore\game\Assets/AI.Planner/csc.rsp'

    It also did not generate a new AI.Planner folder

    In a fresh project I do see the AI section in the menu and how it generates the assemblies ( if a folder is already corrected)

    But it does seem like this missing response file has broken my old project =(


    Update: I reverted that file and it allowed the package to complete installation and create all the assets. BUT I still have to have that file, does anyone know where it is being set?


    Liking the new interface.

    I noticed in the documents we need a new class

    public class YourAgentClass : BaseAgent<YourAgentClass, DomainObject, StateEntityKey, StateData, StateDataContext, ActionScheduler, Heuristic, TerminationEvaluator, StateManager, ActionKey>
    {
    }

    However ActionScheduler is tied to the namespace AI.Planner.Actions.WorkaholicAgent, so in fresh projects without Otto the document example doesn't compile

    Update

    Ok so generating assemblies after the domain is set up will create a namespace to an agent's actions which can be used in your BaseAgent class.

    I highly recommend everyone recreate Otto in their project, it is very informative.
     
    Last edited: Sep 3, 2019
  16. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    We got rid of the csc.rsp files, since the assemblies are now compiled outside of the project. You should just be able to remove csc.rsp. However, you might also need to check if you have any <X>_DOMAIN_GENERATED or <X>_ACTIONS_GENERATED, etc. in your build settings defines. Remove those.
     
  17. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    That definitely helped. I think some other assets got lost somewhere as I have a number of "Missing Prefab"s in the scene, and everything is black except for the UI (bars, etc) and Otto, who does not have any textures. However when I hit play, he animates, and the AI Planner does run. I recall what the scene looked like previously so I pretty much get the gist of what is happening, but I'm not sure if anyone else ran into this.

    In any case, I can see the AI Planner planning and guiding Otto's actions, which is cool. Also I agree, the new interface is improved. Looking forward to people posting their processes on YouTube.
     
  18. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Seems like the repo did not pull all the large files properly. If you do a `git status` what does it show? Have you tried doing a `git lfs fetch`?
     
  19. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Well I have been rebuilding Otto in another project, it seems I must have missed something When I run I get

    My Otto object first throws this.
    ArgumentException: Object AI.Planner.Domains.DomainObject does not exist within the state data Domain Object: (<< 2 >>)

    Then it spams this

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.AI.Planner.DomainLanguage.TraitBased.BaseAgent`10[TAgent,TObject,TStateKey,TStateData,TStateDataContext,TActionScheduler,THeuristic,TTerminationEvaluator,TStateManager,TActionKey].Update () (at Library/PackageCache/com.unity.ai.planner@0.1.1-preview/Runtime/Agent/BaseAgent.cs:273)
    Workaholic.Otto.Update () (at Assets/Scripts/AIPlanner/Otto/Otto.cs:32)

    Which fails in BaseAgent:Update()
    {

    m_Controller.Update();

    m_JobHandle = m_PlannerScheduler.Schedule(default);
    // FIXME: Ideally, we don't complete immediately, but without doing this the entity debugger throws errors
    m_JobHandle.Complete();

    }

    m_Controller is not defined.

    Not sure where I went wrong.
     
    Last edited: Sep 3, 2019
  20. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    118
    If the controller is null, it likely failed during the initial state creation (PlanningDomainData.GetInitialState). How are you setting up your initial state info in the new project?
     
  21. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Yeah it was clearly how I set up something. . . . I got otto doing his thing in my level so I need to try again
     
  22. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    181
    I create 2 action with 2 different operation action-action: "a1" with operation action "op1" and action "a2" with operation action "op2". Both operation action will displays "op1" or "op2" Debug.Log("op1") , Debug.Log("op2") dependent in which action was taken.Also Traits was created with one bool field "check".
    action 1 precondition(field "check" == false) and effect to change field "check" = true.
    action 2 precondition (field "check" == true) and effect to change field "check" = true.

    In normal case the action 1 will run then follow by action2 then action 1 followed by action 2 and so on and output op1 op2 op1 op2 op1 op2.
    But i get only action 1 was run continuously.
    Demo Scenes in attachment.
     

    Attached Files:

  23. mplantady_unity

    mplantady_unity

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    49
    If you look at the Plan visualizer, what you did is actually working as expected.
    But you would need to update your state inside your operational action (in your EndExecution) to advance your plan, otherwise your root state will stay the same (I agree it's not very intuitive, and we actually are working on a new system to handle this)
     
    eterlan, vx4 and sordidlist like this.
  24. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    The various iterations in usability have been great so far! I'm starting to get how it all works. Operational Actions are where I'm hung up at the moment too. The ones that come with Otto are very informative but they're a read for sure. Makes sense why - it just takes some time.
     
    mplantady_unity likes this.
  25. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    So I spent the weekend getting deep with the Otto example. . . here is what I learned:

    1) A Planner action has a state machine paradigm:
    BeginExecution()
    ContinueExecution()
    EndExecution()

    2) These methods control the animator state machine (Mechanim). The animator is composed of sub-state machines at the root level like sleep/work/eat.

    3) The BeginExecution() from the Action calls a trigger property to switch the animator to a sub state like sleep/work/eat.

    4) Each sub state machine is composed of 3 categories or states, BeginState ( ie jump into bed), StateUpdate (sleeping loop), EndState(get out of bed)

    5) Many of these states use StateMachineBehaviors (scripts attached to Animator states) to initialize, and update and an animator property.

    6) These animator properties are then used in transitions from the StateUpdate to EndState in the sub state machine.

    7) Many StateUpdates also transition to itself based on a boolean property.



    The main point being. . . to truly understand the Otto example you need a deep under standing of Mechanim
     
  26. vx4

    vx4

    Joined:
    Dec 11, 2012
    Posts:
    181
    Just to keep in mind.
    ContinueExecution() and EndExecution() mostly depend on return value from OperationalActionStatus Status(...)
     
    vincismurf likes this.
  27. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    Thanks for posting a summary! I like that character animation/action is decoupled from the logic/planning. I need to look more into the StateMachineBehaviors, it sounds like they give a finer grain level of control? (ie, if we wanted to make Otto roll around into various sleeping positions while in the Sleep state, we could do it here?)
     
  28. TonyGrahn

    TonyGrahn

    Joined:
    Aug 4, 2012
    Posts:
    3
    This is a great package.

    I do wonder what approach should be used to modify an agent at run-time? Using Otto as an example, how should he change to a different type of work or how should he be allowed to eat additional foods at run-time?
     
  29. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Thank you, @TonyGrahn. We're glad this is useful to you.

    Re: modifying an agent at run-time -- it depends on what you want.

    If you want Otto to eat an additional type of food, then it would be possible to modify the original ConsumableType enumeration to include another type of food. You'd need to add a new Dispenser game object in the scene and model it after the FoodDispenser or BottleDispenser. You'd also need to add an Inventory_<NewItem> domain object to Otto as a way to keep track of these items. After doing this work and setting up any visuals in the game the current actions should work fine.

    Now, if you're talking about a mode-switch where Otto would behave in an entirely different way or do a different type of work, then you'd do a bit more work to create a separate planning definition and add multiple Otto scripts to the AI_Prefab GameObject. Then you could toggle between the two depending on what mode you wanted. However, I wouldn't suggest doing this with the current version. We're about to introduce a better workflow that should enable just that in a much easier way.

    Does this answer your question?
     
  30. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Yep, that sounds like a good use of a state machine where you want specific, designed behavior without a need for decision making.
     
  31. TonyGrahn

    TonyGrahn

    Joined:
    Aug 4, 2012
    Posts:
    3


    Yes, this very much answers my question. I noticed that trait, enum, and action definition assets were compiled from generated C# at build time and was worried this might make large behavior changes impossible at run-time. But if I understand you correctly, creating separate planning definitions for every permutation of behavior and switching between them is a workable solution. I also see that custom reward functions are possible so if those are going to be in the final version, maybe they could be useful for this too.

    Great work, I understand it is still under very active development and you're working on workflow so I know not to get too emotionally attached to code I hack together playing with Otto.
     
  32. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    can't find it
    upload_2019-9-22_16-38-11.png
     
  33. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
  34. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    2018.4.0f1
     
  35. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    also I tried 2019.3b4 (which shows the package) and got this error

    Code (CSharp):
    1. An error occurred while resolving packages:
    2.   Package com.unity.entities@0.1.1-preview has invalid dependencies:
    3.     nuget.mono-cecil: Resolved version [0.1.5-preview] does not satisfy requested version [0.1.6-preview]
    4.  
    5. A re-import of the project may be required to fix the issue or a manual modification of D:/PROJECTS/Unity AI Planner/Packages/manifest.json file.
    6.  
     
  36. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    found out that entities 0.1.1 ain't compatible with this, gotta downgrade to 0.1
    I thought the package manager handled these?
     
  37. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    v0.1.1 requires 2019.2
     
    laurentlavigne likes this.
  38. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    This is very interesting tool!

    One question about its future direction: will it be ever possible to load plan definitions at runtime from a text file, rather than requiring the editor and code generation? For context: we make games that are heavily procedural and rely on everything getting loaded from text files at startup, for moddability as well as to make scripting easier on the design side (especially in AOT environments where recompilation is painfully long - but also, scripting in text makes collaboration much easier).

    Unfortunately it doesn't look like that use case is currently supported by this package, because of reliance on codegen, and I'm wondering if that's something that's on the roadmap, or if that's a use case that is going to be unsupported?
     
  39. zephyr831125

    zephyr831125

    Joined:
    Mar 4, 2017
    Posts:
    54
    upload_2019-9-24_17-35-58.png
    It seems can't input float value into this field. It auto changed to Int value, even if I copied a float here.
    PS: Target.Progress is float type.
    upload_2019-9-24_17-39-7.png
     
  40. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    118
    Loading plan definitions from file (likely JSON) is certainly one of our backlog items. We haven't yet placed it in our short-term roadmap.

    Runtime changes are also a point of discussion for us. We'll likely roll this out in stages, based on priorities from requests. Changing the set of actions available is the most common request, though changing rewards, heuristic, and state termination criteria could all be useful. At first, we'll likely support swapping among pre-defined/pre-generated components, as it avoids the live code generation hurdle. Stay tuned!
     
    Djayp, rzubek and vx4 like this.
  41. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    118
    Definitely a bug. It was a parsing issue. Luckily, we have already fixed it, so it will work in our next update.
     
  42. rzubek

    rzubek

    Joined:
    Aug 21, 2014
    Posts:
    72
    Thank you for the details! Agreed that live codegen would be bad, specifically since it's not an option on AOT platforms. Being able to define actions entirely through text files, load them up at runtime, and have the planner use those instead of codegen, would be highly desirable.

    Looking forward to future developments!
     
  43. zephyr831125

    zephyr831125

    Joined:
    Mar 4, 2017
    Posts:
    54
    Great, thank you !
     
  44. zephyr831125

    zephyr831125

    Joined:
    Mar 4, 2017
    Posts:
    54
    Hi, another question, my current working project is hybrid ECS based. Is AI Planner working well on it?
    I am learning the otto example, it seems DomainProviders register GameObjects to WorldDomainManager, but ECS World is not GameObject based.
     
    eterlan and laurentlavigne like this.
  45. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    Is there a tutorial for this?
     
    sordidlist likes this.
  46. DreamersINC

    DreamersINC

    Joined:
    Mar 4, 2015
    Posts:
    131
    Is it plan for allowing action to be used by multiple different agents without using inheritance ?
     
    mplantady_unity likes this.
  47. mplantady_unity

    mplantady_unity

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    49
    We focused our effort on GameObject based workflow for now, but we will provide dedicated class to implement Entity-based project in the future.
    You should be able to provide object to the planner manually by rewriting some of the utility class in the meantime, but it hasn't been fully tested.
     
  48. mplantady_unity

    mplantady_unity

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    49
    We will release a more flexible workflow in the coming weeks that will allow more reusability and let developers choose how they want to implement the operational side of a plan.
     
    Djayp likes this.
  49. mplantady_unity

    mplantady_unity

    Unity Technologies

    Joined:
    Jun 19, 2019
    Posts:
    49
    Only the documentation is available currently. What type of tutorial would you be interested more ?
     
  50. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    The documentation and Otto project are very helpful resources, but it might be helpful (just speaking for myself at least) to see someone go through the process of setting up something simple like Otto from the ground up, maybe in a video. Certainly there is a lot of code written for the operational actions which would be tedious to watch someone type out, but if there could just be a "here is where I started, here is what I did next and why, here are some things to keep in mind" type video, that would be very useful to me. All that said, I know that AI Planner is still in flux so it might be asking for trouble to make anything quite that concrete at this point.

    I think the operational actions are where I struggle the most, simply because the ones with Otto are a little bit intricate. Maybe a better compromise would be more detail about operational actions in general? Like a workflow for making them, or even just some best practices.

    Another suggestion might be making/publishing a different demo scene to illustrate a different use of the tool, though I fully admit that even a basic 2D demo with crude primitive shapes would probably take time that your team doesn't want to necessarily spend writing more example code that other users would invariably expect you to maintain.

    Or, here's another idea - maybe instead of one "here's how all of AI Planner works" video, maybe a short series of videos about each piece? Actions, agents, etc. Maybe each video shows a couple examples of using each component, and maybe there's a little summary in there about what code generation does and such for folks without formal CS backgrounds.

    In my own example, I'm trying to make a scene which isn't all that different from Otto, but for a few things:
    1. There are two agents instead of one
    2. Trying to experiment with using a lot of interactable items (traits), maybe closer to 30-40

    I'm particularly curious to know more about multi-agent systems, though I'm not sure if the tool is at that stage yet.
     
Thread Status:
Not open for further replies.