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

This is the local mobility module of MoBAN. More...

#include <MoBanLocal.h>

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

Public Member Functions

 MoBanLocal ()
 
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...
 
void setCoordinator (MoBanCoordinator *coordinator)
 
void setMoBANParameters (Coord referencePoint, double radius, double speed)
 
virtual double getMaxSpeed () const override
 Returns the maximum possible speed at any future time. More...
 
- Public Member Functions inherited from inet::LineSegmentsMobilityBase
 LineSegmentsMobilityBase ()
 
- Public Member Functions inherited from inet::MovingMobilityBase
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 refreshDisplay () const override
 Moves the visual representation module's icon to the new position on the screen. More...
 
virtual void initialize (int) override
 Initializes mobility model parameters. More...
 
virtual void setInitialPosition () override
 Initializes the position from the display string or from module parameters. More...
 
virtual void setTargetPosition () override
 Should be redefined in subclasses. More...
 
virtual void computeMaxSpeed ()
 
- Protected Member Functions inherited from inet::LineSegmentsMobilityBase
virtual void initializePosition () override
 Initializes mobility position. More...
 
virtual void move () override
 Moves according to the mobility model to the current simulation time. 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 checkPosition ()
 Checks whether the position is valid or not. More...
 
virtual void initializeOrientation ()
 Initializes the orientation from module parameters. 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

MoBanCoordinatorcoordinator
 The coordinator of the WBAN. More...
 
Coord referencePosition
 Reference position of the node in the current posture. More...
 
double radius
 The radius of local mobility of the node in the current posture. More...
 
double speed
 The speed of local mobility of the node in the current posture. More...
 
double maxSpeed
 The possible maximum speed at any future time. More...
 
Coord lastCompositePosition
 
Coord lastCompositeVelocity
 
- 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

This is the local mobility module of MoBAN.

It should be instantiated in each node that belongs to a WBAN. The NED parameter "coordinatorIndex" determines to which WBAN (MoBanCoordinator) it belongs. The current implementation uses the Random Walk Mobility Model (RWMM) for individual (local) movement within a sphere around the node, with given speed and sphere radius of the current posture. The reference point of the node in the current posture, the sphere radius, and the speed is given by the corresponding coordinator. RWMM determines the location of the node at any time relative to the given reference point.

Author
Majid Nabi

Constructor & Destructor Documentation

◆ MoBanLocal()

inet::MoBanLocal::MoBanLocal ( )
48 {
49  coordinator = nullptr;
51  radius = 0;
52  speed = 0;
53  maxSpeed = 0;
54 }

Member Function Documentation

◆ computeMaxSpeed()

void inet::MoBanLocal::computeMaxSpeed ( )
protectedvirtual
112 {
114 }

Referenced by initialize().

◆ getCurrentPosition()

const Coord & inet::MoBanLocal::getCurrentPosition ( )
overridevirtual

Returns the position at the current simulation time.

Reimplemented from inet::MovingMobilityBase.

◆ getCurrentVelocity()

const Coord & inet::MoBanLocal::getCurrentVelocity ( )
overridevirtual

Returns the velocity at the current simulation time.

Reimplemented from inet::MovingMobilityBase.

◆ getMaxSpeed()

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

Returns the maximum possible speed at any future time.

Reimplemented from inet::MobilityBase.

103 { return maxSpeed; }

◆ initialize()

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

Initializes mobility model parameters.

Reimplemented from inet::MovingMobilityBase.

57 {
59 
60  EV_TRACE << "initializing MoBanLocal stage " << stage << endl;
61  if (stage == INITSTAGE_LOCAL) {
62  WATCH(lastCompositePosition);
63  WATCH(lastCompositeVelocity);
64  WATCH_PTR(coordinator);
65  WATCH(referencePosition);
66  WATCH(radius);
67  WATCH(speed);
68  }
69  else if (stage == INITSTAGE_SINGLE_MOBILITY)
71 }

◆ numInitStages()

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

Returns the required number of initialize stages.

Reimplemented from inet::MobilityBase.

80 { return NUM_INIT_STAGES; }

◆ refreshDisplay()

void inet::MoBanLocal::refreshDisplay ( ) const
overrideprotectedvirtual

Moves the visual representation module's icon to the new position on the screen.

Reimplemented from inet::MobilityBase.

103 {
104  if (hasGUI() && subjectModule != nullptr) {
105  Coord coordinatorPosition = coordinator->getCurrentPosition();
106  subjectModule->getDisplayString().setTagArg("p", 0, lastPosition.x + coordinatorPosition.x);
107  subjectModule->getDisplayString().setTagArg("p", 1, lastPosition.y + coordinatorPosition.y);
108  }
109 }

◆ setCoordinator()

void inet::MoBanLocal::setCoordinator ( MoBanCoordinator coordinator)
inline

◆ setInitialPosition()

void inet::MoBanLocal::setInitialPosition ( )
overrideprotectedvirtual

Initializes the position from the display string or from module parameters.

Reimplemented from inet::MobilityBase.

74 {
76 }

◆ setMoBANParameters()

void inet::MoBanLocal::setMoBANParameters ( Coord  referencePoint,
double  radius,
double  speed 
)
117 {
118  Enter_Method("setMoBANParameters");
119  this->referencePosition = referencePoint;
120  this->radius = radius;
121  this->speed = speed;
123  lastVelocity = (targetPosition - lastPosition) / (nextChange - simTime()).dbl();
124  scheduleUpdate();
125 }

