Ejemplo n.º 1
0
        public override void CollectObservations(VectorSensor sensor)
        {
            sensor.AddObservation(m_PrevActions);
            sensor.AddObservation(Health * 2 - 1);

            var v = Normalization.Sigmoid(m_Walker.LocalVelocity);

            sensor.AddObservation(v.x);
            sensor.AddObservation(v.z);
        }
Ejemplo n.º 2
0
        public override void CollectObservations(VectorSensor sensor)
        {
            Info.Position = transform.position;
            Info.Forward  = transform.forward;
            road.UpdateInfo(Info);

            if (Info.IsOffRoad)
            {
                AddReward(Mathf.Abs(Info.Deviation) * -offRoadPenaltyFactor);
            }
            else
            {
                AddReward(Vector3.Dot(Info.Frame.Forward, physics.Velocity) * speedRewardFactor);
            }

            sensor.AddObservation(Info.Angle / 180f);
            sensor.AddObservation(Mathf.Clamp(Info.Deviation * 0.2f, -1f, 1f));
            sensor.AddObservation(physics.Inclination3);
            Vector3 v = physics.Localize(physics.Velocity);

            sensor.AddObservation(Normalization.Sigmoid(v.x));
            sensor.AddObservation(Normalization.Sigmoid(v.y));
            // Forward Speed: 0 - 25 m/s => 0 - 90 km/h
            // http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiJzcXJ0KHgqMC4wNCkqMi0xIiwiY29sb3IiOiIjMDAwMDAwIn0seyJ0eXBlIjoxMDAwLCJ3aW5kb3ciOlsiLTI1LjA2MzAwMTE5MjUzMjk2NSIsIjExNy45ODgxNDYyNjg0MDQzOSIsIi01LjgzMzQzOTgyNjk2NTMyMyIsIjguNDcxNjc0OTE5MTI4NDA3Il19XQ--
            sensor.AddObservation(Mathf.Min(Mathf.Sqrt(Mathf.Max(v.z, 0f) * 0.04f) * 2f - 1f, 1f));
            sensor.AddObservation(Normalization.Sigmoid(physics.AngularVelocity));

            sensor.AddObservation(physics.WheelR.NormMotorTorque);
            sensor.AddObservation(physics.WheelF.NormSteer);
            sensor.AddObservation(physics.WheelR.NormBrakeTorque);
            sensor.AddObservation(physics.WheelF.NormBrakeTorque);
            sensor.AddObservation(physics.WheelR.GetHeightAboveGround());
            sensor.AddObservation(physics.WheelF.GetHeightAboveGround());

            Vector3 origin = GetRayOrigin();

            foreach (int i in lookAhead)
            {
                Vector3 p = road.GetFrame(Info.Frame.Index + i).Position;
                sensor.AddObservation((p - origin).normalized);
                Debug.DrawRay(p, Vector3.up, Color.white);
            }

            foreach (float distance in rayObs)
            {
                // Buffered
                sensor.AddObservation(distance);
            }
            CastRays(origin);
            foreach (float distance in rayObs)
            {
                // Current
                sensor.AddObservation(distance);
            }
        }
Ejemplo n.º 3
0
        public override void CollectObservations(VectorSensor sensor)
        {
            sensor.AddObservation(multicopter.Inclination);
            sensor.AddObservation(Normalization.Sigmoid(
                                      multicopter.LocalizeVector(multicopter.Rigidbody.velocity), 0.25f));
            sensor.AddObservation(Normalization.Sigmoid(
                                      multicopter.LocalizeVector(multicopter.Rigidbody.angularVelocity)));

            foreach (var rotor in multicopter.Rotors)
            {
                sensor.AddObservation(rotor.CurrentThrust);
            }
        }