Commit 301bb702 authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

ART Simulator

- now config has default values
- Create function now checks for correct config type
- updated tests
parent f63313bd
......@@ -43,7 +43,7 @@ namespace ITA
void Load(const VistaPropertyList& oProperties) override;
CoordinateSystem eClientCoordinateSystem = CoordinateSystem::Cartesian; //!< 0 = Cartesian, 1 = OpenGL
std::string sJsonAtmosphere; //!< Either JSON formatted string or path to atmosphere JSON file.
std::string sJsonAtmosphere = ""; //!< Either JSON formatted string or path to atmosphere JSON file.
};
......
......@@ -13,6 +13,7 @@
// ITA Base
#include <ITAFileSystemUtils.h>
#include <ITAException.h>
// STD
#include <ostream>
......@@ -85,6 +86,9 @@ namespace ITA
std::unique_ptr<ISimulatorInterface> CARTSimulator::Create( std::shared_ptr< const ISimulatorInterface::SimulatorConfig > pConfig )
{
std::shared_ptr< const ARTSimulatorConfig > pConfigGenericShared = std::dynamic_pointer_cast< const ARTSimulatorConfig >( pConfig );
if (!pConfigGenericShared)
ITA_EXCEPT_INVALID_PARAMETER("Pointer to oinvalid config given.");
const ARTSimulatorConfig& oConf( *pConfigGenericShared );
return std::make_unique<CARTSimulator>( oConf );
}
......
......@@ -30,100 +30,80 @@ using namespace ITA::SimulationScheduler::OutdoorAcoustics;
//using namespace ITA::SimulationScheduler::RoomAcoustics;
//using namespace ITA::SimulationScheduler::RoomAcoustics::Raven;
//TEST ( SimulatorTest, WriteRPF )
//{
// auto simulator = std::make_unique<CSimulator> (
// FieldOfDuty::directSound,
// "D:/ScieBo/MasterThesis/Raven/RavenInput/Cube/referenceNEW.rpf" );
//
// CRavenScene::CReceiverState oReceiverState;
// oReceiverState.vPos.init ( 0, 1, 0 );
// oReceiverState.vView.init ( 0, 0, -1 );
// oReceiverState.vUp.init ( 0, 1, 0 );
//
// CRavenScene::CSourceState oSourceState;
// oSourceState.vPos.init ( 0, 1, 0 );
// oSourceState.vView.init ( 0, 0, -1 );
// oSourceState.vUp.init ( 0, 1, 0 );
//
// auto oTask = new CSimulationTask;
//
// oTask->oScene.AddReceiver ( 0 );
// oTask->oScene.SetReceiverState ( 0, oReceiverState );
// oTask->oScene.AddSource ( 0 );
// oTask->oScene.SetSourceState ( 0, oSourceState );
// oTask->eSimulationType = FieldOfDuty::earlyReflections;
// oTask->uiID = 0;
//
// auto result = new CRavenSimulationResult ( );
//
// simulator->Compute ( oTask, result );
//
// if ( !doesDirectoryExist ( "results" ) )
// makeDirectory ( "results" );
//
// EXPECT_NO_THROW ( simulator->WriteToRpf ( "results/WriteRPFTest.rpf" ) );
//}
struct ARTSimulatorParam
struct ARTSimulatorParam : ART::CARTSimulator::ARTSimulatorConfig
{
struct SceneParam
{
std::string sAtmosphereJsonFile;
VistaVector3D v3SourcePosition;
VistaVector3D v3ReceiverPosition;
friend std::ostream& operator<<( std::ostream& os, const SceneParam& obj )
{
return os
<< "scene: " << obj.sAtmosphereJsonFile
<< " sourcePosition: " << obj.v3SourcePosition[0] << ", " << obj.v3SourcePosition[1] << ", " << obj.v3SourcePosition[2]
<< " sourcePosition: " << obj.v3ReceiverPosition[0] << ", " << obj.v3ReceiverPosition[1] << ", " << obj.v3ReceiverPosition[2];
}
};
struct MiscParam
//TODO: Think about other parameters
VistaVector3D v3SourcePosition;
VistaVector3D v3ReceiverPosition;
friend std::ostream& operator<<(std::ostream& os, const ARTSimulatorParam& obj)
{
int runs;
double acceptableStdDev; // ~6
double correlationThreshold; // >0.9 for deterministic results
bool saveResults;
friend std::ostream& operator<<( std::ostream& os, const MiscParam& obj )
{
return os
<< "runs: " << obj.runs
<< " acceptableStdDev: " << obj.acceptableStdDev
<< " correlationThreshold: " << obj.correlationThreshold;
}
};
return os
<< "ClientCoordSystem: " << (int)obj.eClientCoordinateSystem << ", "
<< "JSON: " << obj.sJsonAtmosphere;
}
};
struct ARTSimulatorTestParam : testing::TestWithParam<std::tuple<ARTSimulatorParam::SceneParam, ARTSimulatorParam::MiscParam>>
struct ARTSimulatorTest : testing::Test
{
std::unique_ptr< ART::CARTSimulator > pSimulator;
std::unique_ptr< CUpdateScene > pUpdateScene;
//ITABase::CMultichannelFiniteImpulseResponse reference;
ARTSimulatorTestParam( )
ARTSimulatorTest()
{
}
ART::CARTSimulator::ARTSimulatorConfig config;
config.eClientCoordinateSystem = CoordinateSystem::OpenGL;
config.sJsonAtmosphere = "";
static bool ResultsAreIdentical ( const ITABase::CMultichannelFiniteImpulseResponse& reference, const COutdoorSimulationResult& secondResult )
{
pSimulator = std::make_unique< ART::CARTSimulator >(config);
return false;
pUpdateScene = std::make_unique< CUpdateScene >(0);
}
static bool CompareResults ( const ITABase::CMultichannelFiniteImpulseResponse& reference, const std::vector<COutdoorSimulationResult>& secondResults, const double& acceptedStandardDeviation )
void SetSourceAndReceiver(const VistaVector3D& v3SourcePos, const VistaVector3D& v3RecPos )
{
return false;
pUpdateScene->SetSourceReceiverPair(
std::make_unique<C3DObject>(v3SourcePos, VistaQuaternion(1,0,0,0), C3DObject::Type::source, 0),
std::make_unique<C3DObject>(v3RecPos, VistaQuaternion(1, 0, 0, 0), C3DObject::Type::receiver, 0)
);
}
};
TEST ( ARTSimulatorConstructionTest, Constructor )
{
ART::CARTSimulator::ARTSimulatorConfig config;
EXPECT_NO_THROW( auto testSim = ART::CARTSimulator(config) );
}
TEST( ARTSimulatorConstructionTest, CreateWithWrongConfig )
{
auto pWrongConfig = std::make_unique<ISimulatorInterface::SimulatorConfig>();
try
{
ART::CARTSimulator::Create( std::move(pWrongConfig) );
}
catch (ITAException& err)
{
SUCCEED();
return;
}
FAIL();
}
TEST_F( ARTSimulatorTest, Compute )
{
auto v3Source = VistaVector3D(1, 0, 0);
auto v3Receiver = VistaVector3D(1, 0, 0);
SetSourceAndReceiver(v3Source, v3Receiver);
auto pResult = pSimulator->Compute( std::move(pUpdateScene) );
EXPECT_TRUE(pResult != nullptr);
}
//TEST_P(SimulatorTestParam, CorrectResult)
//{
// SUCCEED();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment