INET Framework for OMNeT++/OMNEST
inet::RotatingMobilityBase Class Referenceabstract

#include <RotatingMobilityBase.h>

Inheritance diagram for inet::RotatingMobilityBase:
inet::MobilityBase inet::IMobility inet::LinearRotatingMobilityBase

Public Member Functions

virtual EulerAngles getCurrentAngularPosition () override
 Returns the current angular position 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::MobilityBase
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::IMobility
virtual ~IMobility ()
 
virtual Coord getCurrentPosition ()=0
 Returns the current position at the current simulation time. More...
 
virtual Coord getCurrentSpeed ()=0
 Returns the current speed at the current simulation time. More...
 

Protected Member Functions

 RotatingMobilityBase ()
 
virtual ~RotatingMobilityBase ()
 
virtual void initialize (int stage) override
 Initializes mobility model parameters. More...
 
virtual void initializeOrientation () override
 Initializes the orientation from module parameters. More...
 
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 rotateAndUpdate ()
 Moves and notifies listeners. More...
 
virtual void rotate ()=0
 Moves according to the mobility model to the current simulation time. More...
 
- Protected Member Functions inherited from inet::MobilityBase
 MobilityBase ()
 
virtual int numInitStages () const override
 Returns the required number of initialize stages. More...
 
virtual void initializePosition ()
 Initializes mobility position. More...
 
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 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

cMessage * rotateTimer
 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...
 
EulerAngles lastAngularSpeed
 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...
 

Constructor & Destructor Documentation

inet::RotatingMobilityBase::RotatingMobilityBase ( )
protected
21 {
22  rotateTimer = nullptr;
23  updateInterval = 0;
24  stationary = false;
25  lastUpdate = 0;
26  nextChange = -1;
27 }
bool stationary
A mobility model may decide to become stationary at any time.
Definition: RotatingMobilityBase.h:37
simtime_t nextChange
The next simulation time when the mobility module needs to update its internal state.
Definition: RotatingMobilityBase.h:48
simtime_t lastUpdate
The simulation time when the mobility state was last updated.
Definition: RotatingMobilityBase.h:43
cMessage * rotateTimer
The message used for mobility state changes.
Definition: RotatingMobilityBase.h:27
simtime_t updateInterval
The simulation time interval used to regularly signal mobility state changes.
Definition: RotatingMobilityBase.h:32
inet::RotatingMobilityBase::~RotatingMobilityBase ( )
protectedvirtual
30 {
31  cancelAndDelete(rotateTimer);
32 }
cMessage * rotateTimer
The message used for mobility state changes.
Definition: RotatingMobilityBase.h:27

Member Function Documentation

EulerAngles inet::RotatingMobilityBase::getCurrentAngularPosition ( )
overridevirtual

Returns the current angular position at the current simulation time.

Reimplemented from inet::MobilityBase.

88 {
90  return lastOrientation;
91 }
EulerAngles lastOrientation
The last position that was reported.
Definition: MobilityBase.h:81
void rotateAndUpdate()
Moves and notifies listeners.
Definition: RotatingMobilityBase.cc:52
EulerAngles inet::RotatingMobilityBase::getCurrentAngularSpeed ( )
overridevirtual

Returns the current angular speed at the current simulation time.

Reimplemented from inet::MobilityBase.

94 {
96  return lastAngularSpeed;
97 }
EulerAngles lastAngularSpeed
The last speed that was reported at lastUpdate.
Definition: RotatingMobilityBase.h:40
void rotateAndUpdate()
Moves and notifies listeners.
Definition: RotatingMobilityBase.cc:52
void inet::RotatingMobilityBase::handleSelfMessage ( cMessage *  msg)
overrideprotectedvirtual

Called upon arrival of a self messages, subclasses must override.

Implements inet::MobilityBase.

64 {
67 }
void scheduleUpdate()
Schedules the move timer that will update the mobility state.
Definition: RotatingMobilityBase.cc:69
void rotateAndUpdate()
Moves and notifies listeners.
Definition: RotatingMobilityBase.cc:52
void inet::RotatingMobilityBase::initialize ( int  stage)
overrideprotectedvirtual

Initializes mobility model parameters.

Reimplemented from inet::MobilityBase.

35 {
37 
38  EV_TRACE << "initializing RotatingMobilityBase stage " << stage << endl;
39  if (stage == INITSTAGE_LOCAL) {
40  rotateTimer = new cMessage("rotate");
41  updateInterval = par("updateInterval");
42  }
43 }
virtual void initialize(int stage) override
Initializes mobility model parameters.
Definition: MobilityBase.cc:63
Local initializations.
Definition: InitStages.h:35
cMessage * rotateTimer
The message used for mobility state changes.
Definition: RotatingMobilityBase.h:27
simtime_t updateInterval
The simulation time interval used to regularly signal mobility state changes.
Definition: RotatingMobilityBase.h:32
void inet::RotatingMobilityBase::initializeOrientation ( )
overrideprotectedvirtual

