mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-04 23:18:29 -04:00
SITL: expire stationary sim_adsb targets after an hour
This commit is contained in:
parent
ec5820044b
commit
659c35d1a9
@ -55,14 +55,19 @@ void ADSB_Vehicle::update(float delta_t)
|
|||||||
type = (ADSB_EMITTER_TYPE)(rand() % (ADSB_EMITTER_TYPE_POINT_OBSTACLE + 1));
|
type = (ADSB_EMITTER_TYPE)(rand() % (ADSB_EMITTER_TYPE_POINT_OBSTACLE + 1));
|
||||||
// don't allow surface emitters to move
|
// don't allow surface emitters to move
|
||||||
if (type == ADSB_EMITTER_TYPE_POINT_OBSTACLE) {
|
if (type == ADSB_EMITTER_TYPE_POINT_OBSTACLE) {
|
||||||
|
stationary_object_created_ms = AP_HAL::millis64();
|
||||||
velocity_ef.zero();
|
velocity_ef.zero();
|
||||||
} else {
|
} else {
|
||||||
|
stationary_object_created_ms = 0;
|
||||||
velocity_ef.x = Aircraft::rand_normal(vel_min, vel_max);
|
velocity_ef.x = Aircraft::rand_normal(vel_min, vel_max);
|
||||||
velocity_ef.y = Aircraft::rand_normal(vel_min, vel_max);
|
velocity_ef.y = Aircraft::rand_normal(vel_min, vel_max);
|
||||||
if (type < ADSB_EMITTER_TYPE_EMERGENCY_SURFACE) {
|
if (type < ADSB_EMITTER_TYPE_EMERGENCY_SURFACE) {
|
||||||
velocity_ef.z = Aircraft::rand_normal(-3, 3);
|
velocity_ef.z = Aircraft::rand_normal(-3, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (stationary_object_created_ms > 0 && AP_HAL::millis64() - stationary_object_created_ms > AP_MSEC_PER_HOUR) {
|
||||||
|
// regenerate stationary objects so we don't randomly fill up the screen with them over time
|
||||||
|
initialised = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
position += velocity_ef * delta_t;
|
position += velocity_ef * delta_t;
|
||||||
|
@ -47,6 +47,7 @@ private:
|
|||||||
uint32_t ICAO_address;
|
uint32_t ICAO_address;
|
||||||
bool initialised = false;
|
bool initialised = false;
|
||||||
ADSB_EMITTER_TYPE type;
|
ADSB_EMITTER_TYPE type;
|
||||||
|
uint64_t stationary_object_created_ms; // allows expiring of slow/stationary objects
|
||||||
};
|
};
|
||||||
|
|
||||||
class ADSB {
|
class ADSB {
|
||||||
|
Loading…
Reference in New Issue
Block a user