Update the sensor at its sensing frequency
parent
ead655695e
commit
488ddaa836
|
@ -6,9 +6,8 @@ public class Micromissile : Missile
|
||||||
{
|
{
|
||||||
[SerializeField] private float _navigationGain = 3f; // Typically 3-5
|
[SerializeField] private float _navigationGain = 3f; // Typically 3-5
|
||||||
|
|
||||||
private Vector3 _previousLOS;
|
private SensorOutput _sensorOutput;
|
||||||
private Vector3 _accelerationCommand;
|
private Vector3 _accelerationCommand;
|
||||||
private float _lastUpdateTime;
|
|
||||||
private double _elapsedTime = 0;
|
private double _elapsedTime = 0;
|
||||||
protected override void UpdateMidCourse(double deltaTime)
|
protected override void UpdateMidCourse(double deltaTime)
|
||||||
{
|
{
|
||||||
|
@ -21,16 +20,15 @@ public class Micromissile : Missile
|
||||||
|
|
||||||
// Correct the state of the target model at the sensor frequency
|
// Correct the state of the target model at the sensor frequency
|
||||||
float sensorUpdatePeriod = 1f / _agentConfig.dynamic_config.sensor_config.frequency;
|
float sensorUpdatePeriod = 1f / _agentConfig.dynamic_config.sensor_config.frequency;
|
||||||
if (_elapsedTime - _lastUpdateTime >= sensorUpdatePeriod)
|
if (_elapsedTime >= sensorUpdatePeriod)
|
||||||
{
|
{
|
||||||
// TODO: Implement guidance filter to estimate state from sensor output
|
// TODO: Implement guidance filter to estimate state from sensor output
|
||||||
// For now, we'll use the target's actual state
|
// For now, we'll use the target's actual state
|
||||||
// targetModel.SetState(_target.GetState());
|
_sensorOutput = GetComponent<Sensor>().Sense(_target);
|
||||||
_lastUpdateTime = (float)_elapsedTime;
|
|
||||||
_elapsedTime = 0;
|
_elapsedTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sense the target
|
// Check whether the target should be considered a miss
|
||||||
SensorOutput sensorOutput = GetComponent<Sensor>().Sense(_target);
|
SensorOutput sensorOutput = GetComponent<Sensor>().Sense(_target);
|
||||||
if(sensorOutput.velocity.range > 1000f) {
|
if(sensorOutput.velocity.range > 1000f) {
|
||||||
this.MarkAsMiss();
|
this.MarkAsMiss();
|
||||||
|
@ -38,7 +36,7 @@ public class Micromissile : Missile
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the acceleration input
|
// Calculate the acceleration input
|
||||||
accelerationInput = CalculateAccelerationCommand(sensorOutput);
|
accelerationInput = CalculateAccelerationCommand(_sensorOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate and set the total acceleration
|
// Calculate and set the total acceleration
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class Missile : Agent
|
||||||
Vector3 rollAxis = transform.forward;
|
Vector3 rollAxis = transform.forward;
|
||||||
|
|
||||||
// Calculate boost acceleration
|
// Calculate boost acceleration
|
||||||
float boostAcceleration = StaticConfig.boostConfig.boostAcceleration * Physics.gravity.magnitude;
|
float boostAcceleration = (float)(StaticConfig.boostConfig.boostAcceleration * Constants.kGravity);
|
||||||
Vector3 accelerationInput = boostAcceleration * rollAxis;
|
Vector3 accelerationInput = boostAcceleration * rollAxis;
|
||||||
|
|
||||||
// Calculate the total acceleration
|
// Calculate the total acceleration
|
||||||
|
|
Loading…
Reference in New Issue