Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question about Eidos-Montréal's Grid Sensors:

Discussion in 'ML-Agents' started by dmix101, Mar 11, 2021.

  1. dmix101

    dmix101

    Joined:
    Oct 22, 2020
    Posts:
    6
    1. Where do you override the GetObjectData method? I tried to override it in my agent script (the script where you would also override OnActionReceived, Heuristic etc), but I get a error saying No suitable method found to overide.

    2. Also does the grid sensor automatically pass in the normalizedDistance in the Channel Matrix along with the object type, or do we have to pass that in separately when I override the OnActionReceived method?

    3. Also is there a way to not make the grid move with the Agent? I am making a Pacman AI, so I am using a grid sensor I want to get a top down view of the map.

    4. Lastly, what happens if multiple objects are in the same grid square? For example, what would happen if a food object and a enemy object was in the same grid square? Which would get detected, or will none of them get detected?

    Thank you for taking your time out and reading my questions!
     
    Last edited: Mar 11, 2021
  2. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    You need to create a subclass of GridSesnsor and override the method there.

    Grid Sensor will send its observation data to the training process / neural network itself. You don't need to do this.

    No, this is a feature we are considering implementing but haven't put it on our roadmap yet.

    Both will get detected.
     
  3. dmix101

    dmix101

    Joined:
    Oct 22, 2020
    Posts:
    6
    Thank You very much!
    Follow up questions, (these are all probably simple questions:

    1: On the grid sensor, I have the "show gizmos setting enabled" and when I change the "Grid Num Side X" and "Grid Num Side Y" the gizmo moves to a different position. So how do I fix that. If I keep "Grid Num Side X" and "Grid Num Side Y" to 16x16 ( the default), the gizmo is actually in the correct position. But when I change the "Grid Num Side X" and "Grid Num Side Y", the gizmo moves to another position.

    2: Is it possible to use Vector Observations and Grid Sensors at the same time to collect observations?

    3. If I do not override GetObjectData method, will the grid sensor automatically pass in the type of object it detected and how far it is away (normalizedDistance)?

    4. Any other things to keep in mind when using a Grid Sensor. (It is my first time using it!)

     
    Last edited: Mar 13, 2021
  4. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    I haven't seen this, can you send an image? Thanks.

    Yes, just be sure to set up your BehaviorParameters component correctly to reflect the amount of observations you want to make in CollectObservations.

    The grid sensor will encode the objects it detected based on the DetectableObjects you have setup on the component. The normalized distance is passed into the GetObjectData method but is not stored anywhere. You would need to override that method in order to access the normalized distance.

    The grid sensor allocates a lot of memory during training and is generally a CPU hog. It does a lot of physics queries (NumSideX * NumSideZ) Boxoverlap queries per frame. You want to make your grid as small as possible while still being useful for your agent.

    Hope that helps.
     
  5. dmix101

    dmix101

    Joined:
    Oct 22, 2020
    Posts:
    6
    Thank you for responding!
    For question that you asked an Image for... Question 1:
    -I fixed the problem. It turns out the grid has to be a square. I was trying to make it a rectangle (16x9) but the grid has to be a sqaure.

    Another Question
    1: What do you recommend I set the vis_encode_type parameter to, in my config file? I am making a agent that can play and beat Pacman. So what do you recommend the vis_encode_type to be for the quickest training time?
    2: How long do you think it will take to train the AI using grid sensor. I understand that you might not be able to give the exact number, but I am just looking for a proper estimate.

    Thank You for responding to all my previous questions as well.

     
  6. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    I’ve just used “simple” and it’s worked fine


    I have no idea :) if I knew I’d probably be doing talks about it at AI conferences. Could be a day, less than a day, more than a day. Really depends on how your environment is setup and how hard the problem is to solve.
    I could take a wild guess and say if you set up everything correctly it might take a day or less. But again, there are a lot of assumptions built into that very non-committal statement.
     
  7. dmix101

    dmix101

    Joined:
    Oct 22, 2020
    Posts:
    6
    Hey! Thanks for responding!
    Do you know if a Grid Sensors can work Headlessly, so I can speed up training time. I know that Vector Observations can work Headlessly, but Camera Sensors can not work Headlessly. So can Grid Sensors work Headlessly since they do not use a Camera Sensor?
     
  8. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hi @dmix101,
    Grid sensors should work headless since they are taking vector observations and turning them into PNGs without the use of a Camera. Please let me know if you run into issues with that.
    Cheers,
    Chris