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

This mobility module does not move at all; it can be used for standalone stationary nodes. More...

#include <StationaryMobility.h>

Inheritance diagram for inet::StationaryMobility:
inet::StationaryMobilityBase inet::MobilityBase inet::IMobility

Protected Member Functions

virtual void initialize (int stage) override
 Initializes mobility model parameters. More...
 
virtual void refreshDisplay () const override
 Moves the visual representation module's icon to the new position on the screen. More...
 
virtual void updateMobilityStateFromDisplayString ()
 
- Protected Member Functions inherited from inet::StationaryMobilityBase
virtual void handleSelfMessage (cMessage *message) override
 Called upon arrival of a self messages, subclasses must override. 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 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

bool updateFromDisplayString
 
- 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...
 
- Public Member Functions inherited from inet::StationaryMobilityBase
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...
 
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 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 ()
 
- 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 mobility module does not move at all; it can be used for standalone stationary nodes.

Member Function Documentation

◆ initialize()

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

Initializes mobility model parameters.

Reimplemented from inet::MobilityBase.

15 {
17  if (stage == INITSTAGE_LOCAL)
18  updateFromDisplayString = par("updateFromDisplayString");
19 }

◆ refreshDisplay()

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

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

Reimplemented from inet::MobilityBase.

22 {
24  const_cast<StationaryMobility *>(this)->updateMobilityStateFromDisplayString();
25  DirectiveResolver directiveResolver(const_cast<StationaryMobility *>(this));
26  auto text = format.formatString(&directiveResolver);
27  getDisplayString().setTagArg("t", 0, text);
28  }
29  else
31 }

◆ updateMobilityStateFromDisplayString()

void inet::StationaryMobility::updateMobilityStateFromDisplayString ( )
protectedvirtual
34 {
35  char *end;
36  double depth;
37  cDisplayString& displayString = subjectModule->getDisplayString();
39  double x = strtod(displayString.getTagArg("p", 0), &end);
40  double y = strtod(displayString.getTagArg("p", 1), &end);
41  auto newPosition = canvasProjection->computeCanvasPointInverse(cFigure::Point(x, y), depth);
42  if (lastPosition != newPosition) {
43  lastPosition = newPosition;
44  emit(mobilityStateChangedSignal, const_cast<StationaryMobility *>(this));
45  }
46  Quaternion swing;
47  Quaternion twist;
48  Coord vector = canvasProjection->computeCanvasPointInverse(cFigure::Point(0, 0), 1);
49  vector.normalize();
50  lastOrientation.getSwingAndTwist(vector, swing, twist);
51  double oldAngle;
52  Coord axis;
53  twist.getRotationAxisAndAngle(axis, oldAngle);
54  double newAngle = math::deg2rad(strtod(displayString.getTagArg("a", 0), &end));
55  if (oldAngle != newAngle) {
56  lastOrientation *= Quaternion(vector, newAngle - oldAngle);
57  emit(mobilityStateChangedSignal, const_cast<StationaryMobility *>(this));
58  }
59 }

Referenced by refreshDisplay().

Member Data Documentation

◆ updateFromDisplayString

bool inet::StationaryMobility::updateFromDisplayString
protected

Referenced by initialize(), and refreshDisplay().


The documentation for this class was generated from the following files:
inet::StationaryMobility::updateFromDisplayString
bool updateFromDisplayString
Definition: StationaryMobility.h:23
inet::MobilityBase::lastPosition
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:73
inet::StationaryMobility::updateMobilityStateFromDisplayString
virtual void updateMobilityStateFromDisplayString()
Definition: StationaryMobility.cc:33
inet::MobilityBase::lastOrientation
Quaternion lastOrientation
The last orientation that was reported.
Definition: MobilityBase.h:76
inet::CanvasProjection::computeCanvasPointInverse
Coord computeCanvasPointInverse(const cFigure::Point &point, double depth) const
Definition: CanvasProjection.cc:47
inet::MobilityBase::canvasProjection
const CanvasProjection * canvasProjection
The 2D projection used on the canvas.
Definition: MobilityBase.h:67
inet::IMobility::mobilityStateChangedSignal
static simsignal_t mobilityStateChangedSignal
A signal used to publish mobility state changes.
Definition: IMobility.h:40
inet::CanvasProjection::computeCanvasPoint
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:34
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::Quaternion::getSwingAndTwist
void getSwingAndTwist(const Coord &direction, Quaternion &swing, Quaternion &twist) const
Decompose the rotation on to 2 parts.
Definition: Quaternion.cc:188
inet::MobilityBase::format
StringFormat format
Definition: MobilityBase.h:78
inet::math::deg2rad
double deg2rad(double deg)
Convert a degree value to radian.
Definition: INETMath.h:183
inet::StringFormat::formatString
const char * formatString(IDirectiveResolver *resolver) const
Definition: StringFormat.cc:17
inet::MobilityBase::subjectModule
cModule * subjectModule
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:64
inet::Coord::normalize
Coord normalize()
Updates the length of this position vector to be 1.
Definition: Coord.h:280
inet::MobilityBase::refreshDisplay
virtual void refreshDisplay() const override
Moves the visual representation module's icon to the new position on the screen.
Definition: MobilityBase.cc:188