| | | 1 | | using UnityEngine; |
| | | 2 | | |
| | | 3 | | // Ideal sensor. |
| | | 4 | | // |
| | | 5 | | // The ideal sensor provides perfect, noise-free measurements of the relative transformation between |
| | | 6 | | // the sensing agent and a target. This sensor is useful for testing and establishing baseline |
| | | 7 | | // behavior before adding realistic sensor noise and limitations. |
| | | 8 | | public class IdealSensor : SensorBase { |
| | 2907 | 9 | | public IdealSensor(IAgent agent) : base(agent) {} |
| | | 10 | | |
| | | 11 | | // Sense the target hierarchical object. |
| | 1661 | 12 | | public override SensorOutput Sense(IHierarchical hierarchical) { |
| | 1661 | 13 | | Transformation relativeTransformation = Agent.GetRelativeTransformation(hierarchical); |
| | 1661 | 14 | | return GenerateSensorOutput(relativeTransformation); |
| | 1661 | 15 | | } |
| | | 16 | | |
| | | 17 | | // Sense the target agent. |
| | 0 | 18 | | public override SensorOutput Sense(IAgent agent) { |
| | 0 | 19 | | Transformation relativeTransformation = Agent.GetRelativeTransformation(agent); |
| | 0 | 20 | | return GenerateSensorOutput(relativeTransformation); |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | // Sense the waypoint. |
| | 0 | 24 | | public override SensorOutput Sense(in Vector3 waypoint) { |
| | 0 | 25 | | Transformation relativeTransformation = Agent.GetRelativeTransformation(waypoint); |
| | 0 | 26 | | return GenerateSensorOutput(relativeTransformation); |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | // Generate the sensor output from the relative transformation. |
| | 1661 | 30 | | private SensorOutput GenerateSensorOutput(in Transformation relativeTransformation) { |
| | 1661 | 31 | | return new SensorOutput { |
| | | 32 | | Position = relativeTransformation.Position, |
| | | 33 | | Velocity = relativeTransformation.Velocity, |
| | | 34 | | Acceleration = relativeTransformation.Acceleration, |
| | | 35 | | }; |
| | 1661 | 36 | | } |
| | | 37 | | } |