2019-04-22 10:57:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 James Turner
|
|
|
|
*
|
|
|
|
* This file is part of the program FlightGear.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _FGTEST_API_TEST_PILOT_HXX
|
|
|
|
#define _FGTEST_API_TEST_PILOT_HXX
|
|
|
|
|
|
|
|
#include <simgear/props/propsfwd.hxx>
|
|
|
|
#include <simgear/math/SGMathFwd.hxx>
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
2019-04-19 11:26:07 +00:00
|
|
|
#include <simgear/math/SGGeod.hxx>
|
|
|
|
|
|
|
|
class GPS;
|
2019-04-22 10:57:55 +00:00
|
|
|
|
|
|
|
namespace FGTestApi {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief simulation of the user (pilot) fying in a particular way
|
|
|
|
* around the world. Standard property tree values are updated
|
|
|
|
* (position / orientation / velocity)
|
|
|
|
*/
|
|
|
|
class TestPilot : public SGSubsystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TestPilot(SGPropertyNode_ptr props = {});
|
|
|
|
~TestPilot();
|
|
|
|
|
|
|
|
void resetAtPosition(const SGGeod& pos);
|
|
|
|
|
|
|
|
void setSpeedKts(double knots);
|
|
|
|
|
|
|
|
void setCourseTrue(double deg);
|
|
|
|
void turnToCourse(double deg);
|
|
|
|
|
|
|
|
void setVerticalFPM(double fpm);
|
|
|
|
void setTargetAltitudeFtMSL(double altFt);
|
|
|
|
|
|
|
|
// void setTurnRateDegSec();
|
|
|
|
|
|
|
|
void init() override;
|
|
|
|
void update(double dT) override;
|
|
|
|
|
2019-04-19 11:26:07 +00:00
|
|
|
void flyHeading(double hdg);
|
|
|
|
void flyDirectTo(const SGGeod& target);
|
|
|
|
void flyGPSCourse(GPS *gps);
|
2019-09-19 16:26:03 +00:00
|
|
|
|
|
|
|
void flyGPSCourseOffset(GPS *gps, double offsetNm);
|
|
|
|
|
2020-04-16 14:58:40 +00:00
|
|
|
bool isOnHeading(double heading) const;
|
2019-04-22 10:57:55 +00:00
|
|
|
private:
|
2019-04-19 11:26:07 +00:00
|
|
|
enum class LateralMode
|
|
|
|
{
|
|
|
|
Heading,
|
|
|
|
Direct,
|
2019-09-19 16:26:03 +00:00
|
|
|
GPSCourse,
|
|
|
|
GPSOffset
|
2019-04-19 11:26:07 +00:00
|
|
|
};
|
|
|
|
|
2019-04-22 10:57:55 +00:00
|
|
|
void updateValues(double dt);
|
|
|
|
void setPosition(const SGGeod& pos);
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _propRoot;
|
|
|
|
|
|
|
|
double _trueCourseDeg = 0.0;
|
|
|
|
double _speedKnots = 0.0;
|
|
|
|
double _vspeedFPM = 0.0;
|
|
|
|
|
|
|
|
bool _turnActive = false;
|
2019-04-23 17:10:39 +00:00
|
|
|
bool _altActive = false;
|
2019-04-22 10:57:55 +00:00
|
|
|
double _targetCourseDeg = 0.0;
|
|
|
|
double _targetAltitudeFt = 0.0;
|
2019-04-19 11:26:07 +00:00
|
|
|
|
|
|
|
LateralMode _lateralMode = LateralMode::Heading;
|
|
|
|
SGGeod _targetPos;
|
|
|
|
GPS* _gps = nullptr;
|
2019-09-19 16:26:03 +00:00
|
|
|
double _courseOffsetNm =0.0;
|
2019-04-19 11:26:07 +00:00
|
|
|
|
|
|
|
SGPropertyNode_ptr _latProp;
|
|
|
|
SGPropertyNode_ptr _lonProp;
|
|
|
|
SGPropertyNode_ptr _altitudeProp;
|
|
|
|
SGPropertyNode_ptr _headingProp;
|
|
|
|
SGPropertyNode_ptr _speedKnotsProp;
|
|
|
|
SGPropertyNode_ptr _verticalFPMProp;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _gpsNode;
|
2019-04-22 10:57:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // of namespace FGTestApi
|
|
|
|
|
|
|
|
#endif // of _FGTEST_API_TEST_PILOT_HXX
|
|
|
|
|