Commit 18957f7e authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Merge branch 'develop' of https://git.rwth-aachen.de/ita/ITASimulationScheduler into develop

parents 787b90b2 a393a6ea
......@@ -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.
};
......
......@@ -14,6 +14,9 @@
#include <VistaBase/VistaVector3D.h>
#include <VistaAspects/VistaSerializable.h>
// STD
#include <string.h>
namespace ITA
{
namespace SimulationScheduler
......@@ -36,7 +39,7 @@ namespace ITA
oAirAttenuationSpectrum.SetIdentity();
};
int iID;
std::string sID;
double dPropagationDelay; //!< Delay in seconds
double dSpreadingLoss; //!< Wave type specific spreading loss factor
......
......@@ -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 );
}
......@@ -124,7 +128,7 @@ namespace ITA
oIdentitySpectrum.SetIdentity();
for (int idx = 0; idx < vpEigenrays.size(); idx++)
{
pResult->voPathProperties[idx].iID = idx;
pResult->voPathProperties[idx].sID = std::to_string( idx );
pResult->voPathProperties[idx].dPropagationDelay = vpEigenrays[idx]->LastTimeStamp();
pResult->voPathProperties[idx].dSpreadingLoss = vpEigenrays[idx]->SpreadingLoss();
......
......@@ -12,11 +12,13 @@
using namespace ITA::SimulationScheduler;
using namespace ITA::SimulationScheduler::OutdoorAcoustics;
const int MAX_PATHID_STRING_LENGTH = 10000;
int COutdoorSimulationResult::CPathProperty::Serialize(IVistaSerializer& pSerializer) const
{
int returnVal = 0;
returnVal += pSerializer.WriteInt32(iID);
returnVal += pSerializer.WriteString(sID);
returnVal += pSerializer.WriteDouble(dPropagationDelay);
returnVal += pSerializer.WriteDouble(dSpreadingLoss);
......@@ -36,7 +38,7 @@ int COutdoorSimulationResult::CPathProperty::DeSerialize(IVistaDeSerializer& pDe
{
int returnVal = 0;
returnVal += pDeserializer.ReadInt32(iID);
returnVal += pDeserializer.ReadString(sID, MAX_PATHID_STRING_LENGTH);
returnVal += pDeserializer.ReadDouble(dPropagationDelay);
returnVal += pDeserializer.ReadDouble(dSpreadingLoss);
......
......@@ -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