Пример #1
0
    public override void generatePredecesors(ref DefaultState DcurrentState, ref DefaultState DpreviousState,
                                             ref DefaultState DidealGoalState, ref List <DefaultAction> transitions)
    {
        FootstepPlanningState currentState   = DcurrentState as FootstepPlanningState;
        FootstepPlanningState idealGoalState = DidealGoalState as FootstepPlanningState;
        FootstepPlanningState previousState  = DpreviousState as FootstepPlanningState;

        float timeLeft   = idealGoalState.time - currentState.time;
        float timeWindow = window * analyzer.maxActionDuration;

        // If there is no time left
        if (timeLeft + timeWindow < 0)
        {
            //We don't generate transitions
            return;
        }

        AnotatedAnimation preconditions = currentState.preconditions;

        float meanStepSize = analyzer.meanStepSize;

        foreach (AnotatedAnimation anim in analyzer.analyzedAnimations.Values)
        {
            float minAnimSpeed = 0.0f;
            float maxAnimSpeed = 1.0f;

            float animSpeedIncr = 0.1f;

            minAnimSpeed = 1.0f; maxAnimSpeed = 1.0f;

            FootstepPlanningAction newAction = new FootstepPlanningAction(previousState, anim, minAnimSpeed, meanStepSize, 0.0f);
            if (newAction.state != null)
            {
                if (newAction.SatisfiesPreconditions(preconditions))
                {
                    if (!CheckStateCollisions(newAction.state))
                    {
                        transitions.Add(newAction);
                    }

                    // and we generate the other actions using the same animation but at different speeds
                    for (float animSpeed = minAnimSpeed + animSpeedIncr; animSpeed <= maxAnimSpeed; animSpeed += animSpeedIncr)
                    {
                        newAction = new FootstepPlanningAction(previousState, anim, animSpeed, meanStepSize, 0.0f);

                        if (!CheckStateCollisions(newAction.state))
                        {
                            transitions.Add(newAction);
                        }
                    }
                }
            }
        }
    }
Пример #2
0
    public override void generateTransitions(ref DefaultState DcurrentState, ref DefaultState DpreviousState,
	                                ref DefaultState DidealGoalState, ref List<DefaultAction> transitions)
    {
        FootstepPlanningState currentState = DcurrentState as FootstepPlanningState;
        //		FootstepPlanningState previousState = DpreviousState as FootstepPlanningState;
        FootstepPlanningState idealGoalState = DidealGoalState as FootstepPlanningState;

        float timeLeft = idealGoalState.time - currentState.time;
        float timeWindow = window*analyzer.maxActionDuration;

        // If there is no time left
        if ( timeLeft + timeWindow < 0 )
        {
            //We don't generate transitions
            return;
        }

        //Debug.Log("Calling my generation");

        // The next action preconditions
        AnotatedAnimation preconditions = currentState.preconditions;

        float meanStepSize = analyzer.meanStepSize;
        float mass = analyzer.mass;

        // The added transitions
        //int count = 0;

        /*
        //string[] names = {"WalkRightSlow","WalkRightSlow2","WalkNormal","WalkNormal2","WalkFast","WalkFast2","WalkLeft","WalkLeft2","WalkRight","WalkRight2","LeftStep","RightStep"};
        string[] names = {
            "WalkFast","WalkFast2","WalkNormal","WalkNormal2","WalkLeft","WalkLeft2","WalkRight","WalkRight2","LeftStep"
            ,"RightStep","WalkLeftSlow","WalkLeftSlow2","WalkRightSlow","WalkRightSlow2"
            ,"RightStepSlow","LeftStepSlow","WalkSlow","WalkSlow2"
            ,"TurnRight360","TurnLeft360"
            ,"WalkTurnLeft","WalkTurnLeft2"
            "WalkTurnRight","WalkTurnRight2"
            ,"WalkSlowest","WalkSlowest2"
            ,"Idle"
        };

        AnotatedAnimation[] anims = new AnotatedAnimation[names.Length];
        int aux=0;
        foreach (string name in names)
        {
            anims[aux] = analyzer.GetAnotatedAnimation(name);
            aux++;
        }
        */

        // For each possible animation
        foreach( AnotatedAnimation anim in analyzer.analyzedAnimations.Values)
        //foreach (AnotatedAnimation anim in anims)
        {
            // We compute the min and max possible speed of the animation
            // (depending on the previous state, the current state and the velocity of the new animation)
            float minAnimSpeed = 0.0f;
            float maxAnimSpeed = 1.0f;
            //ComputeMinAndMaxAnimSpeeds(currentState,previousState,anim.speed,ref minAnimSpeed,ref maxAnimSpeed);
            float animSpeedIncr = 0.1f;

            //minAnimSpeed = 0.2f; maxAnimSpeed = 1.0f; animSpeedIncr = 0.2f;
            minAnimSpeed = 1.0f; maxAnimSpeed = 1.0f;
            //minAnimSpeed = 0.5f; maxAnimSpeed = 0.5f;

            //int animCount = 0;

            //Debug.Log("Transitions: currentState.time = "+currentState.time+" realTime = "+Time.realtimeSinceStartup);

            // we check the preconditions of that action
            FootstepPlanningAction newAction = new FootstepPlanningAction(currentState,anim,minAnimSpeed,meanStepSize,mass);
            if (newAction.state != null)
            {
                if ( newAction.SatisfiesPreconditions(preconditions) )
                {

                    if (!CheckStateCollisions(newAction.state))
                        transitions.Add(newAction);
                    //count++;
                    //animCount++;

                    // and we generate the other actions using the same animation but at different speeds
                    for (float animSpeed = minAnimSpeed + animSpeedIncr; animSpeed <= maxAnimSpeed; animSpeed += animSpeedIncr)
                    {
                        newAction = new FootstepPlanningAction(currentState,anim,animSpeed,meanStepSize,mass);
                        //transitions.Insert(count,newAction);

                        if (!CheckStateCollisions(newAction.state))
                            transitions.Add(newAction);
                        //count++;

                        //animCount++;
                    }

                }
            }
            //Debug.Log("Animation " + anim.name + " transitions = " + animCount);

            //if (transitions.Count == 0)
            //	Debug.Log("No transitions!");

        }
    }
