コード例 #1
0
static bool
test_speed_factor(int test_num, int n_wind)
{
  // flying at opt speed should be minimum time flight!

  double te0, te1, te2;

  TestFlightResult result = test_flight(test_num, n_wind, 1.0);
  te0 = result.time_elapsed;

  result = test_flight(test_num, n_wind, 0.7);
  te1 = result.time_elapsed;
  // time of this should be higher than nominal
  ok(te0 < te1, test_name("vopt slow or", test_num, n_wind), 0);

  result = test_flight(test_num, n_wind, 1.5);
  te2 = result.time_elapsed;
  // time of this should be higher than nominal
  ok(te0 < te2, test_name("vopt fast or", test_num, n_wind), 0);

  bool retval = (te0 < te1) && (te0 < te2);
  if (verbose || !retval) {
    printf("# sf 0.8 time_elapsed_rat %g\n", te1 / te0);
    printf("# sf 1.2 time_elapsed_rat %g\n", te2 / te0);
  }
  return retval;
}
コード例 #2
0
ファイル: test_bestcruisetrack.cpp プロジェクト: XCame/XCSoar
static bool
test_bestcruisetrack(int test_num, int n_wind)
{

  // tests whether following the cruise track which compensates for wind drift
  // produces routes that are more on track than if the route is allowed to drift
  // downwind during climbs

  // this test allows for a small error margin

  autopilot_parms.enable_bestcruisetrack = false;
  TestFlightResult result = test_flight(test_num, n_wind);
  double t0 = result.time_elapsed;

  autopilot_parms.enable_bestcruisetrack = true;
  result = test_flight(test_num, n_wind);
  double t1 = result.time_elapsed;
  autopilot_parms.enable_bestcruisetrack = false;

  bool fine = (t1 / t0 < 1.01);
  ok(fine, GetTestName("faster flying with bestcruisetrack", test_num, n_wind),
     0);

  if (!fine || verbose)
    printf("# time ratio %g\n", t1 / t0);

  return fine;
}
コード例 #3
0
ファイル: test.cpp プロジェクト: Mrdini/XCSoar
int main(int argc, char** argv) {
  // default arguments
  verbose=2;  
  
  // default arguments
  autopilot_parms.realistic();

  if (!parse_args(argc,argv)) {
    return 0;
  }

  plan_tests(7);

  terrain_height = 1;
  ok(test_abort(0),"abort",0);
  ok(test_flight(3,0,1.0,true),"basic flight test",0);
  ok(test_goto(0,5),"goto",0);
  ok(test_null(),"null",0);
  ok(test_flight(2,0,1.0,true),"basic flight test",0);
  terrain_height = 500;
  ok(test_flight(3,0,1.0,true),"high terrain",0);
  terrain_height = 1;
  ok(test_airspace(100),"airspace 100",0);
  return exit_status();
}
コード例 #4
0
ファイル: harness_flight.cpp プロジェクト: ppara/XCSoar
TestFlightResult
test_flight(int test_num, int n_wind, const double speed_factor,
            const bool auto_mc)
{
  return test_flight(TestFlightComponents(), test_num, n_wind, speed_factor,
                     auto_mc);
}
コード例 #5
0
static bool
test_airspace(const unsigned n_airspaces)
{
  TestFlightComponents components;
  components.airspaces = new Airspaces;
  setup_airspaces(*components.airspaces, GeoPoint(Angle::Degrees(fixed_half), Angle::Degrees(fixed_half)), n_airspaces);
  bool fine = test_flight(components, 4, 0);
  delete components.airspaces;
  return fine;
}
コード例 #6
0
ファイル: test_automc.cpp プロジェクト: davidswelt/XCSoar
static bool
test_automc(int test_num, int n_wind)
{
  // test whether flying by automc (starting above final glide)
  // arrives home faster than without

  TestFlightResult result = test_flight(test_num, n_wind, 1.0, false);
  double t0 = result.time_elapsed;

  result = test_flight(test_num, n_wind, 1.0, true);
  double t1 = result.time_elapsed;

  bool fine = (t1 / t0 < 1.015);
  if (!fine || verbose)
    printf("# time ratio %g\n", t1 / t0);

  ok(fine, test_name("faster with auto mc on", test_num, n_wind), 0);

  return fine;
}
コード例 #7
0
ファイル: test_aat.cpp プロジェクト: damianob/xcsoar
static bool
test_aat(int test_num, int n_wind)
{
  // test whether flying to targets in an AAT task produces
  // elapsed (finish) times equal to desired time with 1.5% tolerance

  TestFlightResult result = test_flight(test_num, n_wind);
  bool fine = result.result;
  double min_time = (double)aat_min_time(test_num) + 300.0;
  // 300 second offset is default 5 minute margin provided in TaskBehaviour

  const double t_ratio = fabs(result.time_elapsed / min_time - 1.0);
  fine &= (t_ratio < 0.015);
  if (!fine || verbose)
    printf("# time ratio error (elapsed/target) %g\n", t_ratio);

  return fine;
}
コード例 #8
0
ファイル: harness_flight.cpp プロジェクト: macsux/XCSoar
bool
test_flight_times(int test_num, int n_wind)
{
  // tests whether elapsed/planned times are consistent
  // there will be small error due to start location

  bool fine = test_flight(test_num, n_wind);
  const double t_rat = fabs(time_elapsed / time_planned - 1.0);
  fine &= t_rat < 0.02;

  if ((verbose) || !fine) {
    printf("# time remaining %g\n", time_remaining);
    printf("# time elapsed %g\n", time_elapsed);
    printf("# time planned %g\n", time_planned);
    printf("# time ratio error (elapsed/planned) %g\n", t_rat);
  }

  return fine;
}
コード例 #9
0
ファイル: test_acfilter.cpp プロジェクト: XCame/XCSoar
int main(int argc, char** argv) {
  // default arguments
  autopilot_parms.SetRealistic();

  if (!ParseArgs(argc,argv)) {
    return 0;
  }

  AircraftState dummy;
  TestFlightComponents components;
  components.aircraft_filter = new AircraftStateFilter(fixed(120));
  components.aircraft_filter->Reset(dummy);

  plan_tests(1);
  ok(test_flight(components, 1,0,1.0,true),"basic flight test",0);

  delete components.aircraft_filter;

  return exit_status();
}
コード例 #10
0
ファイル: test_acfilter.cpp プロジェクト: galippi/xcsoar
int main(int argc, char** argv) {
  // default arguments
  autopilot_parms.bearing_noise=fixed(0);
  autopilot_parms.target_noise=fixed(0.1);
  autopilot_parms.turn_speed=fixed(5.0);
  output_skip = 5;

  if (!parse_args(argc,argv)) {
    return 0;
  }

  AIRCRAFT_STATE dummy;
  aircraft_filter = new AircraftStateFilter(dummy, fixed(120));

  plan_tests(1);
  ok(test_flight(1,0,1.0,true),"basic flight test",0);

  delete aircraft_filter;

  return exit_status();
}
コード例 #11
0
ファイル: test_effectivemc.cpp プロジェクト: damianob/xcsoar
static bool
test_effective_mc(int test_num, int n_wind)
{
  // tests functionality of effective mc calculations

  double ce0, ce1, ce2, ce3, ce4, ce5, ce6;

  autopilot_parms.SetIdeal();

  TestFlightResult result = test_flight(test_num, n_wind);
  ce0 = result.calc_effective_mc;

  // wandering
  autopilot_parms.SetRealistic();
  result = test_flight(test_num, n_wind);
  ce1 = result.calc_effective_mc;
  // effective mc of this should be lower than nominal
  if (ce0 <= ce1 || verbose)
    printf("# calc effective mc %g\n", result.calc_effective_mc);

  ok(ce0 > ce1, GetTestName("emc wandering", test_num, n_wind), 0);

  // flying too slow
  autopilot_parms.SetIdeal();
  result = test_flight(test_num, n_wind, 0.8);
  ce2 = result.calc_effective_mc;
  // effective mc of this should be lower than nominal
  if (ce0 <= ce2 || verbose)
    printf("# calc effective mc %g\n", result.calc_effective_mc);

  ok(ce0 > ce2, GetTestName("emc speed slow", test_num, n_wind), 0);

  // flying too fast
  autopilot_parms.SetIdeal();
  result = test_flight(test_num, n_wind, 1.2);
  ce3 = result.calc_effective_mc;
  // effective mc of this should be lower than nominal
  if (ce0 <= ce3 || verbose)
    printf("# calc effective mc %g\n", result.calc_effective_mc);

  ok(ce0 > ce3, GetTestName("emc speed fast", test_num, n_wind), 0);

  // higher than expected cruise sink
  autopilot_parms.sink_factor = fixed(1.2);
  result = test_flight(test_num, n_wind);
  ce4 = result.calc_effective_mc;
  if (ce0 <= ce4 || verbose)
    printf("# calc effective mc %g\n", result.calc_effective_mc);

  ok(ce0 > ce4, GetTestName("emc high sink", test_num, n_wind), 0);
  // effective mc of this should be lower than nominal
  autopilot_parms.sink_factor = fixed(1.0);

  // slower than expected climb
  autopilot_parms.climb_factor = fixed(0.8);
  result = test_flight(test_num, n_wind);
  ce5 = result.calc_effective_mc;
  if (ce0 <= ce5 || verbose)
    printf("# calc effective mc %g\n", result.calc_effective_mc);

  ok(ce0 > ce5, GetTestName("emc slow climb", test_num, n_wind), 0);
  // effective mc of this should be lower than nominal
  autopilot_parms.climb_factor = fixed(1.0);

  // lower than expected cruise sink;
  autopilot_parms.sink_factor = fixed(0.8);
  result = test_flight(test_num, n_wind);
  ce6 = result.calc_effective_mc;
  if (ce0 >= ce6 || verbose)
    printf("# calc effective mc %g\n", result.calc_effective_mc);

  ok(ce0 < ce6, GetTestName("emc low sink", test_num, n_wind), 0);
  // effective mc of this should be greater than nominal
  autopilot_parms.sink_factor = fixed(1.0);

  bool retval = (ce0 > ce1) &&
                (ce0 > ce2) &&
                (ce0 > ce3) &&
                (ce0 > ce4) &&
                (ce0 > ce5) &&
                (ce0 < ce6);

  if (verbose || !retval) {
    printf("# emc nominal %g\n", ce0);
    printf("# emc wandering %g\n", ce1);
    printf("# emc speed slow %g\n", ce2);
    printf("# emc speed fast %g\n", ce3);
    printf("# emc high sink %g\n", ce4);
    printf("# emc slow climb %g\n", ce5);
    printf("# emc low sink %g\n", ce6);
  }
  return retval;
}
コード例 #12
0
static bool
test_cruise_efficiency(int test_num, int n_wind)
{
  // tests functionality of cruise efficiency calculations

  double ce0, ce1, ce2, ce3, ce4, ce5, ce6;

  autopilot_parms.ideal();

  TestFlightResult result = test_flight(test_num, n_wind);
  ce0 = result.calc_cruise_efficiency;

  // wandering
  autopilot_parms.realistic();
  result = test_flight(test_num, n_wind);
  ce1 = result.calc_cruise_efficiency;
  // cruise efficiency of this should be lower than nominal
  if (ce0 <= ce1 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce1, test_name("ce wandering", test_num, n_wind), 0);

  // flying too slow
  autopilot_parms.ideal();
  result = test_flight(test_num, n_wind, 0.8);
  ce2 = result.calc_cruise_efficiency;
  // cruise efficiency of this should be lower than nominal
  if (ce0 <= ce2 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce2, test_name("ce speed slow", test_num, n_wind), 0);

  // flying too fast
  autopilot_parms.ideal();
  result = test_flight(test_num, n_wind, 1.2);
  ce3 = result.calc_cruise_efficiency;
  // cruise efficiency of this should be lower than nominal
  if (ce0 <= ce3 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce3, test_name("ce speed fast", test_num, n_wind), 0);

  // higher than expected cruise sink
  autopilot_parms.sink_factor = fixed(1.2);
  result = test_flight(test_num, n_wind);
  ce4 = result.calc_cruise_efficiency;
  if (ce0 <= ce4 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce4, test_name("ce high sink", test_num, n_wind), 0);
  // cruise efficiency of this should be lower than nominal
  autopilot_parms.sink_factor = fixed(1.0);

  // slower than expected climb
  autopilot_parms.climb_factor = fixed(0.8);
  result = test_flight(test_num, n_wind);
  ce5 = result.calc_cruise_efficiency;
  if (ce0 <= ce5 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce5, test_name("ce slow climb", test_num, n_wind), 0);
  // cruise efficiency of this should be lower than nominal
  autopilot_parms.climb_factor = fixed(1.0);

  // lower than expected cruise sink;
  autopilot_parms.sink_factor = fixed(0.8);
  result = test_flight(test_num, n_wind);
  ce6 = result.calc_cruise_efficiency;
  if (ce0 >= ce6 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 < ce6, test_name("ce low sink", test_num, n_wind), 0);
  // cruise efficiency of this should be greater than nominal
  autopilot_parms.sink_factor = fixed(1.0);

  bool retval = (ce0 > ce1) && (ce0 > ce2) && (ce0 > ce3) && (ce0 > ce4)
      && (ce0 > ce5) && (ce0 < ce6);
  if (verbose || !retval) {
    printf("# ce nominal %g\n", ce0);
    printf("# ce wandering %g\n", ce1);
    printf("# ce speed slow %g\n", ce2);
    printf("# ce speed fast %g\n", ce3);
    printf("# ce high sink %g\n", ce4);
    printf("# ce slow climb %g\n", ce5);
    printf("# ce low sink %g\n", ce6);
  }
  return retval;
}