Ejemplo n.º 1
0
    public CylinderMap GetCylinderMap(Frame frame, bool mirrored)
    {
        CylinderMap sensor = new CylinderMap(Size, Resolution, Layers, Overlap);
        RootModule  module = (RootModule)Data.GetModule(ID.Root);

        if (module != null)
        {
            Vector3    position = module.GetRootPosition(frame, mirrored);
            Quaternion rotation = module.GetRootRotation(frame, mirrored);
            sensor.Sense(Matrix4x4.TRS(position + new Vector3(0f, 0f, 0f), rotation, Vector3.one), Mask);
        }
        else
        {
            sensor.Sense(frame.GetBoneTransformation(0, mirrored), Mask);
        }
        Samples = sensor.Points.Length;
        return(sensor);
    }
Ejemplo n.º 2
0
    protected override void Feed()
    {
        Controller.Update();

        //Get Root
        Matrix4x4 root = RootSeries.Transformations[TimeSeries.Pivot];

        //Control Cycle
        Signals        = Controller.PoolSignals();
        UserControl    = Controller.PoolUserControl(Signals);
        NetworkControl = Controller.PoolNetworkControl(Signals);

        if (IsInteracting)
        {
            //Do nothing because coroutines have control.
        }
        else if (Controller.QuerySignal("Sit"))
        {
            StartCoroutine(Sit());
        }
        else if (Controller.QuerySignal("Carry"))
        {
            StartCoroutine(Carry());
        }
        else if (Controller.QuerySignal("Open"))
        {
            StartCoroutine(Open());
        }
        else
        {
            Default();
        }

        //Input Bone Positions / Velocities
        for (int i = 0; i < Actor.Bones.Length; i++)
        {
            NeuralNetwork.Feed(Actor.Bones[i].Transform.position.GetRelativePositionTo(root));
            NeuralNetwork.Feed(Actor.Bones[i].Transform.forward.GetRelativeDirectionTo(root));
            NeuralNetwork.Feed(Actor.Bones[i].Transform.up.GetRelativeDirectionTo(root));
            NeuralNetwork.Feed(Actor.Bones[i].Velocity.GetRelativeDirectionTo(root));
        }

        //Input Trajectory Positions / Directions / Velocities / Styles
        for (int i = 0; i < TimeSeries.KeyCount; i++)
        {
            TimeSeries.Sample sample = TimeSeries.GetKey(i);
            NeuralNetwork.FeedXZ(RootSeries.GetPosition(sample.Index).GetRelativePositionTo(root));
            NeuralNetwork.FeedXZ(RootSeries.GetDirection(sample.Index).GetRelativeDirectionTo(root));
            NeuralNetwork.Feed(StyleSeries.Values[sample.Index]);
        }

        //Input Goals
        for (int i = 0; i < TimeSeries.KeyCount; i++)
        {
            TimeSeries.Sample sample = TimeSeries.GetKey(i);
            NeuralNetwork.Feed(GoalSeries.Transformations[sample.Index].GetPosition().GetRelativePositionTo(root));
            NeuralNetwork.Feed(GoalSeries.Transformations[sample.Index].GetForward().GetRelativeDirectionTo(root));
            NeuralNetwork.Feed(GoalSeries.Values[sample.Index]);
        }

        //Input Environment
        Environment.Sense(root, LayerMask.GetMask("Default", "Interaction"));
        NeuralNetwork.Feed(Environment.Occupancies);

        //Input Geometry
        for (int i = 0; i < Geometry.Points.Length; i++)
        {
            NeuralNetwork.Feed(Geometry.References[i].GetRelativePositionTo(root));
            NeuralNetwork.Feed(Geometry.Occupancies[i]);
        }

        //Setup Gating Features
        NeuralNetwork.Feed(GenerateGating());
    }