Пример #3
0
    override public void generateTransitions(ref DefaultState DcurrentState, ref DefaultState DpreviousState,
                                             ref DefaultState DidealGoalState, ref List <DefaultAction> transitions)
    {
        FootstepPlanningState currentState = DcurrentState as FootstepPlanningState;
//		FootstepPlanningState previousState = DpreviousState as FootstepPlanningState;
        FootstepPlanningState idealGoalState = DidealGoalState as FootstepPlanningState;

        float timeLeft   = idealGoalState.time - currentState.time;
        float timeWindow = window * analyzer.maxActionDuration;

        // If there is no time left
        if (timeLeft + timeWindow < 0)
        {
            //We don't generate transitions
            return;
        }

        //Debug.Log("Calling my generation");

        // The next action preconditions
        AnotatedAnimation preconditions = currentState.preconditions;

        float meanStepSize = analyzer.meanStepSize;
        float mass         = analyzer.mass;

        // The added transitions
        //int count = 0;

        /*
         * //string[] names = {"WalkRightSlow","WalkRightSlow2","WalkNormal","WalkNormal2","WalkFast","WalkFast2","WalkLeft","WalkLeft2","WalkRight","WalkRight2","LeftStep","RightStep"};
         * string[] names = {
         *      "WalkFast","WalkFast2","WalkNormal","WalkNormal2","WalkLeft","WalkLeft2","WalkRight","WalkRight2","LeftStep"
         *      ,"RightStep","WalkLeftSlow","WalkLeftSlow2","WalkRightSlow","WalkRightSlow2"
         *      ,"RightStepSlow","LeftStepSlow","WalkSlow","WalkSlow2"
         *      ,"TurnRight360","TurnLeft360"
         *      ,"WalkTurnLeft","WalkTurnLeft2"
         *      "WalkTurnRight","WalkTurnRight2"
         *      ,"WalkSlowest","WalkSlowest2"
         *      ,"Idle"
         * };
         *
         * AnotatedAnimation[] anims = new AnotatedAnimation[names.Length];
         * int aux=0;
         * foreach (string name in names)
         * {
         *      anims[aux] = analyzer.GetAnotatedAnimation(name);
         *      aux++;
         * }
         */

        // For each possible animation
        foreach (AnotatedAnimation anim in analyzer.analyzedAnimations.Values)
        //foreach (AnotatedAnimation anim in anims)
        {
            // We compute the min and max possible speed of the animation
            // (depending on the previous state, the current state and the velocity of the new animation)
            float minAnimSpeed = 0.0f;
            float maxAnimSpeed = 1.0f;
            //ComputeMinAndMaxAnimSpeeds(currentState,previousState,anim.speed,ref minAnimSpeed,ref maxAnimSpeed);
            float animSpeedIncr = 0.1f;

            //minAnimSpeed = 0.2f; maxAnimSpeed = 1.0f; animSpeedIncr = 0.2f;
            minAnimSpeed = 1.0f; maxAnimSpeed = 1.0f;
            //minAnimSpeed = 0.5f; maxAnimSpeed = 0.5f;

            //int animCount = 0;

            //Debug.Log("Transitions: currentState.time = "+currentState.time+" realTime = "+Time.realtimeSinceStartup);

            // we check the preconditions of that action
            FootstepPlanningAction newAction = new FootstepPlanningAction(currentState, anim, minAnimSpeed, meanStepSize, mass);
            if (newAction.state != null)
            {
                if (newAction.SatisfiesPreconditions(preconditions))
                {
                    if (!CheckStateCollisions(newAction.state))
                    {
                        transitions.Add(newAction);
                    }
                    //count++;
                    //animCount++;

                    // and we generate the other actions using the same animation but at different speeds
                    for (float animSpeed = minAnimSpeed + animSpeedIncr; animSpeed <= maxAnimSpeed; animSpeed += animSpeedIncr)
                    {
                        newAction = new FootstepPlanningAction(currentState, anim, animSpeed, meanStepSize, mass);
                        //transitions.Insert(count,newAction);

                        if (!CheckStateCollisions(newAction.state))
                        {
                            transitions.Add(newAction);
                        }
                        //count++;

                        //animCount++;
                    }
                }
            }
            //Debug.Log("Animation " + anim.name + " transitions = " + animCount);

            //if (transitions.Count == 0)
            //	Debug.Log("No transitions!");
        }
    }
