ADD: updated the test function for simtrack

This commit is contained in:
Henry Winkel
2023-07-04 09:32:44 +02:00
parent f21188672b
commit 713d9f0f6c
3 changed files with 26 additions and 13 deletions

View File

@@ -35,6 +35,7 @@ namespace SimCore
void setPosition(double x, double y, double z);
SimCore::Position getPosition();
SimCore::Identifier getIdentifier();
/// @brief
/// @param emission
void addEmission(Emission emission);

View File

@@ -10,14 +10,14 @@ namespace SimCore
}
SimTrack::SimTrack(WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind)
:ID_(SimCore::Identifier()),SourceType_(WHISPER::SourceType::SIMCOMTROLER)
:ID_(SimCore::Identifier()),SourceType_(sourcetype)
{
EntityKind.setValue(entityKind);
}
SimTrack::SimTrack(SimCore::Identifier id ,WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind )
:ID_(id),SourceType_(WHISPER::SourceType::SIMCOMTROLER)
:ID_(id),SourceType_(sourcetype)
{
EntityKind.setValue(entityKind);
@@ -53,7 +53,7 @@ namespace SimCore
WHISPER::Message SimTrack::buildMessage(SimCore::Identifier parentID)
{
WHISPER::Message msg(parentID.getParentNumber(), parentID.getNumber(),WHISPER::MsgTopics::TRACK , WHISPER::MsgType::GROUND_TRUTH_TRACK, WHISPER::SourceType::GATEWAY);
WHISPER::Message msg(parentID.getParentNumber(), parentID.getNumber(),WHISPER::MsgTopics::TRACK , WHISPER::MsgType::GROUND_TRUTH_TRACK, this->SourceType_);
messages::SimTrack::SimTrack SimTrack;
@@ -118,18 +118,22 @@ namespace SimCore
{
track.setPosition(trackMsg.mutable_geocentricposition()->x(), trackMsg.mutable_geocentricposition()->y(), trackMsg.mutable_geocentricposition()->z());
}
if (trackMsg.has_contactcourse())
{
track.Course.setValue(trackMsg.contactcourse());
}
if (trackMsg.has_contactspeed())
{
track.Speed.setValue(trackMsg.contactspeed());
}
if (trackMsg.has_conactpitch())
{
track.Pitch.setValue(trackMsg.contactspeed());
}
if (trackMsg.has_contactrcs())
{
track.RCS.setValue(trackMsg.contactrcs());

View File

@@ -1,3 +1,4 @@
#include "SimCore/Identifier.hpp"
#include <SimCore/Messages/SimTrack.hpp>
#include <WHISPER/Messages/Message.hpp>
#include <SimCore/SimCore.hpp>
@@ -14,6 +15,8 @@ SCENARIO("Testing the SimCore Track")
{
GIVEN("different Attributes for a Track in different forms")
{
auto OwnID = SimCore::Identifier();
Eigen::Vector3d GeocentPos1;
GeocentPos1(SimCore::GeocentricPosition::X) = 3784014.333;
GeocentPos1(SimCore::GeocentricPosition::Y) = 899869.779;
@@ -52,17 +55,23 @@ SCENARIO("Testing the SimCore Track")
auto idEmi = emi1.getID();
track.addEmission(emi1);
// serializedMSG = track.buildMessage(parentID).serialize();
// msg = std::make_shared<WHISPER::Message>(serializedMSG);
// if (msg.get()->msgType_ == WHISPER::GROUND_TRUTH_TRACK) {
serializedMSG = track.buildMessage(OwnID).serialize();
msg = std::make_shared<WHISPER::Message>(serializedMSG);
if (msg.get()->msgType_ == WHISPER::GROUND_TRUTH_TRACK) {
// trackPtr = std::make_shared<SimCore::SimTrack>(std::move(SimCore::SimTrack::unpack(*msg)));
// }
LOG_S(INFO)<< msg.get()->topic_;
trackPtr = std::make_shared<SimCore::SimTrack>(std::move(SimCore::SimTrack::unpack(*msg)));
}
// std::string trackstring = track.buildMessage(parentID).serialize();
// SimCore::GroundTruthTrack trackDeserialized = SimCore::GroundTruthTrack::unpack(*msg);
SimCore::SimTrack trackDeserialized = SimCore::SimTrack::unpack(*msg);
std::shared_ptr<SimCore::Emission> esm= track.getEmission(emi1.getID());
esm->packEmission();
@@ -76,11 +85,10 @@ SCENARIO("Testing the SimCore Track")
REQUIRE(track.getEmission(emi1.getID()).get()->getID() == idEmi);
// REQUIRE(msg.get()->msgType_ == WHISPER::GROUND_TRUTH_TRACK);
// REQUIRE(trackPtr->Speed.getValue() == speed);
// REQUIRE(trackPtr->getPosition().getGeocentricPos() == GeocentPos1);
// REQUIRE(trackPtr->getIdentifier().getNumber() > 0);
// REQUIRE(trackDeserialized.getIdentifier().getNumber() > 0);
REQUIRE(trackPtr->Speed.getValue() == speed);
REQUIRE(trackPtr->getPosition().getGeocentricPos() == GeocentPos1);
REQUIRE(trackDeserialized.getEmission(emi1.getID()).get()->getID() == idEmi);