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

Gauss Markov movement model. More...

#include <GaussMarkovMobility.h>

Inheritance diagram for inet::GaussMarkovMobility:
inet::LineSegmentsMobilityBase inet::MovingMobilityBase inet::MobilityBase inet::IMobility

Public Member Functions

virtual double getMaxSpeed () const override
 Returns the maximum possible speed at any future time. More...
 
 GaussMarkovMobility ()
 
- Public Member Functions inherited from inet::LineSegmentsMobilityBase
 LineSegmentsMobilityBase ()
 
- Public Member Functions inherited from inet::MovingMobilityBase
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 EulerAngles getCurrentAngularPosition () override
 Returns the current angular position at the current simulation time. More...
 
- Public Member Functions inherited from inet::MobilityBase
virtual EulerAngles getCurrentAngularSpeed () override
 Returns the current angular speed at the current simulation 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::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...
 
void preventBorderHugging ()
 If the host is too close to the border it is repelled. More...
 
virtual void move () override
 Move the host. More...
 
virtual void setTargetPosition () override
 Calculate a new target position to move to. More...
 
- Protected Member Functions inherited from inet::LineSegmentsMobilityBase
virtual void initializePosition () override
 Initializes mobility position. More...
 
- Protected Member Functions inherited from inet::MovingMobilityBase
 MovingMobilityBase ()
 
virtual ~MovingMobilityBase ()
 
virtual void handleSelfMessage (cMessage *message) override
 Called upon arrival of a self messages, subclasses must override. More...
 
void scheduleUpdate ()
 Schedules the move timer that will update the mobility state. More...
 
void moveAndUpdate ()
 Moves and notifies listeners. More...
 
- Protected Member Functions inherited from inet::MobilityBase
 MobilityBase ()
 
virtual void setInitialPosition ()
 Initializes the position from the display string or from module parameters. 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 speed
 speed of the host More...
 
double angle
 angle of linear motion More...
 
double alpha
 alpha parameter More...
 
int margin
 margin at which the host gets repelled from the border More...
 
double speedMean
 speed mean More...
 
double angleMean
 angle mean More...
 
double variance
 variance More...
 
- Protected Attributes inherited from inet::LineSegmentsMobilityBase
Coord targetPosition
 End position of current linear movement. More...
 
- Protected Attributes inherited from inet::MovingMobilityBase
cMessage * moveTimer
 The message used for mobility state changes. More...
 
simtime_t updateInterval
 The simulation time interval used to regularly signal mobility state changes. More...
 
bool stationary
 A mobility model may decide to become stationary at any time. More...
 
Coord lastSpeed
 The last speed that was reported at lastUpdate. More...
 
simtime_t lastUpdate
 The simulation time when the mobility state was last updated. More...
 
simtime_t nextChange
 The next simulation time when the mobility module needs to update its internal state. More...
 
- 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

Gauss Markov movement model.

See NED file for more info.

Author
Marcin Kosiba

Constructor & Destructor Documentation

inet::GaussMarkovMobility::GaussMarkovMobility ( )
27 {
28  speed = 0;
29  angle = 0;
30  alpha = 0;
31  margin = 0;
32  speedMean = 0;
33  angleMean = 0;
34  variance = 0;
35 }
double speedMean
speed mean
Definition: GaussMarkovMobility.h:39
double angleMean
angle mean
Definition: GaussMarkovMobility.h:40
double variance
variance
Definition: GaussMarkovMobility.h:41
int margin
margin at which the host gets repelled from the border
Definition: GaussMarkovMobility.h:38
double angle
angle of linear motion
Definition: GaussMarkovMobility.h:36
double alpha
alpha parameter
Definition: GaussMarkovMobility.h:37
double speed
speed of the host
Definition: GaussMarkovMobility.h:35

Member Function Documentation

virtual double inet::GaussMarkovMobility::getMaxSpeed ( ) const
inlineoverridevirtual

Returns the maximum possible speed at any future time.

Reimplemented from inet::MobilityBase.

59 { return speed; }
double speed
speed of the host
Definition: GaussMarkovMobility.h:35
void inet::GaussMarkovMobility::initialize ( int  stage)
overrideprotectedvirtual

Initializes mobility model parameters.

Reimplemented from inet::MovingMobilityBase.

38 {
40 
41  EV_TRACE << "initializing GaussMarkovMobility stage " << stage << endl;
42  if (stage == INITSTAGE_LOCAL) {
43  speedMean = par("speed");
44  angleMean = par("angle");
45  alpha = par("alpha");
46  margin = par("margin");
47  variance = par("variance");
48  angle = fmod(angle, 360);
49  //constrain alpha to [0.0;1.0]
50  alpha = fmax(0.0, alpha);
51  alpha = fmin(1.0, alpha);
52 
53  speed = speedMean;
54  angle = angleMean;
55  stationary = (speed == 0);
56  }
57 }
virtual void initialize(int stage) override
Initializes mobility model parameters.
Definition: MovingMobilityBase.cc:42
double speedMean
speed mean
Definition: GaussMarkovMobility.h:39
Local initializations.
Definition: InitStages.h:35
double angleMean
angle mean
Definition: GaussMarkovMobility.h:40
bool stationary
A mobility model may decide to become stationary at any time.
Definition: MovingMobilityBase.h:49
double variance
variance
Definition: GaussMarkovMobility.h:41
int margin
margin at which the host gets repelled from the border
Definition: GaussMarkovMobility.h:38
double angle
angle of linear motion
Definition: GaussMarkovMobility.h:36
double alpha
alpha parameter
Definition: GaussMarkovMobility.h:37
double speed
speed of the host
Definition: GaussMarkovMobility.h:35
void inet::GaussMarkovMobility::move ( )
overrideprotectedvirtual

