Now, I wrote my own grid sensor a while back, because I wanted a minimal solution that does nothing more than encoding float values as visual observations. The plan was to later extend it for specific use cases. One such extension is the Spatial Grid Sensor, it detects colliders via OverlapSphere and projects their polar coordinates onto the observed grid.
I haven’t done any extensive testing yet, like comparing how well the sensor does compared to using a ton of raycasts. However, if you want to check it out, you can find the code, description and two example projects here: GitHub - mbaske/grid-sensor: Grid Sensor Components for Unity ML-Agents
I also added a comparison with the Eidos grid sensor. It’s apples and oranges, really. My sensor uses a different detection approach, which was designed for 3D and is probably a bit overkill for 2D. It’s faster though
Hi I am trying to use your scripts to make a grid sensor. I have done everything as done in your DogFight scene, but I am getting the following error-
ArgumentNullException: Value cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary2[TKey,TValue].FindEntry (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0) System.Collections.Generic.Dictionary2[TKey,TValue].TryGetValue (TKey key, TValue& value) (at <695d1cc93cca45069c528c15c9fdd749>:0)
MBaske.Sensors.Grid.DetectionResult.TryGetItems (System.String tag, System.Collections.Generic.IList`1[MBaske.Sensors.Grid.DetectionResult+Item]& items) (at Assets/Scripts/Sensors/Grid/Basic/Detection/DetectionResult.cs:109)
MBaske.Sensors.Grid.GridSensorComponentBaseGO+d__22.MoveNext () (at Assets/Scripts/Sensors/Grid/GameObject/Sensor/GridSensorComponentBaseGO.cs:165)
SimpleInputControls.CollectObservations (Unity.MLAgents.Sensors.VectorSensor sensor) (at Assets/SimpleInputControls.cs:104)
Please let me know if you have any solution else let me know what other details you will require to solve this. P.S. - The error takes me here-
Hi @mohdafzal20299
I haven’t looked at this for a while… just did a clean install of Unity Editor 2021.3.151f (Windows), cloned my grid-sensor repo, re-imported the three items in /Examples/!Reimport/ folder and things look ok. I can run the example scenes without any issues.
From the error you’re getting, it looks like the ‘tag’ argument is null, causing the exception when trying to look up an associated dictionary item. Not sure where that null tag might come from though… Could you check your detectable gameobjects have valid tags and sensor settings are referencing them?