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 const CoordgetCurrentPosition () override
 Returns the position at the current simulation time. More...
 
virtual const CoordgetCurrentVelocity () override
 Returns the velocity at the current simulation time. More...
 
virtual const CoordgetCurrentAcceleration () override
 Returns the acceleration at the current simulation time. More...
 
virtual const QuaterniongetCurrentAngularPosition () override
 Returns the angular position at the current simulation time. More...
 
virtual const QuaterniongetCurrentAngularVelocity () override
 Returns the angular velocity at the current simulation time. More...
 
virtual const QuaterniongetCurrentAngularAcceleration () override
 Returns the angular acceleration at the current simulation time. More...
 
- Public Member Functions inherited from inet::MobilityBase
virtual const CoordgetConstraintAreaMax () const override
 Returns the maximum position along each axes for. More...
 
virtual const CoordgetConstraintAreaMin () const override
 Returns the minimum position along each axes for. 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...
 
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...
 
virtual void orient ()
 
- Protected Member Functions inherited from inet::MobilityBase
 MobilityBase ()
 
virtual int getId () const override
 
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 refreshDisplay () const override
 Moves the visual representation module's icon to the new position on the screen. More...
 
virtual void updateDisplayStringFromMobilityState () const
 
virtual void handleParameterChange (const char *name) override
 Allows changing parameters from the GUI. More...
 
virtual void handleMessage (cMessage *msg) override
 This modules should only receive self-messages. 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 * findSubjectModule ()
 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 &velocity, rad &angle, rad &elevation, Quaternion &quaternion)
 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 &velocity)
 Invokes one of reflectIfOutside(), wrapIfOutside() and placeRandomlyIfOutside(), depending on the given border policy. More...
 
virtual void handleIfOutside (BorderPolicy policy, Coord &targetPosition, Coord &velocity, rad &heading)
 
virtual void handleIfOutside (BorderPolicy policy, Coord &targetPosition, Coord &velocity, rad &heading, rad &elevation)
 
virtual void handleIfOutside (BorderPolicy policy, Coord &targetPosition, Coord &velocity, rad &heading, rad &elevation, Quaternion &quaternion)
 

Protected Attributes

double speed = 0.0
 speed of the host More...
 
double speedMean = 0.0
 speed mean More...
 
double speedStdDev = 0.0
 speed standard deviation More...
 
rad angle = rad(0.0)
 angle of linear motion More...
 
rad angleMean = rad(0.0)
 angle mean More...
 
rad angleStdDev = rad(0.0)
 angle standard deviation More...
 
double alpha = 0.0
 alpha parameter in [0;1] interval More...
 
double margin = 0.0
 margin at which the host gets repelled from the border 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 lastVelocity
 The last velocity that was reported at lastUpdate. More...
 
Quaternion lastAngularVelocity
 The last angular velocity 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...
 
bool faceForward
 
- Protected Attributes inherited from inet::MobilityBase
cModule * subjectModule
 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...
 
Quaternion lastOrientation
 The last orientation that was reported. More...
 
StringFormat format
 

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

◆ GaussMarkovMobility()

inet::GaussMarkovMobility::GaussMarkovMobility ( )
17 {
18 }

Member Function Documentation

◆ getMaxSpeed()

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

Returns the maximum possible speed at any future time.

Reimplemented from inet::MobilityBase.

48 { return speed; }

◆ initialize()

void inet::GaussMarkovMobility::initialize ( int  stage)
overrideprotectedvirtual

Initializes mobility model parameters.

Reimplemented from inet::MovingMobilityBase.

21 {
23 
24  EV_TRACE << "initializing GaussMarkovMobility stage " << stage << endl;
25  if (stage == INITSTAGE_LOCAL) {
26  speedMean = par("speed");
27  speedStdDev = par("speedStdDev");
28  angleMean = deg(fmod(deg(par("angle")).get(), 360.0));
29  angleStdDev = deg(par("angleStdDev"));
30  alpha = par("alpha");
31  if (alpha < 0.0 || alpha > 1.0)
32  throw cRuntimeError("The parameter 'alpha' is out of [0;1] interval");
33  // constrain alpha to [0.0;1.0]
34  margin = par("margin");
35  speed = speedMean;
36  angle = angleMean;
37  stationary = (speed == 0);
38  }
39 }

◆ move()

void inet::GaussMarkovMobility::move ( )
overrideprotectedvirtual

◆ numInitStages()

virtual int inet::GaussMarkovMobility::numInitStages ( ) const
inlineoverrideprotectedvirtual

Returns the required number of initialize stages.

Reimplemented from inet::MobilityBase.

33 { return NUM_INIT_STAGES; }

◆ preventBorderHugging()

void inet::GaussMarkovMobility::preventBorderHugging ( )
protected

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

42 {
43  bool left = (lastPosition.x < constraintAreaMin.x + margin);
44  bool right = (lastPosition.x >= constraintAreaMax.x - margin);
45  bool top = (lastPosition.y < constraintAreaMin.y + margin);
46  bool bottom = (lastPosition.y >= constraintAreaMax.y - margin);
47  if (top || bottom) {
48  angleMean = bottom ? deg(270.0) : deg(90.0);
49  if (right)
50  angleMean -= deg(45.0);
51  else if (left)
52  angleMean += deg(45.0);
53  }
54  else if (left)
55  angleMean = deg(0.0);
56  else if (right)
57  angleMean = deg(180.0);
58 }

Referenced by move().

◆ setTargetPosition()

void inet::GaussMarkovMobility::setTargetPosition ( )
overrideprotectedvirtual

Calculate a new target position to move to.

Implements inet::LineSegmentsMobilityBase.