Referenced by inet::MoBanCoordinator::publishToNodes().

◆ setTargetPosition()

void inet::MoBanLocal::setTargetPosition ( )
overrideprotectedvirtual

Should be redefined in subclasses.

This method gets called when targetPosition and nextChange has been reached, and its task is to set a new targetPosition and nextChange. At the end of the movement sequence, it should set nextChange to -1.

Implements inet::LineSegmentsMobilityBase.

79 {
80  if (speed != 0) {
81  // find a uniformly random position within a sphere around the reference point
82  double x = uniform(-radius, radius);
83  double y = uniform(-radius, radius);
84  double z = uniform(-radius, radius);
85  while (x * x + y * y + z * z > radius * radius) {
86  x = uniform(-radius, radius);
87  y = uniform(-radius, radius);
88  z = uniform(-radius, radius);
89  }
90 
91  targetPosition = referencePosition + Coord(x, y, z);
92  Coord positionDelta = targetPosition - lastPosition;
93  double distance = positionDelta.length();
94  nextChange = simTime() + distance / speed;
95  }
96  else {
98  nextChange = -1;
99  }
100 }

Referenced by setMoBANParameters().

Member Data Documentation

◆ coordinator

MoBanCoordinator* inet::MoBanLocal::coordinator
protected

◆ lastCompositePosition

Coord inet::MoBanLocal::lastCompositePosition
protected

Referenced by getCurrentPosition(), and initialize().

◆ lastCompositeVelocity

Coord inet::MoBanLocal::lastCompositeVelocity
protected

Referenced by getCurrentVelocity(), and initialize().

◆ maxSpeed

double inet::MoBanLocal::maxSpeed
protected

The possible maximum speed at any future time.

Referenced by computeMaxSpeed(), and MoBanLocal().

◆ radius

double inet::MoBanLocal::radius
protected

The radius of local mobility of the node in the current posture.

Referenced by initialize(), MoBanLocal(), setMoBANParameters(), and setTargetPosition().

◆ referencePosition

Coord inet::MoBanLocal::referencePosition
protected

Reference position of the node in the current posture.

Referenced by initialize(), MoBanLocal(), setInitialPosition(), setMoBANParameters(), and setTargetPosition().

◆ speed

double inet::MoBanLocal::speed
protected

The speed of local mobility of the node in the current posture.

Referenced by initialize(), MoBanLocal(), setMoBANParameters(), and setTargetPosition().


The documentation for this class was generated from the following files:
inet::MoBanLocal::radius
double radius
The radius of local mobility of the node in the current posture.
Definition: MoBanLocal.h:68
inet::MoBanLocal::coordinator
MoBanCoordinator * coordinator
The coordinator of the WBAN.
Definition: MoBanLocal.h:62
inet::MoBanLocal::maxSpeed
double maxSpeed
The possible maximum speed at any future time.
Definition: MoBanLocal.h:74
inet::MobilityBase::lastPosition
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:73
inet::Coord::ZERO
static const Coord ZERO
Definition: Coord.h:27
inet::LineSegmentsMobilityBase::targetPosition
Coord targetPosition
End position of current linear movement.
Definition: LineSegmentsMobilityBase.h:28
inet::Coord::x
double x
Definition: Coord.h:36
inet::MoBanLocal::computeMaxSpeed
virtual void computeMaxSpeed()
Definition: MoBanLocal.cc:111
inet::MovingMobilityBase::scheduleUpdate
void scheduleUpdate()
Schedules the move timer that will update the mobility state.
Definition: MovingMobilityBase.cc:76
inet::MovingMobilityBase::getCurrentPosition
virtual const Coord & getCurrentPosition() override
Returns the position at the current simulation time.
Definition: MovingMobilityBase.cc:94
inet::MovingMobilityBase::initialize
virtual void initialize(int stage) override
Initializes mobility model parameters.
Definition: MovingMobilityBase.cc:26
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::MoBanLocal::setTargetPosition
virtual void setTargetPosition() override
Should be redefined in subclasses.
Definition: MoBanLocal.cc:78
inet::INITSTAGE_SINGLE_MOBILITY
INET_API InitStage INITSTAGE_SINGLE_MOBILITY
Initialization of single mobility modules: calculating the initial position and orientation.
inet::MoBanLocal::lastCompositeVelocity
Coord lastCompositeVelocity
Definition: MoBanLocal.h:77
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::MoBanLocal::lastCompositePosition
Coord lastCompositePosition
Definition: MoBanLocal.h:76
inet::MoBanLocal::speed
double speed
The speed of local mobility of the node in the current posture.
Definition: MoBanLocal.h:71
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::MoBanLocal::referencePosition
Coord referencePosition
Reference position of the node in the current posture.
Definition: MoBanLocal.h:65
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::MobilityBase::subjectModule
cModule * subjectModule
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:64
inet::MovingMobilityBase::lastVelocity
Coord lastVelocity
The last velocity that was reported at lastUpdate.
Definition: MovingMobilityBase.h:35
inet::Coord::length
double length() const
Returns the length of this Coords position vector.
Definition: Coord.h:275
inet::MovingMobilityBase::getCurrentVelocity
virtual const Coord & getCurrentVelocity() override
Returns the velocity at the current simulation time.
Definition: MovingMobilityBase.cc:100
inet::MoBanCoordinator::getMaxSpeed
virtual double getMaxSpeed() const override
Returns the maximum possible speed at any future time.
Definition: MoBanCoordinator.h:212
inet::Coord::y
double y
Definition: Coord.h:37