public IEnumerator ProperReset()
        {
            string[] tags   = { k_Tag1 };
            int[]    depths = { 5, 1, 3 };
            dummyData.Data = new[] { 3f, .6f, 2.2f };
            Color[] colors = { Color.red, Color.magenta };
            gridSensor.SetParameters(tags, depths, GridSensor.GridDepthType.Channel,
                                     1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            gridSensor.Start();

            yield return(null);

            float[] output = gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 3, output.Length);

            int[]     subarrayIndicies  = new int[] { 77, 78, 87, 88 };
            float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new[] { 3f / 5f, .6f, 2.2f / 3f }, 4);
            float[]   expectedDefault   = new float[] { 0, 0, 0 };
            GridObsTestUtils.AssertSubarraysAtIndex(output, subarrayIndicies, expectedSubarrays, expectedDefault);

            Object.DestroyImmediate(boxGo);

            yield return(null);

            output = gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 3, output.Length);

            subarrayIndicies  = new int[0];
            expectedSubarrays = new float[0][];
            GridObsTestUtils.AssertSubarraysAtIndex(output, subarrayIndicies, expectedSubarrays, expectedDefault);
        }
        public IEnumerator ProperReset()
        {
            string[] tags   = { k_Tag1 };
            int[]    depths = { 5, 1, 3 };
            dummyData.Data = new[] { 3f, .6f, 2.2f };
            Color[] colors = { Color.red, Color.magenta };
            GridObsTestUtils.SetComponentParameters(gridSensorComponent, tags, depths, GridDepthType.ChannelHot,
                                                    1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            var gridSensor = (GridSensor)gridSensorComponent.CreateSensors()[0];

            yield return(null);

            gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 9, gridSensor.m_PerceptionBuffer.Length);

            int[]     subarrayIndicies  = new int[] { 77, 78, 87, 88 };
            float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new[] { 0, 0, 0, 1, 0, .6f, 0, 0, 1 }, 4);
            float[]   expectedDefault   = new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            GridObsTestUtils.AssertSubarraysAtIndex(gridSensor.m_PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault);

            Object.DestroyImmediate(boxGo);

            yield return(null);

            gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 9, gridSensor.m_PerceptionBuffer.Length);

            subarrayIndicies  = new int[0];
            expectedSubarrays = new float[0][];
            GridObsTestUtils.AssertSubarraysAtIndex(gridSensor.m_PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault);
        }
Beispiel #3
0
        public IEnumerator OneChannelDepthOneCount()
        {
            string[] tags   = { k_Tag1 };
            int[]    depths = { 1 };
            Color[]  colors = { Color.red, Color.magenta };
            gridSensor.SetParameters(tags, depths, GridSensor.GridDepthType.Channel,
                                     1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            gridSensor.Start();

            yield return(null);

            float[] output = gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 1, output.Length);

            int[]     subarrayIndicies  = new int[] { 77, 78, 87, 88 };
            float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new float[] { 1f }, 4);
            float[]   expectedDefault   = new float[] { 0 };
            GridObsTestUtils.AssertSubarraysAtIndex(output, subarrayIndicies, expectedSubarrays, expectedDefault);
        }
        public IEnumerator OneChannelDepthOneCount()
        {
            string[] tags   = { k_Tag1 };
            int[]    depths = { 1 };
            Color[]  colors = { Color.red, Color.magenta };
            GridObsTestUtils.SetComponentParameters(gridSensorComponent, tags, depths, GridDepthType.Counting,
                                                    1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            var gridSensor = (GridSensor)gridSensorComponent.CreateSensors()[0];

            yield return(null);

            gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 1, gridSensor.m_PerceptionBuffer.Length);

            int[]     subarrayIndicies  = new int[] { 77, 78, 87, 88 };
            float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new[] { 1f }, 4);
            float[]   expectedDefault   = new float[] { 0 };
            GridObsTestUtils.AssertSubarraysAtIndex(gridSensor.m_PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault);
        }
Beispiel #5
0
        public IEnumerator ThreeChannelDepthFiveOneThreeGoodValues()
        {
            string[] tags   = { k_Tag1 };
            int[]    depths = { 5, 1, 3 };
            dummyData.Data = new[] { 3f, .6f, 2.2f };
            Color[] colors = { Color.red, Color.magenta };
            gridSensor.SetParameters(tags, depths, GridSensor.GridDepthType.ChannelHot,
                                     1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            gridSensor.Start();

            yield return(null);

            float[] output = gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 9, output.Length);

            int[]     subarrayIndicies  = new int[] { 77, 78, 87, 88 };
            float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new[] { 0, 0, 0, 1, 0, .6f, 0, 0, 1 }, 4);
            float[]   expectedDefault   = new float[] { 1, 0, 0, 0, 0, 0, 1, 0, 0 };
            GridObsTestUtils.AssertSubarraysAtIndex(output, subarrayIndicies, expectedSubarrays, expectedDefault);
        }
Beispiel #6
0
        public IEnumerator TwoChannelDepthFourCount()
        {
            string[] tags   = { k_Tag1, k_Tag2 };
            int[]    depths = { 4, 1 };
            Color[]  colors = { Color.red, Color.magenta };
            gridSensor.SetParameters(tags, depths, GridSensor.GridDepthType.Channel,
                                     1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            gridSensor.Start();

            boxGoTwo   = CreateBlock(new Vector3(3.1f, 0f, 3.1f), k_Tag1, "box2");
            boxGoThree = CreateBlock(new Vector3(2.9f, 0f, 2.9f), k_Tag2, "box2");

            yield return(null);

            float[] output = gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 2, output.Length);

            int[]     subarrayIndicies  = new int[] { 77, 78, 87, 88 };
            float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new float[] { .5f, 1 }, 4);
            float[]   expectedDefault   = new float[] { 0, 0 };
            GridObsTestUtils.AssertSubarraysAtIndex(output, subarrayIndicies, expectedSubarrays, expectedDefault);
        }