Skip to content

Commit

Permalink
Pass additional information to the Signal
Browse files Browse the repository at this point in the history
Add information about emission/reception orientation/antenna to the
signal. This might be relevant for some analogue models.
  • Loading branch information
mxsrc authored and sommer committed Dec 19, 2018
1 parent 5192fd4 commit 7be9f34
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/veins/base/phyLayer/BasePhyLayer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ void BasePhyLayer::filterSignal(AirFrame* frame)
const Coord senderOrientation = senderPOA.orientation;

// add position information to signal
signal.setSenderPos(senderPosition);
signal.setReceiverPos(receiverPosition);
signal.setSenderPoa(senderPOA);
signal.setReceiverPoa({receiverPosition, receiverOrientation, antenna});

// compute gains at sender and receiver antenna
double receiverGain = antenna->getGain(receiverPosition.getPositionAt(), receiverOrientation, senderPosition.getPositionAt());
Expand Down
24 changes: 12 additions & 12 deletions src/veins/base/toolbox/Signal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Signal::Signal(const Signal& other)
, propagationDelay(other.propagationDelay)
, analogueModelList(other.analogueModelList)
, numAnalogueModelsApplied(other.numAnalogueModelsApplied)
, senderPos(other.senderPos)
, receiverPos(other.receiverPos)
, senderPoa(other.senderPoa)
, receiverPoa(other.receiverPoa)
{
}

Expand Down Expand Up @@ -242,24 +242,24 @@ void Signal::applyAllAnalogueModels()
}
}

AntennaPosition Signal::getSenderPos() const
POA Signal::getSenderPoa() const
{
return senderPos;
return senderPoa;
}

AntennaPosition Signal::getReceiverPos() const
POA Signal::getReceiverPoa() const
{
return receiverPos;
return receiverPoa;
}

void Signal::setSenderPos(AntennaPosition pos)
void Signal::setSenderPoa(const POA& poa)
{
senderPos = pos;
senderPoa = poa;
}

void Signal::setReceiverPos(AntennaPosition pos)
void Signal::setReceiverPoa(const POA& poa)
{
receiverPos = pos;
receiverPoa = poa;
}

simtime_t_cref Signal::getSendingStart() const
Expand Down Expand Up @@ -331,8 +331,8 @@ Signal& Signal::operator=(const Signal& other)

analogueModelList = other.getAnalogueModelList();
numAnalogueModelsApplied = other.getNumAnalogueModelsApplied();
senderPos = other.getSenderPos();
receiverPos = other.getReceiverPos();
senderPoa = other.getSenderPoa();
receiverPoa = other.getReceiverPoa();

timingUsed = other.hasTiming();
sendingStart = other.getSendingStart();
Expand Down
28 changes: 14 additions & 14 deletions src/veins/base/toolbox/Signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "veins/veins.h"

