INET Framework for OMNeT++/OMNEST
inet::LinearNodeDistributionMobility Class Reference

Mobility model which places all hosts at constant distances in a line with an orientation. More...

#include <LinearNodeDistributionMobility.h>

Inheritance diagram for inet::LinearNodeDistributionMobility:
inet::StationaryMobility inet::MobilityBase inet::IMobility

Public Member Functions

 LinearNodeDistributionMobility ()
 
- Public Member Functions inherited from inet::StationaryMobility
 StationaryMobility ()
 
 StationaryMobility (Coord position)
 
virtual Coord getCurrentPosition () override
 Returns the current position at the current simulation time. More...
 
virtual Coord getCurrentSpeed () override
 Returns the current speed at the current simulation time. More...
 
virtual double getMaxSpeed () const override
 Returns the maximum possible speed at any future time. More...
 
virtual Coord getConstraintAreaMax () const override
 Returns the current angular acceleration at the current simulation time. More...
 
virtual Coord getConstraintAreaMin () const override
 
- Public Member Functions inherited from inet::MobilityBase
virtual EulerAngles getCurrentAngularPosition () override
 Returns the current acceleration at the current simulation time. More...
 
virtual EulerAngles getCurrentAngularSpeed () override
 Returns the current angular speed at the current simulation time. More...
 
- Public Member Functions inherited from inet::IMobility
virtual ~IMobility ()
 

Protected Member Functions

virtual int numInitStages () const override
 Returns the required number of initialize stages. More...
 
virtual void initialize (int stage) override
 Initializes mobility model parameters. More...
 
virtual void setInitialPosition () override
 Initializes the position according to the mobility model. More...
 
virtual void finish () override
 Save the host position. More...
 
- Protected Member Functions inherited from inet::StationaryMobility
virtual void handleSelfMessage (cMessage *message) override
 Never happens. More...
 
- Protected Member Functions inherited from inet::MobilityBase
 MobilityBase ()
 
virtual void initializePosition ()
 Initializes mobility position. More...
 
virtual void checkPosition ()
 Checks whether the position is valid or not. More...
 
virtual void initializeOrientation ()
 Initializes the orientation from module parameters. More...
 
virtual void handleMessage (cMessage *msg) override
 This modules should only receive self-messages. More...
 
virtual void updateVisualRepresentation ()
 Moves the visual representation module's icon to the new position on the screen. More...
 
virtual void emitMobilityStateChangedSignal ()
 Emits a signal with the updated mobility state. More...
 
virtual Coord getRandomPosition ()
 Returns a new random position satisfying the constraint area. More...
 
virtual cModule * findVisualRepresentation ()
 Returns the module that represents the object moved by this mobility module. More...
 
virtual bool isOutside ()
 Returns true if the mobility is outside of the constraint area. More...
 
virtual void reflectIfOutside (Coord &targetPosition, Coord &speed, double &angle)
 Utility function to reflect the node if it goes outside the constraint area. More...
 
virtual void wrapIfOutside (Coord &targetPosition)
 Utility function to wrap the node to the opposite edge (torus) if it goes outside the constraint area. More...
 
virtual void placeRandomlyIfOutside (Coord &targetPosition)
 Utility function to place the node randomly if it goes outside the constraint area. More...
 
virtual void raiseErrorIfOutside ()
 Utility function to raise an error if the node gets outside the constraint area. More...
 
virtual void handleIfOutside (BorderPolicy policy, Coord &targetPosition, Coord &speed, double &angle)
 Invokes one of reflectIfOutside(), wrapIfOutside() and placeRandomlyIfOutside(), depending on the given border policy. More...
 

Protected Attributes

double separation
 
double initialX
 
double initialY
 
double orientation
 
- Protected Attributes inherited from inet::MobilityBase
cModule * visualRepresentation
 Pointer to visual representation module, to speed up repeated access. More...
 
const CanvasProjectioncanvasProjection
 The 2D projection used on the canvas. More...
 
Coord constraintAreaMin
 3 dimensional position and size of the constraint area (in meters). More...
 
Coord constraintAreaMax
 
Coord lastPosition
 The last position that was reported. More...
 
