Exemplo n.º 1
0
    void Start()
    {
        _body            = GetComponent <ArticulationBody>();
        _parentBody      = _body.transform.parent.GetComponentInParent <ArticulationBody>();
        _debugController = FindObjectOfType <MarathonTestBedController>();
        _spawnableEnv    = GetComponentInParent <MLAgents.SpawnableEnv>();
        _mocapController = _spawnableEnv.GetComponentInChildren <MocapController>();
        var mocapBodyParts = _mocapController.GetComponentsInChildren <Rigidbody>().ToList();

        _target = mocapBodyParts.First(x => x.name == _body.name);
    }
Exemplo n.º 2
0
    public override void AgentReset()
    {
        if (!_hasLazyInitialized)
        {
            _decisionRequester  = GetComponent <DecisionRequester>();
            _debugController    = FindObjectOfType <MarathonTestBedController>();
            Time.fixedDeltaTime = FixedDeltaTime;
            _spawnableEnv       = GetComponentInParent <SpawnableEnv>();
            _mocapController    = _spawnableEnv.GetComponentInChildren <MocapController>();
            _mocapBodyParts     = _mocapController.GetComponentsInChildren <Rigidbody>().ToList();
            _bodyParts          = GetComponentsInChildren <ArticulationBody>().ToList();
            _dReConObservations = GetComponent <DReConObservations>();
            _dReConRewards      = GetComponent <DReConRewards>();
            var mocapController = _spawnableEnv.GetComponentInChildren <MocapController>();
            _trackBodyStatesInWorldSpace = mocapController.GetComponent <TrackBodyStatesInWorldSpace>();
            _ragDollSettings             = GetComponent <RagDoll003>();
            _inputController             = _spawnableEnv.GetComponentInChildren <InputController>();
            _sensorObservations          = GetComponent <SensorObservations>();

            foreach (var body in GetComponentsInChildren <ArticulationBody>())
            {
                body.solverIterations         = 255;
                body.solverVelocityIterations = 255;
            }

            _motors = GetComponentsInChildren <ArticulationBody>()
                      .Where(x => x.jointType == ArticulationJointType.SphericalJoint)
                      .Where(x => !x.isRoot)
                      .Distinct()
                      .ToList();
            var individualMotors = new List <float>();
            foreach (var m in _motors)
            {
                if (m.twistLock == ArticulationDofLock.LimitedMotion)
                {
                    individualMotors.Add(0f);
                }
                if (m.swingYLock == ArticulationDofLock.LimitedMotion)
                {
                    individualMotors.Add(0f);
                }
                if (m.swingZLock == ArticulationDofLock.LimitedMotion)
                {
                    individualMotors.Add(0f);
                }
            }
            _dReConObservations.PreviousActions = individualMotors.ToArray();
            _hasLazyInitialized = true;
        }
        _smoothedActions = null;
        debugCopyMocap   = false;
        _inputController.OnReset();
        _mocapController.GetComponentInChildren <MocapAnimatorController>().OnReset();
        var angle    = Vector3.SignedAngle(Vector3.forward, _inputController.HorizontalDirection, Vector3.up);
        var rotation = Quaternion.Euler(0f, angle, 0f);

        _mocapController.OnReset(rotation);
        _mocapController.CopyStatesTo(this.gameObject);
        // _trackBodyStatesInWorldSpace.CopyStatesTo(this.gameObject);
        float timeDelta = float.MinValue;

        _dReConObservations.OnReset();
        _dReConRewards.OnReset();
        _dReConObservations.OnStep(timeDelta);
        _dReConRewards.OnStep(timeDelta);
        _skipRewardAfterTeleport = false;
#if UNITY_EDITOR
        if (DebugPauseOnReset)
        {
            UnityEditor.EditorApplication.isPaused = true;
        }
#endif
    }