#include "veins/base/utils/AntennaPosition.h"
#include "veins/base/utils/POA.h"
#include "veins/base/utils/Coord.h"
#include "veins/base/toolbox/Spectrum.h"
#include "veins/base/phyLayer/AnalogueModel.h"
Expand Down Expand Up @@ -287,32 +287,32 @@ class Signal {
///@}

/**
* @name Sender and receiver positions
* @name Sender and receiver POAs
*/
///@{
/**
* Get this signal's sender postition.
* Get this signal's sender POA.
*/
AntennaPosition getSenderPos() const;
POA getSenderPoa() const;

/**
* Get this signal's receiver postition.
* Get this signal's receiver POA.
*/
AntennaPosition getReceiverPos() const;
POA getReceiverPoa() const;

/**
* Set this signal's sender postition.
* Set this signal's sender POA.
*
* @param pos the new sender position
* @param poa the new sender POA
*/
void setSenderPos(AntennaPosition pos);
void setSenderPoa(const POA& poa);

/**
* Set this signal's receiver postition.
* Set this signal's receiver POA.
*
* @param pos the new receiver position
* @param poa the new receiver POA
*/
void setReceiverPos(AntennaPosition pos);
void setReceiverPoa(const POA& poa);
///@}

/**
Expand Down Expand Up @@ -511,8 +511,8 @@ class Signal {
AnalogueModelList* analogueModelList = nullptr;
uint16_t numAnalogueModelsApplied = 0;

AntennaPosition senderPos;
AntennaPosition receiverPos;
POA senderPoa;
POA receiverPoa;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/veins/modules/analogueModel/BreakpointPathlossModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ using Veins::AirFrame;

void BreakpointPathlossModel::filterSignal(Signal* signal)
{
auto senderPos = signal->getSenderPos().getPositionAt();
auto receiverPos = signal->getReceiverPos().getPositionAt();
auto senderPos = signal->getSenderPoa().pos.getPositionAt();
auto receiverPos = signal->getReceiverPoa().pos.getPositionAt();

/** Calculate the distance factor */
double distance = useTorus ? receiverPos.sqrTorusDist(senderPos, playgroundSize) : receiverPos.sqrdist(senderPos);
Expand Down
4 changes: 2 additions & 2 deletions src/veins/modules/analogueModel/NakagamiFading.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ using namespace Veins;
*/
void NakagamiFading::filterSignal(Signal* signal)
{
auto senderPos = signal->getSenderPos().getPositionAt();
auto receiverPos = signal->getReceiverPos().getPositionAt();
auto senderPos = signal->getSenderPoa().pos.getPositionAt();
auto receiverPos = signal->getReceiverPoa().pos.getPositionAt();

const double M_CLOSE = 1.5;
const double M_FAR = 0.75;
Expand Down
4 changes: 2 additions & 2 deletions src/veins/modules/analogueModel/PERModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ using Veins::AirFrame;

void PERModel::filterSignal(Signal* signal)
{
auto senderPos = signal->getSenderPos().getPositionAt();
auto receiverPos = signal->getReceiverPos().getPositionAt();
auto senderPos = signal->getSenderPoa().pos.getPositionAt();
auto receiverPos = signal->getReceiverPoa().pos.getPositionAt();

double attenuationFactor = 1; // no attenuation
if (packetErrorRate > 0 && RNGCONTEXT uniform(0, 1) < packetErrorRate) {
Expand Down
4 changes: 2 additions & 2 deletions src/veins/modules/analogueModel/SimpleObstacleShadowing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ SimpleObstacleShadowing::SimpleObstacleShadowing(cComponent* owner, ObstacleCont

void SimpleObstacleShadowing::filterSignal(Signal* signal)
{
auto senderPos = signal->getSenderPos().getPositionAt();
auto receiverPos = signal->getReceiverPos().getPositionAt();
auto senderPos = signal->getSenderPoa().pos.getPositionAt();
auto receiverPos = signal->getReceiverPoa().pos.getPositionAt();

double factor = obstacleControl.calculateAttenuation(senderPos, receiverPos);

Expand Down
4 changes: 2 additions & 2 deletions src/veins/modules/analogueModel/SimplePathlossModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using Veins::AirFrame;

void SimplePathlossModel::filterSignal(Signal* signal)
{
auto senderPos = signal->getSenderPos().getPositionAt();
auto receiverPos = signal->getReceiverPos().getPositionAt();
auto senderPos = signal->getSenderPoa().pos.getPositionAt();
auto receiverPos = signal->getReceiverPoa().pos.getPositionAt();

/** Calculate the distance factor */
double sqrDistance = useTorus ? receiverPos.sqrTorusDist(senderPos, playgroundSize) : receiverPos.sqrdist(senderPos);
Expand Down
4 changes: 2 additions & 2 deletions src/veins/modules/analogueModel/TwoRayInterferenceModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ using namespace Veins;

void TwoRayInterferenceModel::filterSignal(Signal* signal)
{
auto senderPos = signal->getSenderPos().getPositionAt();
auto receiverPos = signal->getReceiverPos().getPositionAt();
auto senderPos = signal->getSenderPoa().pos.getPositionAt();
auto receiverPos = signal->getReceiverPoa().pos.getPositionAt();

const Coord senderPos2D(senderPos.x, senderPos.y);
const Coord receiverPos2D(receiverPos.x, receiverPos.y);
Expand Down
6 changes: 3 additions & 3 deletions src/veins/modules/analogueModel/VehicleObstacleShadowing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ VehicleObstacleShadowing::VehicleObstacleShadowing(cComponent* owner, VehicleObs

void VehicleObstacleShadowing::filterSignal(Signal* signal)
{
auto senderPos = signal->getSenderPos().getPositionAt();
auto receiverPos = signal->getReceiverPos().getPositionAt();
auto senderPos = signal->getSenderPoa().pos.getPositionAt();
auto receiverPos = signal->getReceiverPoa().pos.getPositionAt();

auto potentialObstacles = vehicleObstacleControl.getPotentialObstacles(signal->getSenderPos(), signal->getReceiverPos(), *signal);
auto potentialObstacles = vehicleObstacleControl.getPotentialObstacles(signal->getSenderPoa().pos, signal->getReceiverPoa().pos, *signal);

if (potentialObstacles.size() < 1) return;

Expand Down
13 changes: 6 additions & 7 deletions subprojects/veins_catch/src/TwoRayInterferenceModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,29 @@ SCENARIO("TwoRayInterferenceModel", "[analogueModel]")
{

AirFrame frame = createAirframe(2.4e9, 10e6, 0, .001, 1);
Signal& s = frame.getSignal();
TwoRayInterferenceModel tri(&dc, 1.02);
int dummyId = -1;

AntennaPosition senderPos(dummyId, Coord(0, 0, 2), Coord(0, 0, 0), simTime());
Signal& s = frame.getSignal();
s.setSenderPoa({{dummyId, Coord(0, 0, 2), Coord(0, 0, 0), simTime()}, {}, nullptr});

WHEN("the receiver is at (10,0)")
{
AntennaPosition receiverPos(dummyId, Coord(10, 0, 2), Coord(0, 0, 0), simTime());
s.setReceiverPoa({{dummyId, Coord(10, 0, 2), Coord(0, 0, 0), simTime()}, {}, nullptr});

THEN("TwoRayInterferenceModel drops power from 1 to 959.5e-9")
{
tri.filterSignal(&s, senderPos, receiverPos);
tri.filterSignal(&s);
REQUIRE(s.atFrequency(2.4e9) == Approx(9.5587819943e-07).epsilon(1e-9));
}
}

WHEN("the receiver is at (100,0)")
{
AntennaPosition receiverPos(dummyId, Coord(100, 0, 2), Coord(0, 0, 0), simTime());
s.setReceiverPoa({{dummyId, Coord(100, 0, 2), Coord(0, 0, 0), simTime()}, {}, nullptr});

THEN("TwoRayInterferenceModel drops power from 1 to 20.3e-9")
{
tri.filterSignal(&s, senderPos, receiverPos);
tri.filterSignal(&s);
REQUIRE(s.atFrequency(2.4e9) == Approx(2.0317806459e-08).epsilon(1e-9));
}
}
Expand Down

0 comments on commit 7be9f34

Please sign in to comment.