EulerAngles lastOrientation
 The last position that was reported. More...
 

Additional Inherited Members

- Public Types inherited from inet::MobilityBase
enum  BorderPolicy { REFLECT, WRAP, PLACERANDOMLY, RAISEERROR }
 Selects how a mobility module should behave if it reaches the edge of the constraint area. More...
 
- Static Public Attributes inherited from inet::IMobility
static simsignal_t mobilityStateChangedSignal = cComponent::registerSignal("mobilityStateChanged")
 A signal used to publish mobility state changes. More...
 

Detailed Description

Mobility model which places all hosts at constant distances in a line with an orientation.

Author
Alfonso Ariza

Constructor & Destructor Documentation

inet::LinearNodeDistributionMobility::LinearNodeDistributionMobility ( )
26 {
27  initialX = 0;
28  initialY = 0;
29  separation = 0;
30  orientation = 0;
31 }
double orientation
Definition: LinearNodeDistributionMobility.h:42
double initialY
Definition: LinearNodeDistributionMobility.h:41
double initialX
Definition: LinearNodeDistributionMobility.h:40
double separation
Definition: LinearNodeDistributionMobility.h:39

Member Function Documentation

void inet::LinearNodeDistributionMobility::finish ( )
overrideprotectedvirtual

Save the host position.

64 {
65  MobilityBase::finish();
66  recordScalar("x", lastPosition.x);
67  recordScalar("y", lastPosition.y);
68 }
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
void inet::LinearNodeDistributionMobility::initialize ( int  stage)
overrideprotectedvirtual

Initializes mobility model parameters.

Reimplemented from inet::MobilityBase.

34 {
36 
37  EV_TRACE << "initializing LinearNodeDistributionMobility stage " << stage << endl;
38  if (stage == INITSTAGE_LOCAL) {
39  initialX = par("initialX").doubleValue();
40  initialY = par("initialY").doubleValue();
41  separation = par("separation").doubleValue();
42  orientation = par("orientation").doubleValue();
43  }
44 }
double orientation
Definition: LinearNodeDistributionMobility.h:42
virtual void initialize(int stage) override
Initializes mobility model parameters.
Definition: MobilityBase.cc:63
double initialY
Definition: LinearNodeDistributionMobility.h:41
Local initializations.
Definition: InitStages.h:35
double initialX
Definition: LinearNodeDistributionMobility.h:40
double separation
Definition: LinearNodeDistributionMobility.h:39
virtual int inet::LinearNodeDistributionMobility::numInitStages ( ) const
inlineoverrideprotectedvirtual

Returns the required number of initialize stages.

Reimplemented from inet::MobilityBase.

45 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::LinearNodeDistributionMobility::setInitialPosition ( )
overrideprotectedvirtual

Initializes the position according to the mobility model.

Reimplemented from inet::MobilityBase.

47 {
48  int index = visualRepresentation->getIndex();
49  double rad = M_PI * orientation / 180.0;
50  Coord initialPos;
51  initialPos.x = initialX;
52  initialPos.y = initialY;
53  initialPos.z = 0;
54  Coord direction(cos(rad), sin(rad));
55  lastPosition = initialPos + (direction * (index * separation));
57  lastPosition.x -= 1;
59  lastPosition.y -= 1;
60  lastPosition.z = 0;
61 }
double orientation
Definition: LinearNodeDistributionMobility.h:42
compose< m, pow< m,-1 > > rad
Definition: Units.h:764
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1201
cModule * visualRepresentation
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:69
double z
Definition: Coord.h:51
double initialY
Definition: LinearNodeDistributionMobility.h:41
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
#define M_PI
Definition: PlotFigure.cc:27
double initialX
Definition: LinearNodeDistributionMobility.h:40
double separation
Definition: LinearNodeDistributionMobility.h:39
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1195
Coord constraintAreaMax
Definition: MobilityBase.h:75

Member Data Documentation

double inet::LinearNodeDistributionMobility::initialX
protected
double inet::LinearNodeDistributionMobility::initialY
protected
double inet::LinearNodeDistributionMobility::orientation
protected
double inet::LinearNodeDistributionMobility::separation
protected

The documentation for this class was generated from the following files: