mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-11 06:25:33 +08:00
refactor: Add interface for PBH interpolators
This commit is contained in:
@@ -648,6 +648,7 @@ add_library(misc SHARED
|
|||||||
simulation/simulatedaircraftlist.cpp
|
simulation/simulatedaircraftlist.cpp
|
||||||
simulation/matchingstatisticsentry.h
|
simulation/matchingstatisticsentry.h
|
||||||
simulation/interpolationsetuplist.h
|
simulation/interpolationsetuplist.h
|
||||||
|
simulation/interpolatorpbh.h
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
test/testdata.cpp
|
test/testdata.cpp
|
||||||
|
|||||||
@@ -246,11 +246,12 @@ namespace BlackMisc::Simulation
|
|||||||
{
|
{
|
||||||
if (!isValidInterpolant) { break; }
|
if (!isValidInterpolant) { break; }
|
||||||
|
|
||||||
|
const IInterpolatorPbh &pbh = interpolant.pbh();
|
||||||
|
|
||||||
// init interpolated situation
|
// init interpolated situation
|
||||||
currentSituation = this->initInterpolatedSituation(pbh.getStartSituation(), pbh.getEndSituation());
|
currentSituation = this->initInterpolatedSituation(pbh.getStartSituation(), pbh.getEndSituation());
|
||||||
|
|
||||||
// Pitch bank heading first, so follow up steps could use those values
|
// Pitch bank heading first, so follow up steps could use those values
|
||||||
const auto pbh = interpolant.pbh();
|
|
||||||
currentSituation.setHeading(pbh.getHeading());
|
currentSituation.setHeading(pbh.getHeading());
|
||||||
currentSituation.setPitch(pbh.getPitch());
|
currentSituation.setPitch(pbh.getPitch());
|
||||||
currentSituation.setBank(pbh.getBank());
|
currentSituation.setBank(pbh.getBank());
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace BlackMisc
|
|||||||
//! End situation
|
//! End situation
|
||||||
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
||||||
|
|
||||||
CInterpolatorLinearPbh pbh() const { return m_pbh; }
|
const IInterpolatorPbh &pbh() const { return m_pbh; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Aviation::CAircraftSituation m_startSituation;
|
Aviation::CAircraftSituation m_startSituation;
|
||||||
|
|||||||
@@ -11,11 +11,12 @@
|
|||||||
#include "blackmisc/pq/angle.h"
|
#include "blackmisc/pq/angle.h"
|
||||||
#include "blackmisc/pq/speed.h"
|
#include "blackmisc/pq/speed.h"
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/simulation/interpolatorpbh.h"
|
||||||
|
|
||||||
namespace BlackMisc::Simulation
|
namespace BlackMisc::Simulation
|
||||||
{
|
{
|
||||||
//! Simple linear interpolator for pitch, bank, heading and groundspeed from start to end situation
|
//! Simple linear interpolator for pitch, bank, heading and groundspeed from start to end situation
|
||||||
class BLACKMISC_EXPORT CInterpolatorLinearPbh
|
class BLACKMISC_EXPORT CInterpolatorLinearPbh : public IInterpolatorPbh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! @{
|
//! @{
|
||||||
@@ -27,12 +28,12 @@ namespace BlackMisc::Simulation
|
|||||||
|
|
||||||
//! @{
|
//! @{
|
||||||
//! Getter
|
//! Getter
|
||||||
Aviation::CHeading getHeading() const;
|
Aviation::CHeading getHeading() const override;
|
||||||
PhysicalQuantities::CAngle getPitch() const;
|
PhysicalQuantities::CAngle getPitch() const override;
|
||||||
PhysicalQuantities::CAngle getBank() const;
|
PhysicalQuantities::CAngle getBank() const override;
|
||||||
PhysicalQuantities::CSpeed getGroundSpeed() const;
|
PhysicalQuantities::CSpeed getGroundSpeed() const override;
|
||||||
const Aviation::CAircraftSituation &getStartSituation() const { return m_startSituation; }
|
const Aviation::CAircraftSituation &getStartSituation() const override { return m_startSituation; }
|
||||||
const Aviation::CAircraftSituation &getEndSituation() const { return m_endSituation; }
|
const Aviation::CAircraftSituation &getEndSituation() const override { return m_endSituation; }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Change time fraction
|
//! Change time fraction
|
||||||
|
|||||||
34
src/blackmisc/simulation/interpolatorpbh.h
Normal file
34
src/blackmisc/simulation/interpolatorpbh.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||||
|
#define BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||||
|
|
||||||
|
#include "blackmisc/aviation/heading.h"
|
||||||
|
#include "blackmisc/pq/angle.h"
|
||||||
|
#include "blackmisc/pq/speed.h"
|
||||||
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
|
|
||||||
|
namespace BlackMisc::Simulation
|
||||||
|
{
|
||||||
|
//! Base class for Pitch-Bank-Heading interpolators
|
||||||
|
class IInterpolatorPbh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IInterpolatorPbh() = default;
|
||||||
|
|
||||||
|
//! @{
|
||||||
|
//! Getter
|
||||||
|
virtual Aviation::CHeading getHeading() const = 0;
|
||||||
|
virtual PhysicalQuantities::CAngle getPitch() const = 0;
|
||||||
|
virtual PhysicalQuantities::CAngle getBank() const = 0;
|
||||||
|
virtual PhysicalQuantities::CSpeed getGroundSpeed() const = 0;
|
||||||
|
virtual const Aviation::CAircraftSituation &getStartSituation() const = 0;
|
||||||
|
virtual const Aviation::CAircraftSituation &getEndSituation() const = 0;
|
||||||
|
//! @}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BLACKMISC_SIMULATION_INTERPOLATORPBH_H
|
||||||
@@ -77,7 +77,7 @@ namespace BlackMisc::Simulation
|
|||||||
//! \private UNIT tests/ASSERT only
|
//! \private UNIT tests/ASSERT only
|
||||||
const PosArray &getPa() const { return m_pa; }
|
const PosArray &getPa() const { return m_pa; }
|
||||||
|
|
||||||
CInterpolatorLinearPbh pbh() const { return m_pbh; }
|
const IInterpolatorPbh &pbh() const { return m_pbh; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PosArray m_pa; //!< current positions array, latest values last
|
PosArray m_pa; //!< current positions array, latest values last
|
||||||
|
|||||||
Reference in New Issue
Block a user