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

#include <AttachedMobility.h>

Inheritance diagram for inet::AttachedMobility:
inet::MobilityBase inet::IMobility

Public Member Functions

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...
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *object, cObject *details) override
 
- 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 ()
 

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...
 
virtual void handleSelfMessage (cMessage *msg) 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 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 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

ModuleRefByPar< IMobilitymobility
 
Coord positionOffset = Coord::NIL
 
Quaternion orientationOffset = Quaternion::NIL
 
bool isZeroOffset = false
 
Coord lastVelocity
 
Quaternion lastAngularPosition
 
- 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...
 

Member Function Documentation

◆ getCurrentAcceleration()

const Coord & inet::AttachedMobility::getCurrentAcceleration ( )
overridevirtual

Returns the acceleration at the current simulation time.

Implements inet::IMobility.

75 {
76  if (isZeroOffset)
77  return mobility->getCurrentAcceleration();
78  else {
79  // TODO
80  return Coord::NIL;
81  }
82 }

◆ getCurrentAngularAcceleration()

const Quaternion & inet::AttachedMobility::getCurrentAngularAcceleration ( )
overridevirtual

Returns the angular acceleration at the current simulation time.

Implements inet::IMobility.

97 {
98  return mobility->getCurrentAngularAcceleration();
99 }

◆ getCurrentAngularPosition()

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

Returns the angular position at the current simulation time.

Implements inet::IMobility.

85 {
86  lastAngularPosition = mobility->getCurrentAngularPosition();
88  return lastAngularPosition;
89 }

◆ getCurrentAngularVelocity()

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

Returns the angular velocity at the current simulation time.

Implements inet::IMobility.

92 {
93  return mobility->getCurrentAngularVelocity();
94 }

◆ getCurrentPosition()

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

Returns the position at the current simulation time.

Implements inet::IMobility.

47 {
48  if (isZeroOffset)
49  lastPosition = mobility->getCurrentPosition();
50  else {
51  RotationMatrix rotation(mobility->getCurrentAngularPosition().toEulerAngles());
52  lastPosition = mobility->getCurrentPosition() + rotation.rotateVector(positionOffset);
53  }
54  return lastPosition;
55 }

◆ getCurrentVelocity()

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

Returns the velocity at the current simulation time.

Implements inet::IMobility.

58 {
59  if (isZeroOffset)
60  lastVelocity = mobility->getCurrentVelocity();
61  else {
62  RotationMatrix rotation(mobility->getCurrentAngularPosition().toEulerAngles());
63  Coord rotatedOffset = rotation.rotateVector(positionOffset);
64  Quaternion quaternion(mobility->getCurrentAngularVelocity());
65  Coord rotationAxis;
66  double rotationAngle;
67  quaternion.getRotationAxisAndAngle(rotationAxis, rotationAngle);
68  auto additionalVelocity = rotationAngle == 0 ? Coord::ZERO : rotationAxis % rotatedOffset * rotationAngle;
69  lastVelocity = mobility->getCurrentVelocity() + additionalVelocity;
70  }
71  return lastVelocity;
72 }

◆ handleSelfMessage()

virtual void inet::AttachedMobility::handleSelfMessage ( cMessage *  msg)
inlineoverrideprotectedvirtual

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

Implements inet::MobilityBase.

29 { throw cRuntimeError("Unknown self message"); }

◆ initialize()

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

Initializes mobility model parameters.

Reimplemented from inet::MobilityBase.

17 {
19  EV_TRACE << "initializing AttachedMobility stage " << stage << endl;
20  if (stage == INITSTAGE_LOCAL) {
21  mobility.reference(this, "mobilityModule", true);
22  positionOffset.x = par("offsetX");
23  positionOffset.y = par("offsetY");
24  positionOffset.z = par("offsetZ");
25  auto alpha = deg(par("offsetHeading"));
26  auto offsetElevation = deg(par("offsetElevation"));
27  // NOTE: negation is needed, see IMobility comments on orientation
28  auto beta = -offsetElevation;
29  auto gamma = deg(par("offsetBank"));
30  orientationOffset = Quaternion(EulerAngles(alpha, beta, gamma));
32  check_and_cast<cModule *>(mobility.get())->subscribe(IMobility::mobilityStateChangedSignal, this);
33  WATCH(lastVelocity);
34  WATCH(lastAngularPosition);
35  }
36 }

◆ numInitStages()

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

Returns the required number of initialize stages.

Reimplemented from inet::MobilityBase.

27 { return NUM_INIT_STAGES; }

◆ receiveSignal()

void inet::AttachedMobility::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
39 {
40  Enter_Method("%s", cComponent::getSignalName(signal));
41 
44 }

Member Data Documentation

◆ isZeroOffset

bool inet::AttachedMobility::isZeroOffset = false
protected

◆ lastAngularPosition

Quaternion inet::AttachedMobility::lastAngularPosition
protected

◆ lastVelocity

Coord inet::AttachedMobility::lastVelocity
protected

Referenced by getCurrentVelocity(), and initialize().

◆ mobility

◆ orientationOffset

Quaternion inet::AttachedMobility::orientationOffset = Quaternion::NIL
protected

◆ positionOffset

Coord inet::AttachedMobility::positionOffset = Coord::NIL
protected

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::AttachedMobility::isZeroOffset
bool isZeroOffset
Definition: AttachedMobility.h:22
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::Coord::ZERO
static const Coord ZERO
Definition: Coord.h:27
inet::Coord::x
double x
Definition: Coord.h:36
inet::AttachedMobility::lastAngularPosition
Quaternion lastAngularPosition
Definition: AttachedMobility.h:24
inet::AttachedMobility::orientationOffset
Quaternion orientationOffset
Definition: AttachedMobility.h:21
inet::AttachedMobility::positionOffset
Coord positionOffset
Definition: AttachedMobility.h:20
inet::IMobility::mobilityStateChangedSignal
static simsignal_t mobilityStateChangedSignal
A signal used to publish mobility state changes.
Definition: IMobility.h:40
inet::Coord::z
double z
Definition: Coord.h:38
inet::AttachedMobility::lastVelocity
Coord lastVelocity
Definition: AttachedMobility.h:23
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
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::Coord::NIL
static const Coord NIL
Constant with all values set to 0.
Definition: Coord.h:26
inet::units::constants::alpha
const value< double, units::unit > alpha(7.2973525376e-3)
inet::Coord::y
double y
Definition: Coord.h:37
inet::AttachedMobility::mobility
ModuleRefByPar< IMobility > mobility
Definition: AttachedMobility.h:19