Revert "Device/Driver/LX: Add small delay after baud rate change"
[xcsoar.git] / test / src / RunWindEKF.cpp
blob80eb5f9d2f3d3fdea169715aa63ffeea6981eb5b
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "Computer/Settings.hpp"
25 #include "Computer/CirclingComputer.hpp"
26 #include "Computer/Wind/WindEKFGlue.hpp"
27 #include "Formatter/TimeFormatter.hpp"
28 #include "OS/Args.hpp"
29 #include "DebugReplay.hpp"
31 #include <stdio.h>
33 int main(int argc, char **argv)
35 Args args(argc, argv, "DRIVER FILE");
36 DebugReplay *replay = CreateDebugReplay(args);
37 if (replay == NULL)
38 return EXIT_FAILURE;
40 args.ExpectEnd();
42 printf("# time wind_bearing (deg) wind_speed (m/s) grndspeed (m/s) tas (m/s) bearing (deg)\n");
44 CirclingSettings circling_settings;
45 circling_settings.SetDefaults();
47 CirclingComputer circling_computer;
48 circling_computer.Reset();
50 WindEKFGlue wind_ekf;
51 wind_ekf.Reset();
53 while (replay->Next()) {
54 const MoreData &data = replay->Basic();
55 const DerivedInfo &calculated = replay->Calculated();
57 circling_computer.TurnRate(replay->SetCalculated(),
58 data, calculated.flight);
60 WindEKFGlue::Result result =
61 wind_ekf.Update(data, replay->Calculated());
62 if (result.quality > 0) {
63 TCHAR time_buffer[32];
64 FormatTime(time_buffer, data.time);
66 _tprintf(_T("%s %d %g %g %g %d\n"), time_buffer,
67 (int)result.wind.bearing.Degrees(),
68 (double)result.wind.norm,
69 (double)data.ground_speed,
70 (double)data.true_airspeed,
71 (int)data.track.Degrees());
75 delete replay;