ADD: added update of simtrack
This commit is contained in:
@@ -35,6 +35,7 @@ namespace SimCore
|
||||
/// @return
|
||||
std::string getName();
|
||||
|
||||
|
||||
Data<double> Frequency;
|
||||
Data<double> Range;
|
||||
Data<double> Bandwidth;
|
||||
|
||||
@@ -10,33 +10,24 @@
|
||||
|
||||
#include <SimCore/Messages/Emission.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace SimCore
|
||||
{
|
||||
class SimTrack
|
||||
{
|
||||
private:
|
||||
const SimCore::Identifier ID_;
|
||||
|
||||
const WHISPER::SourceType SourceType_;
|
||||
|
||||
Position position_;
|
||||
|
||||
std::vector<Emission> EmitterList;
|
||||
|
||||
public:
|
||||
SimTrack();
|
||||
SimTrack(WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind);
|
||||
SimTrack( SimCore::Identifier id ,WHISPER::SourceType sourcetype,SimCore::EntityKind entityKind );
|
||||
|
||||
SimTrack(WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);
|
||||
|
||||
SimTrack(SimCore::Identifier id, WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);
|
||||
|
||||
~SimTrack();
|
||||
|
||||
/// @brief
|
||||
/// @param pos
|
||||
void setPosition(SimCore::Position pos);
|
||||
|
||||
/// @brief
|
||||
/// @param x
|
||||
/// @param y
|
||||
@@ -44,8 +35,30 @@ namespace SimCore
|
||||
void setPosition(double x, double y, double z);
|
||||
SimCore::Position getPosition();
|
||||
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> Course;
|
||||
Data<double> Pitch;
|
||||
@@ -53,12 +66,14 @@ namespace SimCore
|
||||
|
||||
Data<SimCore::EntityKind> EntityKind;
|
||||
|
||||
private:
|
||||
const SimCore::Identifier ID_;
|
||||
|
||||
WHISPER::Message buildMessage(SimCore::Identifier parentID);
|
||||
static SimTrack unpack(WHISPER::Message msg);
|
||||
const WHISPER::SourceType SourceType_;
|
||||
|
||||
Position position_;
|
||||
|
||||
std::vector<std::shared_ptr<SimCore::Emission>> EmissionList;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ namespace SimCore
|
||||
:ID_(SimCore::Identifier())
|
||||
{
|
||||
this->name_.setValue(name);
|
||||
|
||||
}
|
||||
|
||||
SimCore::Emission::Emission(std::string name, SimCore::Identifier id)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace SimCore
|
||||
{
|
||||
[[deprecated("use SimTrack instead")]]
|
||||
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_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));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -23,6 +23,8 @@ SCENARIO("Testing the SimCore Track")
|
||||
GeodesPos1(SimCore::GeodesicPosition::LONGITUDE) = 13.376935;
|
||||
GeodesPos1(SimCore::GeodesicPosition::HEIGHT) = 0;
|
||||
|
||||
SimCore::Emission emi1("test Radar");
|
||||
|
||||
SimCore::Position pos1(GeocentPos1(SimCore::X),GeocentPos1(SimCore::Y),GeocentPos1(SimCore::Z));
|
||||
|
||||
double course = 90;
|
||||
@@ -47,6 +49,9 @@ SCENARIO("Testing the SimCore Track")
|
||||
if (track.getPosition() == pos) {
|
||||
testOperator = true;
|
||||
}
|
||||
|
||||
auto idEmi = emi1.getID();
|
||||
track.addEmission(emi1);
|
||||
// serializedMSG = track.buildMessage(parentID).serialize();
|
||||
// msg = std::make_shared<WHISPER::Message>(serializedMSG);
|
||||
|
||||
@@ -58,7 +63,8 @@ SCENARIO("Testing the SimCore Track")
|
||||
// std::string trackstring = track.buildMessage(parentID).serialize();
|
||||
|
||||
// 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")
|
||||
{
|
||||
@@ -66,6 +72,8 @@ SCENARIO("Testing the SimCore Track")
|
||||
REQUIRE(track.Course.getValue() == course);
|
||||
REQUIRE(track.Speed.getValue() == speed);
|
||||
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(trackPtr->Speed.getValue() == speed);
|
||||
|
||||
Reference in New Issue
Block a user