68 {
69  // calculate new speed and direction based on the model
70  speed = alpha * speed
71  + (1.0 - alpha) * speedMean
72  + sqrt(1.0 - alpha * alpha) * normal(0.0, 1.0) * speedStdDev;
73 
74  angle = alpha * angle
75  + (1.0 - alpha) * angleMean
76  + rad(sqrt(1.0 - alpha * alpha) * normal(0.0, 1.0) * angleStdDev);
77 
78  Coord direction(cos(rad(angle).get()), sin(rad(angle).get()));
79  nextChange = simTime() + updateInterval;
80  targetPosition = lastPosition + direction * (speed * updateInterval.dbl());
81 
82  EV_DEBUG << " speed = " << speed << " angle = " << angle << endl;
83  EV_DEBUG << " mspeed = " << speedMean << " mangle = " << angleMean << endl;
84 }

Member Data Documentation

◆ alpha

double inet::GaussMarkovMobility::alpha = 0.0
protected

alpha parameter in [0;1] interval

Referenced by initialize(), and setTargetPosition().

◆ angle

rad inet::GaussMarkovMobility::angle = rad(0.0)
protected

angle of linear motion

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

◆ angleMean

rad inet::GaussMarkovMobility::angleMean = rad(0.0)
protected

angle mean

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

◆ angleStdDev

rad inet::GaussMarkovMobility::angleStdDev = rad(0.0)
protected

angle standard deviation

Referenced by initialize(), and setTargetPosition().

◆ margin

double inet::GaussMarkovMobility::margin = 0.0
protected

margin at which the host gets repelled from the border

Referenced by initialize(), and preventBorderHugging().

◆ speed

double inet::GaussMarkovMobility::speed = 0.0
protected

speed of the host

Referenced by initialize(), and setTargetPosition().

◆ speedMean

double inet::GaussMarkovMobility::speedMean = 0.0
protected

speed mean

Referenced by initialize(), and setTargetPosition().

◆ speedStdDev

double inet::GaussMarkovMobility::speedStdDev = 0.0
protected

speed standard deviation

Referenced by initialize(), and setTargetPosition().


The documentation for this class was generated from the following files:
inet::GaussMarkovMobility::alpha
double alpha
alpha parameter in [0;1] interval
Definition: GaussMarkovMobility.h:29
inet::GaussMarkovMobility::angleStdDev
rad angleStdDev
angle standard deviation
Definition: GaussMarkovMobility.h:28
inet::MobilityBase::REFLECT
@ REFLECT
reflect off the wall
Definition: MobilityBase.h:56
inet::MobilityBase::lastPosition
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:73
inet::units::units::deg
fscale< rad, rad2degScale > deg
Definition: Units.h:1158
inet::LineSegmentsMobilityBase::targetPosition
Coord targetPosition
End position of current linear movement.
Definition: LineSegmentsMobilityBase.h:28
inet::MovingMobilityBase::stationary
bool stationary
A mobility model may decide to become stationary at any time.
Definition: MovingMobilityBase.h:32
inet::Coord::x
double x
Definition: Coord.h:36
inet::GaussMarkovMobility::speedStdDev
double speedStdDev
speed standard deviation
Definition: GaussMarkovMobility.h:25
inet::units::cos
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1524
inet::units::sqrt
value< Value, pow< Unit, 1, 2 > > sqrt(const value< Value, Unit > &a)
Definition: Units.h:272
inet::GaussMarkovMobility::angleMean
rad angleMean
angle mean
Definition: GaussMarkovMobility.h:27
inet::LineSegmentsMobilityBase::move
virtual void move() override
Moves according to the mobility model to the current simulation time.
Definition: LineSegmentsMobilityBase.cc:31
inet::MovingMobilityBase::initialize
virtual void initialize(int stage) override
Initializes mobility model parameters.
Definition: MovingMobilityBase.cc:26
inet::MobilityBase::handleIfOutside
virtual void handleIfOutside(BorderPolicy policy, Coord &targetPosition, Coord &velocity)
Invokes one of reflectIfOutside(), wrapIfOutside() and placeRandomlyIfOutside(), depending on the giv...
Definition: MobilityBase.cc:353
inet::MobilityBase::constraintAreaMax
Coord constraintAreaMax
Definition: MobilityBase.h:70
inet::MovingMobilityBase::nextChange
simtime_t nextChange
The next simulation time when the mobility module needs to update its internal state.
Definition: MovingMobilityBase.h:46
inet::MovingMobilityBase::updateInterval
simtime_t updateInterval
The simulation time interval used to regularly signal mobility state changes.
Definition: MovingMobilityBase.h:27
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::GaussMarkovMobility::speed
double speed
speed of the host
Definition: GaussMarkovMobility.h:23
inet::MovingMobilityBase::lastVelocity
Coord lastVelocity
The last velocity that was reported at lastUpdate.
Definition: MovingMobilityBase.h:35
inet::GaussMarkovMobility::margin
double margin
margin at which the host gets repelled from the border
Definition: GaussMarkovMobility.h:30
inet::MobilityBase::constraintAreaMin
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:70
inet::GaussMarkovMobility::angle
rad angle
angle of linear motion
Definition: GaussMarkovMobility.h:26
inet::units::values::rad
value< double, units::rad > rad
Definition: Units.h:1245
inet::Coord::y
double y
Definition: Coord.h:37
inet::units::sin
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1518
inet::GaussMarkovMobility::preventBorderHugging
void preventBorderHugging()
If the host is too close to the border it is repelled.
Definition: GaussMarkovMobility.cc:41
inet::GaussMarkovMobility::speedMean
double speedMean
speed mean
Definition: GaussMarkovMobility.h:24