Rendering and environment improvements
This commit is contained in:
@@ -41,77 +41,7 @@ public class IdealSensor : Sensor
|
||||
|
||||
return positionSensorOutput;
|
||||
}
|
||||
|
||||
// protected override VelocityOutput SenseVelocity(Agent target)
|
||||
// {
|
||||
// VelocityOutput velocitySensorOutput = new VelocityOutput();
|
||||
|
||||
// // Calculate the relative position of the target with respect to the agent
|
||||
// Vector3 position = _agent.transform.position;
|
||||
// Vector3 targetPosition = target.transform.position;
|
||||
// Vector3 targetRelativePosition = targetPosition - position;
|
||||
|
||||
// // Calculate the relative velocity of the target with respect to the agent
|
||||
// Vector3 velocity = _agent.GetVelocity();
|
||||
// Vector3 targetVelocity = target.GetVelocity();
|
||||
// Vector3 targetRelativeVelocity = targetVelocity - velocity;
|
||||
|
||||
// // Project the relative velocity vector onto the relative position vector
|
||||
// Vector3 velocityProjectionOnRelativePosition = Vector3.Project(targetRelativeVelocity, targetRelativePosition);
|
||||
|
||||
// // Determine the sign of the range rate
|
||||
// float rangeRateSign = Vector3.Dot(velocityProjectionOnRelativePosition, targetRelativePosition) >= 0 ? 1 : -1;
|
||||
|
||||
// // Calculate the range rate
|
||||
// velocitySensorOutput.range = rangeRateSign * velocityProjectionOnRelativePosition.magnitude;
|
||||
|
||||
// // Project the relative velocity vector onto the sphere passing through the target
|
||||
// Vector3 velocityProjectionOnAzimuthElevationSphere = targetRelativeVelocity - velocityProjectionOnRelativePosition;
|
||||
|
||||
// // The target azimuth vector is orthogonal to the relative position vector and
|
||||
// // points to the starboard of the target along the azimuth-elevation sphere
|
||||
// Vector3 targetAzimuth = Vector3.Cross(targetRelativePosition, _agent.transform.forward).normalized;
|
||||
|
||||
// // The target elevation vector is orthogonal to the relative position vector
|
||||
// // and points upwards from the target along the azimuth-elevation sphere
|
||||
// Vector3 targetElevation = Vector3.Cross(targetAzimuth, targetRelativePosition).normalized;
|
||||
|
||||
// // If the relative position vector is parallel to the yaw or pitch axis, the
|
||||
// // target azimuth vector or the target elevation vector will be undefined
|
||||
// if (targetAzimuth.magnitude == 0)
|
||||
// {
|
||||
// // In this case, we can use the right vector as the azimuth
|
||||
// targetAzimuth = _agent.transform.right;
|
||||
// // And recalculate the elevation vector
|
||||
// targetElevation = Vector3.Cross(targetAzimuth, targetRelativePosition).normalized;
|
||||
// }
|
||||
|
||||
// else if (targetElevation.magnitude == 0)
|
||||
// {
|
||||
// targetElevation = Vector3.Cross(targetAzimuth, targetRelativePosition);
|
||||
// }
|
||||
|
||||
// // Project the relative velocity vector on the azimuth-elevation sphere onto the target azimuth vector
|
||||
// Vector3 velocityProjectionOnTargetAzimuth = Vector3.Project(velocityProjectionOnAzimuthElevationSphere, targetAzimuth);
|
||||
|
||||
// // Determine the sign of the azimuth velocity
|
||||
// float azimuthVelocitySign = Vector3.Dot(velocityProjectionOnTargetAzimuth, targetAzimuth) >= 0 ? 1 : -1;
|
||||
|
||||
// // Calculate the time derivative of the azimuth to the target
|
||||
// velocitySensorOutput.azimuth = azimuthVelocitySign * velocityProjectionOnTargetAzimuth.magnitude / targetRelativePosition.magnitude;
|
||||
|
||||
// // Project the velocity vector on the azimuth-elevation sphere onto the target elevation vector
|
||||
// Vector3 velocityProjectionOnTargetElevation = velocityProjectionOnAzimuthElevationSphere - velocityProjectionOnTargetAzimuth;
|
||||
|
||||
// // Determine the sign of the elevation velocity
|
||||
// float elevationVelocitySign = Vector3.Dot(velocityProjectionOnTargetElevation, targetElevation) >= 0 ? 1 : -1;
|
||||
|
||||
// // Calculate the time derivative of the elevation to the target
|
||||
// velocitySensorOutput.elevation = elevationVelocitySign * velocityProjectionOnTargetElevation.magnitude / targetRelativePosition.magnitude;
|
||||
|
||||
// return velocitySensorOutput;
|
||||
// }
|
||||
|
||||
|
||||
protected override VelocityOutput SenseVelocity(Agent target)
|
||||
{
|
||||
VelocityOutput velocitySensorOutput = new VelocityOutput();
|
||||
|
||||
@@ -9,10 +9,48 @@ public abstract class Sensor : MonoBehaviour
|
||||
_agent = GetComponent<Agent>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Main sensing method to gather information about a target agent.
|
||||
/// </summary>
|
||||
/// <param name="target">The agent to sense.</param>
|
||||
/// <returns>SensorOutput containing position and velocity data.</returns>
|
||||
/// <remarks>
|
||||
/// Implementers should:
|
||||
/// 1. Call SensePosition to get position data.
|
||||
/// 2. Call SenseVelocity to get velocity data.
|
||||
/// 3. Combine results into a SensorOutput struct.
|
||||
/// </remarks>
|
||||
public abstract SensorOutput Sense(Agent target);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the relative position of the target agent.
|
||||
/// </summary>
|
||||
/// <param name="target">The agent to sense.</param>
|
||||
/// <returns>PositionOutput containing range, azimuth, and elevation.</returns>
|
||||
/// <remarks>
|
||||
/// Implementers should calculate:
|
||||
/// - range: Distance to the target (in unity units).
|
||||
/// - azimuth: Horizontal angle to the target (in degrees).
|
||||
/// Positive is clockwise from the forward direction.
|
||||
/// - elevation: Vertical angle to the target (in degrees).
|
||||
/// Positive is above the horizontal plane.
|
||||
/// </remarks>
|
||||
protected abstract PositionOutput SensePosition(Agent target);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the relative velocity of the target agent.
|
||||
/// </summary>
|
||||
/// <param name="target">The agent to sense.</param>
|
||||
/// <returns>VelocityOutput containing range rate, azimuth rate, and elevation rate.</returns>
|
||||
/// <remarks>
|
||||
/// Implementers should calculate:
|
||||
/// - range: Radial velocity (closing speed) in units/second.
|
||||
/// Positive means the target is moving away.
|
||||
/// - azimuth: Rate of change of azimuth in degrees/second.
|
||||
/// Positive means the target is moving clockwise.
|
||||
/// - elevation: Rate of change of elevation in degrees/second.
|
||||
/// Positive means the target is moving upwards.
|
||||
/// </remarks>
|
||||
protected abstract VelocityOutput SenseVelocity(Agent target);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user