ADD: added update of simtrack
This commit is contained in:
@@ -35,6 +35,7 @@ namespace SimCore
|
|||||||
/// @return
|
/// @return
|
||||||
std::string getName();
|
std::string getName();
|
||||||
|
|
||||||
|
|
||||||
Data<double> Frequency;
|
Data<double> Frequency;
|
||||||
Data<double> Range;
|
Data<double> Range;
|
||||||
Data<double> Bandwidth;
|
Data<double> Bandwidth;
|
||||||
|
|||||||
@@ -10,26 +10,16 @@
|
|||||||
|
|
||||||
#include <SimCore/Messages/Emission.hpp>
|
#include <SimCore/Messages/Emission.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace SimCore
|
namespace SimCore
|
||||||
{
|
{
|
||||||
class SimTrack
|
class SimTrack
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
const SimCore::Identifier ID_;
|
|
||||||
|
|
||||||
const WHISPER::SourceType SourceType_;
|
|
||||||
|
|
||||||
Position position_;
|
|
||||||
|
|
||||||
std::vector<Emission> EmitterList;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimTrack();
|
SimTrack();
|
||||||
|
|
||||||
SimTrack(WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);
|
SimTrack(WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);
|
||||||
|
|
||||||
SimTrack(SimCore::Identifier id, WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);
|
SimTrack(SimCore::Identifier id, WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);
|
||||||
|
|
||||||
~SimTrack();
|
~SimTrack();
|
||||||
@@ -37,6 +27,7 @@ namespace SimCore
|
|||||||
/// @brief
|
/// @brief
|
||||||
/// @param pos
|
/// @param pos
|
||||||
void setPosition(SimCore::Position pos);
|
void setPosition(SimCore::Position pos);
|
||||||
|
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @param x
|
/// @param x
|
||||||
/// @param y
|
/// @param y
|
||||||
@@ -44,8 +35,30 @@ namespace SimCore
|
|||||||
void setPosition(double x, double y, double z);
|
void setPosition(double x, double y, double z);
|
||||||
SimCore::Position getPosition();
|
SimCore::Position getPosition();
|
||||||
SimCore::Identifier getIdentifier();
|
SimCore::Identifier getIdentifier();
|
||||||
|
/// @brief
|
||||||
|
/// @param emission
|
||||||
|
void addEmission(Emission emission);
|
||||||
|
|
||||||
|
/// @brief
|
||||||
|
/// @param id
|
||||||
|
/// @return
|
||||||
|
std::shared_ptr<Emission> getEmission(SimCore::Identifier id);
|
||||||
|
|
||||||
|
/// @brief couts the stored emissions
|
||||||
|
/// @return returns the amout of emission
|
||||||
|
size_t coutEmissions();
|
||||||
|
|
||||||
|
/// @brief return a WHISPER Message out of a simtrack object
|
||||||
|
/// @param parentID
|
||||||
|
/// @return WHISPER::Message
|
||||||
|
WHISPER::Message buildMessage(SimCore::Identifier parentID);
|
||||||
|
|
||||||
|
/// @brief creates a SimTrack out of a whisper message
|
||||||
|
/// @param msg
|
||||||
|
/// @return SimTrack Oject
|
||||||
|
static SimTrack unpack(WHISPER::Message msg);
|
||||||
|
|
||||||
|
public:
|
||||||
Data<double> Speed;
|
Data<double> Speed;
|
||||||
Data<double> Course;
|
Data<double> Course;
|
||||||
Data<double> Pitch;
|
Data<double> Pitch;
|
||||||
@@ -53,12 +66,14 @@ namespace SimCore
|
|||||||
|
|
||||||
Data<SimCore::EntityKind> EntityKind;
|
Data<SimCore::EntityKind> EntityKind;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const SimCore::Identifier ID_;
|
||||||
|
|
||||||
WHISPER::Message buildMessage(SimCore::Identifier parentID);
|
const WHISPER::SourceType SourceType_;
|
||||||
static SimTrack unpack(WHISPER::Message msg);
|
|
||||||
|
Position position_;
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<SimCore::Emission>> EmissionList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ namespace SimCore
|
|||||||
:ID_(SimCore::Identifier())
|
:ID_(SimCore::Identifier())
|
||||||
{
|
{
|
||||||
this->name_.setValue(name);
|
this->name_.setValue(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimCore::Emission::Emission(std::string name, SimCore::Identifier id)
|
SimCore::Emission::Emission(std::string name, SimCore::Identifier id)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace SimCore
|
namespace SimCore
|
||||||
{
|
{
|
||||||
|
[[deprecated("use SimTrack instead")]]
|
||||||
GroundTruthTrack::GroundTruthTrack(WHISPER::SourceType src,SimCore::Identifier id,SimCore::TrackKind kind):Track(src, id, kind)
|
GroundTruthTrack::GroundTruthTrack(WHISPER::SourceType src,SimCore::Identifier id,SimCore::TrackKind kind):Track(src, id, kind)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,14 @@ namespace SimCore
|
|||||||
SimTrack.mutable_entityidentifier()->set_parent(this->ID_.getParentNumber());
|
SimTrack.mutable_entityidentifier()->set_parent(this->ID_.getParentNumber());
|
||||||
SimTrack.mutable_entityidentifier()->set_uuid(this->ID_.getUUID());
|
SimTrack.mutable_entityidentifier()->set_uuid(this->ID_.getUUID());
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<Emission>>::iterator it;
|
||||||
|
for( it = EmissionList.begin(); it != EmissionList.end(); it++)
|
||||||
|
{
|
||||||
|
|
||||||
|
auto emissionMsg = it->get()->packEmission();
|
||||||
|
SimTrack.add_contactemissions()->CopyFrom(emissionMsg);
|
||||||
|
|
||||||
|
}
|
||||||
// SimTrack.mutable_timestamp()->set_seconds(time(NULL));
|
// SimTrack.mutable_timestamp()->set_seconds(time(NULL));
|
||||||
|
|
||||||
auto any = std::make_shared<google::protobuf::Any>();
|
auto any = std::make_shared<google::protobuf::Any>();
|
||||||
@@ -161,10 +168,42 @@ namespace SimCore
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < trackMsg.contactemissions_size(); i++)
|
||||||
|
{
|
||||||
|
const messages::SimTrack::Emission* emission = trackMsg.mutable_contactemissions(i);
|
||||||
|
auto obj = SimCore::Emission::unpackEmission(*emission);
|
||||||
|
track.addEmission(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimTrack::addEmission(Emission emission)
|
||||||
|
{
|
||||||
|
auto tmp = std::make_shared<Emission>(std::move(emission));
|
||||||
|
this->EmissionList.push_back(std::move(tmp));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Emission> SimTrack::getEmission(SimCore::Identifier id)
|
||||||
|
{
|
||||||
|
for(auto iterator = this->EmissionList.begin(); iterator != this->EmissionList.end(); iterator++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (iterator->get()->getID()== id)
|
||||||
|
{
|
||||||
|
return *iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SimTrack::coutEmissions()
|
||||||
|
{
|
||||||
|
return EmissionList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace SimCore
|
} // namespace SimCore
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ SCENARIO("Testing the SimCore Track")
|
|||||||
GeodesPos1(SimCore::GeodesicPosition::LONGITUDE) = 13.376935;
|
GeodesPos1(SimCore::GeodesicPosition::LONGITUDE) = 13.376935;
|
||||||
GeodesPos1(SimCore::GeodesicPosition::HEIGHT) = 0;
|
GeodesPos1(SimCore::GeodesicPosition::HEIGHT) = 0;
|
||||||
|
|
||||||
|
SimCore::Emission emi1("test Radar");
|
||||||
|
|
||||||
SimCore::Position pos1(GeocentPos1(SimCore::X),GeocentPos1(SimCore::Y),GeocentPos1(SimCore::Z));
|
SimCore::Position pos1(GeocentPos1(SimCore::X),GeocentPos1(SimCore::Y),GeocentPos1(SimCore::Z));
|
||||||
|
|
||||||
double course = 90;
|
double course = 90;
|
||||||
@@ -47,6 +49,9 @@ SCENARIO("Testing the SimCore Track")
|
|||||||
if (track.getPosition() == pos) {
|
if (track.getPosition() == pos) {
|
||||||
testOperator = true;
|
testOperator = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto idEmi = emi1.getID();
|
||||||
|
track.addEmission(emi1);
|
||||||
// serializedMSG = track.buildMessage(parentID).serialize();
|
// serializedMSG = track.buildMessage(parentID).serialize();
|
||||||
// msg = std::make_shared<WHISPER::Message>(serializedMSG);
|
// msg = std::make_shared<WHISPER::Message>(serializedMSG);
|
||||||
|
|
||||||
@@ -58,7 +63,8 @@ SCENARIO("Testing the SimCore Track")
|
|||||||
// std::string trackstring = track.buildMessage(parentID).serialize();
|
// std::string trackstring = track.buildMessage(parentID).serialize();
|
||||||
|
|
||||||
// SimCore::GroundTruthTrack trackDeserialized = SimCore::GroundTruthTrack::unpack(*msg);
|
// SimCore::GroundTruthTrack trackDeserialized = SimCore::GroundTruthTrack::unpack(*msg);
|
||||||
|
std::shared_ptr<SimCore::Emission> esm= track.getEmission(emi1.getID());
|
||||||
|
esm->packEmission();
|
||||||
|
|
||||||
THEN("check if Track attributes are correct")
|
THEN("check if Track attributes are correct")
|
||||||
{
|
{
|
||||||
@@ -66,6 +72,8 @@ SCENARIO("Testing the SimCore Track")
|
|||||||
REQUIRE(track.Course.getValue() == course);
|
REQUIRE(track.Course.getValue() == course);
|
||||||
REQUIRE(track.Speed.getValue() == speed);
|
REQUIRE(track.Speed.getValue() == speed);
|
||||||
REQUIRE(track.getPosition().getGeocentricPos() == pos.getGeocentricPos());
|
REQUIRE(track.getPosition().getGeocentricPos() == pos.getGeocentricPos());
|
||||||
|
REQUIRE(track.coutEmissions() > 0);
|
||||||
|
REQUIRE(track.getEmission(emi1.getID()).get()->getID() == idEmi);
|
||||||
|
|
||||||
// REQUIRE(msg.get()->msgType_ == WHISPER::GROUND_TRUTH_TRACK);
|
// REQUIRE(msg.get()->msgType_ == WHISPER::GROUND_TRUTH_TRACK);
|
||||||
// REQUIRE(trackPtr->Speed.getValue() == speed);
|
// REQUIRE(trackPtr->Speed.getValue() == speed);
|
||||||
|
|||||||
Reference in New Issue
Block a user