Пример #4
0
    public override void generatePredecesors(ref DefaultState DcurrentState, ref DefaultState DpreviousState, 
	                                          ref DefaultState DidealGoalState, ref List<DefaultAction> transitions)
    {
        FootstepPlanningState currentState =  DcurrentState as FootstepPlanningState;
        FootstepPlanningState idealGoalState = DidealGoalState as FootstepPlanningState;
        FootstepPlanningState previousState = DpreviousState as FootstepPlanningState;

        float timeLeft = idealGoalState.time - currentState.time;
        float timeWindow = window*analyzer.maxActionDuration;

        // If there is no time left
        if ( timeLeft + timeWindow < 0 )
        {
            //We don't generate transitions
            return;
        }

        AnotatedAnimation preconditions = currentState.preconditions;

        float meanStepSize = analyzer.meanStepSize;

        foreach( AnotatedAnimation anim in analyzer.analyzedAnimations.Values)
        {
            float minAnimSpeed = 0.0f;
            float maxAnimSpeed = 1.0f;

            float animSpeedIncr = 0.1f;

            minAnimSpeed = 1.0f; maxAnimSpeed = 1.0f;

            FootstepPlanningAction newAction = new FootstepPlanningAction(previousState,anim,minAnimSpeed,meanStepSize, 0.0f);
            if (newAction.state != null)
            {
                if ( newAction.SatisfiesPreconditions(preconditions) )
                {

                    if (!CheckStateCollisions(newAction.state))
                        transitions.Add(newAction);

                    // and we generate the other actions using the same animation but at different speeds
                    for (float animSpeed = minAnimSpeed + animSpeedIncr; animSpeed <= maxAnimSpeed; animSpeed += animSpeedIncr)
                    {
                        newAction = new FootstepPlanningAction(previousState,anim,animSpeed,meanStepSize, 0.0f);

                        if (!CheckStateCollisions(newAction.state))
                            transitions.Add(newAction);

                    }

                }
            }
        }
    }