Пример #1
0
        public static VehicleControlData ConvertTo(Lgsvl.VehicleControlDataRos data)
        {
            float Deg2Rad          = UnityEngine.Mathf.Deg2Rad;
            float MaxSteeringAngle = 29f * Deg2Rad; //ADASTEC
            float wheelAngle       = 0f;

            if (data.target_wheel_angle > MaxSteeringAngle)
            {
                wheelAngle = MaxSteeringAngle;
            }
            else if (data.target_wheel_angle < -MaxSteeringAngle)
            {
                wheelAngle = -MaxSteeringAngle;
            }

            // ratio between -MaxSteeringAngle and MaxSteeringAngle
            var k = (float)(wheelAngle + MaxSteeringAngle) / (MaxSteeringAngle * 2);

            // target_wheel_angular_rate, target_gear are not supported on simulator side.
            return(new VehicleControlData()
            {
                Acceleration = data.acceleration_pct,
                Braking = data.braking_pct,
                SteerAngle = UnityEngine.Mathf.Lerp(-1f, 1f, k),
            });
        }
Пример #2
0
 public static VehicleControlData ConvertTo(Lgsvl.VehicleControlDataRos data)
 {
     // target_gear are not supported on simulator side
     return(new VehicleControlData()
     {
         Acceleration = data.acceleration_pct,
         Braking = data.braking_pct,
         SteerAngle = data.target_wheel_angle * UnityEngine.Mathf.Rad2Deg,
     });
 }