randomize speed

This commit is contained in:
Jet
2023-06-23 17:45:49 +01:00
parent a80d820e7d
commit de391c8df9
3 changed files with 5 additions and 7 deletions

View File

@@ -33,12 +33,10 @@ Spoofer::Spoofer() {
utm_data.alt_msl_m = utm_data.base_alt_m + z;
utm_data.alt_agl_m = z;
utm_data.speed_kn = speed_kn;
utm_data.speed_kn = 1;
utm_data.satellites = 8;
utm_data.base_valid = 1;
speed_m_x = ((float) speed_kn) * 0.514444 * 0.2; // Because we update every 200 ms.
utm_utils.calc_m_per_deg(lat_d,&m_deg_lat,&m_deg_long);
}
@@ -48,6 +46,10 @@ void Spoofer::update() {
return;
}
// randomly update the velocity
utm_data.speed_kn = constrain(utm_data.speed_kn + (rand() % 5) - 2, 1, 20);
speed_m_x = ((float) utm_data.speed_kn) * 0.514444 * 0.2; // Because we update every 200 ms.
// randomly pick a direction to head and update the heading
float ranf = 0.001 * (float) (((int) rand() % 1000) - 500);
int dir_change = (int) (max_dir_change * ranf);