Initializes the orientation from module parameters.

Reimplemented from inet::MobilityBase.

Reimplemented in inet::LinearRotatingMobilityBase.

46 {
48  lastUpdate = simTime();
50 }
simtime_t lastUpdate
The simulation time when the mobility state was last updated.
Definition: RotatingMobilityBase.h:43
void scheduleUpdate()
Schedules the move timer that will update the mobility state.
Definition: RotatingMobilityBase.cc:69
virtual void initializeOrientation()
Initializes the orientation from module parameters.
Definition: MobilityBase.cc:140
virtual void inet::RotatingMobilityBase::rotate ( )
protectedpure virtual

Moves according to the mobility model to the current simulation time.

Subclasses must override and update lastPosition, lastSpeed, lastUpdate, nextChange and other state according to the mobility model.

Implemented in inet::LinearRotatingMobilityBase.

Referenced by rotateAndUpdate().

void inet::RotatingMobilityBase::rotateAndUpdate ( )
protected

Moves and notifies listeners.

Referenced by getCurrentAngularPosition(), getCurrentAngularSpeed(), and handleSelfMessage().

53 {
54  simtime_t now = simTime();
55  if (nextChange == now || lastUpdate != now) {
56  rotate();
57  lastUpdate = simTime();
60  }
61 }
simtime_t nextChange
The next simulation time when the mobility module needs to update its internal state.
Definition: RotatingMobilityBase.h:48
virtual void emitMobilityStateChangedSignal()
Emits a signal with the updated mobility state.
Definition: MobilityBase.cc:176
simtime_t lastUpdate
The simulation time when the mobility state was last updated.
Definition: RotatingMobilityBase.h:43
virtual void updateVisualRepresentation()
Moves the visual representation module&#39;s icon to the new position on the screen.
Definition: MobilityBase.cc:157
virtual void rotate()=0
Moves according to the mobility model to the current simulation time.
void inet::RotatingMobilityBase::scheduleUpdate ( )
protected

Schedules the move timer that will update the mobility state.

Referenced by handleSelfMessage(), inet::LinearRotatingMobilityBase::initializeOrientation(), and initializeOrientation().

70 {
71  cancelEvent(rotateTimer);
72  if (!stationary && updateInterval != 0) {
73  // periodic update is needed
74  simtime_t nextUpdate = simTime() + updateInterval;
75  if (nextChange != -1 && nextChange < nextUpdate)
76  // next change happens earlier than next update
77  scheduleAt(nextChange, rotateTimer);
78  else
79  // next update happens earlier than next change or there is no change at all
80  scheduleAt(nextUpdate, rotateTimer);
81  }
82  else if (nextChange != -1)
83  // no periodic update is needed
84  scheduleAt(nextChange, rotateTimer);
85 }
bool stationary
A mobility model may decide to become stationary at any time.
Definition: RotatingMobilityBase.h:37
simtime_t nextChange
The next simulation time when the mobility module needs to update its internal state.
Definition: RotatingMobilityBase.h:48
cMessage * rotateTimer
The message used for mobility state changes.
Definition: RotatingMobilityBase.h:27
simtime_t updateInterval
The simulation time interval used to regularly signal mobility state changes.
Definition: RotatingMobilityBase.h:32

Member Data Documentation

EulerAngles inet::RotatingMobilityBase::lastAngularSpeed
protected

The last speed that was reported at lastUpdate.

Referenced by getCurrentAngularSpeed().

simtime_t inet::RotatingMobilityBase::lastUpdate
protected
simtime_t inet::RotatingMobilityBase::nextChange
protected

The next simulation time when the mobility module needs to update its internal state.

The -1 value turns off sending a self message for the next mobility state change.

Referenced by inet::LinearRotatingMobilityBase::initializeOrientation(), inet::LinearRotatingMobilityBase::rotate(), rotateAndUpdate(), RotatingMobilityBase(), and scheduleUpdate().

cMessage* inet::RotatingMobilityBase::rotateTimer
protected

The message used for mobility state changes.

Referenced by initialize(), RotatingMobilityBase(), scheduleUpdate(), and ~RotatingMobilityBase().

bool inet::RotatingMobilityBase::stationary
protected

A mobility model may decide to become stationary at any time.

The true value disables sending self messages.

Referenced by inet::LinearRotatingMobilityBase::initializeOrientation(), RotatingMobilityBase(), and scheduleUpdate().

simtime_t inet::RotatingMobilityBase::updateInterval
protected

The simulation time interval used to regularly signal mobility state changes.

The 0 value turns off the signal.

Referenced by initialize(), RotatingMobilityBase(), and scheduleUpdate().


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