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 const QuaterniongetCurrentAngularPosition () override
 Returns the current angular position at the current simulation time. More...
 
virtual const QuaterniongetCurrentAngularVelocity () override
 Returns the current angular velocity 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 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 ()
 
virtual const CoordgetCurrentPosition ()=0
 Returns the position at the current simulation time. More...
 
virtual const CoordgetCurrentVelocity ()=0
 Returns the velocity at the current simulation time. More...
 
virtual const CoordgetCurrentAcceleration ()=0
 Returns the acceleration at the current simulation time. More...
 
virtual const QuaterniongetCurrentAngularAcceleration ()=0
 Returns the angular acceleration 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 getId () const override
 
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 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

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...
 
Quaternion lastAngularVelocity
 The last 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...
 
- 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...
 

Constructor & Destructor Documentation

◆ RotatingMobilityBase()

inet::RotatingMobilityBase::RotatingMobilityBase ( )
protected
13 {
14  rotateTimer = nullptr;
15  updateInterval = 0;
16  stationary = false;
17  lastUpdate = 0;
18  nextChange = -1;
19 }

◆ ~RotatingMobilityBase()

inet::RotatingMobilityBase::~RotatingMobilityBase ( )
protectedvirtual
22 {
23  cancelAndDelete(rotateTimer);
24 }

Member Function Documentation

◆ getCurrentAngularPosition()

const Quaternion & inet::RotatingMobilityBase::getCurrentAngularPosition ( )
overridevirtual

Returns the current angular position at the current simulation time.

Implements inet::IMobility.

79 {
81  return lastOrientation;
82 }

◆ getCurrentAngularVelocity()

const Quaternion & inet::RotatingMobilityBase::getCurrentAngularVelocity ( )
overridevirtual

Returns the current angular velocity at the current simulation time.

Implements inet::IMobility.

85 {
87  return lastAngularVelocity;
88 }

◆ handleSelfMessage()

void inet::RotatingMobilityBase::handleSelfMessage ( cMessage *  msg)
overrideprotectedvirtual

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

Implements inet::MobilityBase.

55 {
58 }

◆ initialize()

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

Initializes mobility model parameters.

Reimplemented from inet::MobilityBase.

27 {
29 
30  EV_TRACE << "initializing RotatingMobilityBase stage " << stage << endl;
31  if (stage == INITSTAGE_LOCAL) {
32  rotateTimer = new cMessage("rotate");
33  updateInterval = par("updateInterval");
34  }
35 }

◆ initializeOrientation()

void inet::RotatingMobilityBase::initializeOrientation ( )
overrideprotectedvirtual

Initializes the orientation from module parameters.

Reimplemented from inet::MobilityBase.

Reimplemented in inet::LinearRotatingMobilityBase.

38 {
40  lastUpdate = simTime();
42 }

◆ rotate()

virtual void inet::RotatingMobilityBase::rotate ( )
protectedpure virtual

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

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

Implemented in inet::LinearRotatingMobilityBase.

Referenced by rotateAndUpdate().

◆ rotateAndUpdate()

void inet::RotatingMobilityBase::rotateAndUpdate ( )
protected

Moves and notifies listeners.

45 {
46  simtime_t now = simTime();
47  if (nextChange == now || lastUpdate != now) {
48  rotate();
49  lastUpdate = simTime();
51  }
52 }

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

◆ scheduleUpdate()

void inet::RotatingMobilityBase::scheduleUpdate ( )
protected

Schedules the move timer that will update the mobility state.

61 {
62  cancelEvent(rotateTimer);
63  if (!stationary && updateInterval != 0) {
64  // periodic update is needed
65  simtime_t nextUpdate = simTime() + updateInterval;
66  if (nextChange != -1 && nextChange < nextUpdate)
67  // next change happens earlier than next update
68  scheduleAt(nextChange, rotateTimer);
69  else
70  // next update happens earlier than next change or there is no change at all
71  scheduleAt(nextUpdate, rotateTimer);
72  }
73  else if (nextChange != -1)
74  // no periodic update is needed
75  scheduleAt(nextChange, rotateTimer);
76 }

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

Member Data Documentation

◆ lastAngularVelocity

Quaternion inet::RotatingMobilityBase::lastAngularVelocity
protected

The last velocity that was reported at lastUpdate.

Referenced by getCurrentAngularVelocity().

◆ lastUpdate

simtime_t inet::RotatingMobilityBase::lastUpdate
protected

◆ nextChange

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().

◆ rotateTimer

cMessage* inet::RotatingMobilityBase::rotateTimer
protected

The message used for mobility state changes.

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

◆ stationary

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().

◆ updateInterval

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:
inet::MobilityBase::emitMobilityStateChangedSignal
virtual void emitMobilityStateChangedSignal()
Emits a signal with the updated mobility state.
Definition: MobilityBase.cc:246
inet::RotatingMobilityBase::updateInterval
simtime_t updateInterval
The simulation time interval used to regularly signal mobility state changes.
Definition: RotatingMobilityBase.h:24
inet::MobilityBase::lastOrientation
Quaternion lastOrientation
The last orientation that was reported.
Definition: MobilityBase.h:76
inet::RotatingMobilityBase::lastUpdate
simtime_t lastUpdate
The simulation time when the mobility state was last updated.
Definition: RotatingMobilityBase.h:35
inet::RotatingMobilityBase::rotateAndUpdate
void rotateAndUpdate()
Moves and notifies listeners.
Definition: RotatingMobilityBase.cc:44
inet::RotatingMobilityBase::stationary
bool stationary
A mobility model may decide to become stationary at any time.
Definition: RotatingMobilityBase.h:29
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::MobilityBase::initialize
virtual void initialize(int stage) override
Initializes mobility model parameters.
Definition: MobilityBase.cc:87
inet::RotatingMobilityBase::scheduleUpdate
void scheduleUpdate()
Schedules the move timer that will update the mobility state.
Definition: RotatingMobilityBase.cc:60
inet::RotatingMobilityBase::rotateTimer
cMessage * rotateTimer
The message used for mobility state changes.
Definition: RotatingMobilityBase.h:19
inet::MobilityBase::initializeOrientation
virtual void initializeOrientation()
Initializes the orientation from module parameters.
Definition: MobilityBase.cc:176
inet::RotatingMobilityBase::nextChange
simtime_t nextChange
The next simulation time when the mobility module needs to update its internal state.
Definition: RotatingMobilityBase.h:40
inet::RotatingMobilityBase::rotate
virtual void rotate()=0
Moves according to the mobility model to the current simulation time.
inet::RotatingMobilityBase::lastAngularVelocity
Quaternion lastAngularVelocity
The last velocity that was reported at lastUpdate.
Definition: RotatingMobilityBase.h:32