Move the host.

Reimplemented from inet::LineSegmentsMobilityBase.

79 {
82  Coord dummy;
83  handleIfOutside(REFLECT, dummy, dummy, angle);
84 }
reflect off the wall
Definition: MobilityBase.h:61
virtual void move() override
Moves according to the mobility model to the current simulation time.
Definition: LineSegmentsMobilityBase.cc:40
virtual void handleIfOutside(BorderPolicy policy, Coord &targetPosition, Coord &speed, double &angle)
Invokes one of reflectIfOutside(), wrapIfOutside() and placeRandomlyIfOutside(), depending on the giv...
Definition: MobilityBase.cc:269
double angle
angle of linear motion
Definition: GaussMarkovMobility.h:36
void preventBorderHugging()
If the host is too close to the border it is repelled.
Definition: GaussMarkovMobility.cc:59
virtual int inet::GaussMarkovMobility::numInitStages ( ) const
inlineoverrideprotectedvirtual

Returns the required number of initialize stages.

Reimplemented from inet::MobilityBase.

44 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::GaussMarkovMobility::preventBorderHugging ( )
protected

If the host is too close to the border it is repelled.

Referenced by move().

60 {
61  bool left = (lastPosition.x < constraintAreaMin.x + margin);
62  bool right = (lastPosition.x >= constraintAreaMax.x - margin);
63  bool top = (lastPosition.y < constraintAreaMin.y + margin);
64  bool bottom = (lastPosition.y >= constraintAreaMax.y - margin);
65  if (top || bottom) {
66  angleMean = bottom ? 270.0 : 90.0;
67  if (right)
68  angleMean -= 45.0;
69  else if (left)
70  angleMean += 45.0;
71  }
72  else if (left)
73  angleMean = 0.0;
74  else if (right)
75  angleMean = 180.0;
76 }
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
double angleMean
angle mean
Definition: GaussMarkovMobility.h:40
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
int margin
margin at which the host gets repelled from the border
Definition: GaussMarkovMobility.h:38
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Coord constraintAreaMax
Definition: MobilityBase.h:75
void inet::GaussMarkovMobility::setTargetPosition ( )
overrideprotectedvirtual

Calculate a new target position to move to.

Implements inet::LineSegmentsMobilityBase.

87 {
88  // calculate new speed and direction based on the model
89  speed = alpha * speed
90  + (1.0 - alpha) * speedMean
91  + sqrt(1.0 - alpha * alpha)
92  * normal(0.0, 1.0)
93  * variance;
94 
95  angle = alpha * angle
96  + (1.0 - alpha) * angleMean
97  + sqrt(1.0 - alpha * alpha)
98  * normal(0.0, 1.0)
99  * variance;
100 
101  double rad = M_PI * angle / 180.0;
102  Coord direction(cos(rad), sin(rad));
103  nextChange = simTime() + updateInterval;
104  targetPosition = lastPosition + direction * speed * updateInterval.dbl();
105 
106  EV_DEBUG << " speed = " << speed << " angle = " << angle << endl;
107  EV_DEBUG << " mspeed = " << speedMean << " mangle = " << angleMean << endl;
108 }
double speedMean
speed mean
Definition: GaussMarkovMobility.h:39
compose< m, pow< m,-1 > > rad
Definition: Units.h:764
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1201
value< Value, pow< Unit, 1, 2 > > sqrt(const value< Value, Unit > &a)
Definition: Units.h:247
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
simtime_t nextChange
The next simulation time when the mobility module needs to update its internal state.
Definition: MovingMobilityBase.h:60
Coord targetPosition
End position of current linear movement.
Definition: LineSegmentsMobilityBase.h:41
#define M_PI
Definition: PlotFigure.cc:27
simtime_t updateInterval
The simulation time interval used to regularly signal mobility state changes.
Definition: MovingMobilityBase.h:44
double angleMean
angle mean
Definition: GaussMarkovMobility.h:40
double variance
variance
Definition: GaussMarkovMobility.h:41
double angle
angle of linear motion
Definition: GaussMarkovMobility.h:36
double alpha
alpha parameter
Definition: GaussMarkovMobility.h:37
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1195
double speed
speed of the host
Definition: GaussMarkovMobility.h:35

Member Data Documentation

double inet::GaussMarkovMobility::alpha
protected

alpha parameter

Referenced by GaussMarkovMobility(), initialize(), and setTargetPosition().

double inet::GaussMarkovMobility::angle
protected

angle of linear motion

Referenced by GaussMarkovMobility(), initialize(), move(), and setTargetPosition().

double inet::GaussMarkovMobility::angleMean
protected
int inet::GaussMarkovMobility::margin
protected

margin at which the host gets repelled from the border

Referenced by GaussMarkovMobility(), initialize(), and preventBorderHugging().

double inet::GaussMarkovMobility::speed
protected

speed of the host

Referenced by GaussMarkovMobility(), initialize(), and setTargetPosition().

double inet::GaussMarkovMobility::speedMean
protected

speed mean

Referenced by GaussMarkovMobility(), initialize(), and setTargetPosition().

double inet::GaussMarkovMobility::variance
protected

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