Search Unity

AI Planner - v0.1.1-preview Release!

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

  1. TrevorUnity

    TrevorUnity

    Unity Technologies

    Joined:
    Jun 28, 2017
    Posts:
    14
    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!
     
  2. alexchesser

    alexchesser

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

    vx4

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

    threedots1

    Joined:
    Oct 9, 2014
    Posts:
    26
    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:
    100
  6. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    183
    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

    Unity Technologies

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

    ice-ko

    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:
    183
    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

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    227
    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:
    183
    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

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    227
    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.
     
    vincismurf likes this.
  13. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    51

    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:
    183
    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:
    183
    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

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    227
    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. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    51
    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

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    227
    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:
    183
    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:
    14
    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:
    183
    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:
    100
    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:
    3
    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)
     
    vx4 and growling_egg like this.
  24. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    51
    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:
    183
    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:
    100
    Just to keep in mind.
    ContinueExecution() and EndExecution() mostly depend on return value from OperationalActionStatus Status(...)
     
    vincismurf likes this.
  27. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    51
    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:
    2
    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

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    227
    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

    Unity Technologies

    Joined:
    Aug 12, 2015
    Posts:
    227
    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:
    2


    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.