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

Abstract base class for mobility modules. More...

#include <MobilityBase.h>

Inheritance diagram for inet::MobilityBase:
inet::IMobility inet::MovingMobilityBase inet::RotatingMobilityBase inet::StationaryMobility inet::CircleMobility inet::LinearMobility inet::LineSegmentsMobilityBase inet::RectangleMobility inet::VehicleMobility inet::LinearRotatingMobilityBase inet::LinearNodeDistributionMobility inet::StaticConcentricMobility inet::StaticGridMobility

Public Types

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

virtual double getMaxSpeed () const override
 Returns the maximum possible speed at any future time. More...
 
virtual EulerAngles getCurrentAngularPosition () override
 Returns the current acceleration at the current simulation time. More...
 
virtual EulerAngles getCurrentAngularSpeed () override
 Returns the current angular speed at the current simulation 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

 MobilityBase ()
 
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 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 handleMessage (cMessage *msg) override
 This modules should only receive self-messages. More...
 
virtual void handleSelfMessage (cMessage *msg)=0
 Called upon arrival of a self messages, subclasses must override. 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

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

- 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

Abstract base class for mobility modules.

Mobility modules inheriting from this base class may be stationary or may change their mobility state over simulation time. This base class only provides a few utility methods to handle some common tasks among mobility modules.

Subclasses must redefine handleSelfMessage() to update the mobility state and schedule the next update. Subclasses must also redefine initialize() to read their specific parameters and schedule the first update.

This base class also provides random initial placement as a default mechanism. After initialization the module updates the display and emits a signal to subscribers providing the mobility state. Receivers of this signal can query the mobility state through the IMobility interface.

Author
Daniel Willkomm, Andras Varga

Member Enumeration Documentation

Selects how a mobility module should behave if it reaches the edge of the constraint area.

See also
handleIfOutside()
Enumerator
REFLECT 

reflect off the wall

WRAP 

reappear at the opposite edge (torus)

PLACERANDOMLY 

placed at a randomly chosen position within the constraint area

RAISEERROR 

stop the simulation with error

60  {
61  REFLECT,
62  WRAP,
64  RAISEERROR
65  };
reflect off the wall
Definition: MobilityBase.h:61
reappear at the opposite edge (torus)
Definition: MobilityBase.h:62
stop the simulation with error
Definition: MobilityBase.h:64
placed at a randomly chosen position within the constraint area
Definition: MobilityBase.h:63

Constructor & Destructor Documentation

inet::MobilityBase::MobilityBase ( )
protected
53  :
54  visualRepresentation(nullptr),
55  canvasProjection(nullptr),
60 {
61 }
cModule * visualRepresentation
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:69
static const EulerAngles ZERO
Definition: EulerAngles.h:12
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
EulerAngles lastOrientation
The last position that was reported.
Definition: MobilityBase.h:81
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
static const Coord ZERO
Definition: Coord.h:41
const CanvasProjection * canvasProjection
The 2D projection used on the canvas.
Definition: MobilityBase.h:72
Coord constraintAreaMax
Definition: MobilityBase.h:75

Member Function Documentation

void inet::MobilityBase::checkPosition ( )
protectedvirtual

Checks whether the position is valid or not.

Referenced by initializePosition().

130 {
131  if (!isFiniteNumber(lastPosition.x) || !isFiniteNumber(lastPosition.y) || !isFiniteNumber(lastPosition.z))
132  throw cRuntimeError("Mobility position is not a finite number after initialize (x=%g,y=%g,z=%g)", lastPosition.x, lastPosition.y, lastPosition.z);
133  if (isOutside())
134  throw cRuntimeError("Mobility position (x=%g,y=%g,z=%g) is outside the constraint area (%g,%g,%g - %g,%g,%g)",
138 }
double z
Definition: Coord.h:51
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
virtual bool isOutside()
Returns true if the mobility is outside of the constraint area.
Definition: MobilityBase.cc:190
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Coord constraintAreaMax
Definition: MobilityBase.h:75
void inet::MobilityBase::emitMobilityStateChangedSignal ( )
protectedvirtual

Emits a signal with the updated mobility state.

Referenced by initializePosition(), inet::MovingMobilityBase::moveAndUpdate(), and inet::RotatingMobilityBase::rotateAndUpdate().

177 {
178  emit(mobilityStateChangedSignal, this);
179 }
static simsignal_t mobilityStateChangedSignal
A signal used to publish mobility state changes.
Definition: IMobility.h:42
virtual cModule* inet::MobilityBase::findVisualRepresentation ( )
inlineprotectedvirtual

Returns the module that represents the object moved by this mobility module.

Reimplemented in inet::MoBANCoordinator.

Referenced by initialize().

120 { return getModuleFromPar<cModule>(par("visualRepresentation"), this); }
virtual Coord inet::MobilityBase::getConstraintAreaMax ( ) const
inlineoverridevirtual

Returns the current angular acceleration at the current simulation time.

Implements inet::IMobility.

Reimplemented in inet::StationaryMobility.

167 { return constraintAreaMax; }
Coord constraintAreaMax
Definition: MobilityBase.h:75
virtual Coord inet::MobilityBase::getConstraintAreaMin ( ) const
inlineoverridevirtual

Implements inet::IMobility.

Reimplemented in inet::StationaryMobility.

168 { return constraintAreaMin; }
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
virtual EulerAngles inet::MobilityBase::getCurrentAngularPosition ( )
inlineoverridevirtual

Returns the current acceleration at the current simulation time.

Returns the current angular position at the current simulation time.

Implements inet::IMobility.

Reimplemented in inet::MovingMobilityBase, and inet::RotatingMobilityBase.

162 { return EulerAngles::ZERO; }
static const EulerAngles ZERO
Definition: EulerAngles.h:12
virtual EulerAngles inet::MobilityBase::getCurrentAngularSpeed ( )
inlineoverridevirtual

Returns the current angular speed at the current simulation time.

Implements inet::IMobility.

Reimplemented in inet::RotatingMobilityBase.

165 { return EulerAngles::ZERO; }
static const EulerAngles ZERO
Definition: EulerAngles.h:12
virtual double inet::MobilityBase::getMaxSpeed ( ) const
inlineoverridevirtual
Coord inet::MobilityBase::getRandomPosition ( )
protectedvirtual

Returns a new random position satisfying the constraint area.

Referenced by placeRandomlyIfOutside(), inet::MoBANCoordinator::selectDestination(), setInitialPosition(), inet::RandomWPMobility::setTargetPosition(), and inet::ConstSpeedMobility::setTargetPosition().

182 {
183  Coord p;
184  p.x = uniform(constraintAreaMin.x, constraintAreaMax.x);
185  p.y = uniform(constraintAreaMin.y, constraintAreaMax.y);
186  p.z = uniform(constraintAreaMin.z, constraintAreaMax.z);
187  return p;
188 }
double z
Definition: Coord.h:51
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Coord constraintAreaMax
Definition: MobilityBase.h:75
void inet::MobilityBase::handleIfOutside ( BorderPolicy  policy,
Coord targetPosition,
Coord speed,
double &  angle 
)
protectedvirtual

Invokes one of reflectIfOutside(), wrapIfOutside() and placeRandomlyIfOutside(), depending on the given border policy.

Referenced by inet::LinearMobility::move(), inet::ChiangMobility::move(), inet::GaussMarkovMobility::move(), inet::MassMobility::move(), inet::CircleMobility::move(), and inet::TurtleMobility::move().

270 {
271  switch (policy) {
272  case REFLECT:
273  reflectIfOutside(targetPosition, speed, angle);
274  break;
275 
276  case WRAP:
277  wrapIfOutside(targetPosition);
278  break;
279 
280  case PLACERANDOMLY:
281  placeRandomlyIfOutside(targetPosition);
282  break;
283 
284  case RAISEERROR:
286  break;
287 
288  default:
289  throw cRuntimeError("Invalid outside policy=%d in module", policy, getFullPath().c_str());
290  }
291 }
virtual void raiseErrorIfOutside()
Utility function to raise an error if the node gets outside the constraint area.
Definition: MobilityBase.cc:259
reflect off the wall
Definition: MobilityBase.h:61
reappear at the opposite edge (torus)
Definition: MobilityBase.h:62
stop the simulation with error
Definition: MobilityBase.h:64
virtual void reflectIfOutside(Coord &targetPosition, Coord &speed, double &angle)
Utility function to reflect the node if it goes outside the constraint area.
Definition: MobilityBase.cc:208
virtual void wrapIfOutside(Coord &targetPosition)
Utility function to wrap the node to the opposite edge (torus) if it goes outside the constraint area...
Definition: MobilityBase.cc:234
virtual void placeRandomlyIfOutside(Coord &targetPosition)
Utility function to place the node randomly if it goes outside the constraint area.
Definition: MobilityBase.cc:250
placed at a randomly chosen position within the constraint area
Definition: MobilityBase.h:63
void inet::MobilityBase::handleMessage ( cMessage *  msg)
overrideprotectedvirtual

This modules should only receive self-messages.

150 {
151  if (message->isSelfMessage())
152  handleSelfMessage(message);
153  else
154  throw cRuntimeError("Mobility modules can only receive self messages");
155 }
virtual void handleSelfMessage(cMessage *msg)=0
Called upon arrival of a self messages, subclasses must override.
virtual void inet::MobilityBase::handleSelfMessage ( cMessage *  msg)
protectedpure virtual

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

Implemented in inet::MovingMobilityBase, inet::RotatingMobilityBase, and inet::StationaryMobility.

Referenced by handleMessage().

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

Initializes mobility model parameters.

Reimplemented in inet::MoBANCoordinator, inet::MoBANLocal, inet::Ns2MotionMobility, inet::MovingMobilityBase, inet::RotatingMobilityBase, inet::MassMobility, inet::TurtleMobility, inet::CircleMobility, inet::RectangleMobility, inet::LinearNodeDistributionMobility, inet::VehicleMobility, inet::BonnMotionMobility, inet::GaussMarkovMobility, inet::TractorMobility, inet::ANSimMobility, inet::ConstSpeedMobility, inet::LinearMobility, inet::ChiangMobility, and inet::RandomWPMobility.

Referenced by inet::LinearNodeDistributionMobility::initialize(), inet::RotatingMobilityBase::initialize(), and inet::MovingMobilityBase::initialize().

64 {
65  cSimpleModule::initialize(stage);
66  EV_TRACE << "initializing MobilityBase stage " << stage << endl;
67  if (stage == INITSTAGE_LOCAL) {
68  constraintAreaMin.x = par("constraintAreaMinX");
69  constraintAreaMin.y = par("constraintAreaMinY");
70  constraintAreaMin.z = par("constraintAreaMinZ");
71  constraintAreaMax.x = par("constraintAreaMaxX");
72  constraintAreaMax.y = par("constraintAreaMaxY");
73  constraintAreaMax.z = par("constraintAreaMaxZ");
74  bool visualizeMobility = par("visualizeMobility");
75  if (visualizeMobility)
77  WATCH(constraintAreaMin);
78  WATCH(constraintAreaMax);
79  WATCH(lastPosition);
80  }
81  else if (stage == INITSTAGE_PHYSICAL_ENVIRONMENT_2) {
82  if (visualRepresentation != nullptr) {
83  auto visualizationTarget = visualRepresentation->getParentModule();
84  canvasProjection = CanvasProjection::getCanvasProjection(visualizationTarget->getCanvas());
85  }
88  }
89 }
Additional physical environment initializations that depend on the previous stage.
Definition: InitStages.h:47
cModule * visualRepresentation
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:69
double z
Definition: Coord.h:51
virtual void initializePosition()
Initializes mobility position.
Definition: MobilityBase.cc:91
virtual cModule * findVisualRepresentation()
Returns the module that represents the object moved by this mobility module.
Definition: MobilityBase.h:120
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
Local initializations.
Definition: InitStages.h:35
virtual void initializeOrientation()
Initializes the orientation from module parameters.
Definition: MobilityBase.cc:140
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
const CanvasProjection * canvasProjection
The 2D projection used on the canvas.
Definition: MobilityBase.h:72
Coord constraintAreaMax
Definition: MobilityBase.h:75
static const CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:38
void inet::MobilityBase::initializeOrientation ( )
protectedvirtual

Initializes the orientation from module parameters.

Reimplemented in inet::RotatingMobilityBase, and inet::LinearRotatingMobilityBase.

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

141 {
142  if (hasPar("initialAlpha") && hasPar("initialBeta") && hasPar("initialGamma")) {
143  lastOrientation.alpha = par("initialAlpha");
144  lastOrientation.beta = par("initialBeta");
145  lastOrientation.gamma = par("initialGamma");
146  }
147 }
double gamma
Definition: EulerAngles.h:19
double beta
Definition: EulerAngles.h:18
EulerAngles lastOrientation
The last position that was reported.
Definition: MobilityBase.h:81
double alpha
Definition: EulerAngles.h:17
void inet::MobilityBase::initializePosition ( )
protectedvirtual

Initializes mobility position.

Reimplemented in inet::MovingMobilityBase, and inet::LineSegmentsMobilityBase.

Referenced by initialize(), inet::LineSegmentsMobilityBase::initializePosition(), and inet::MovingMobilityBase::initializePosition().

92 {
94  checkPosition();
97 }
virtual void emitMobilityStateChangedSignal()
Emits a signal with the updated mobility state.
Definition: MobilityBase.cc:176
virtual void updateVisualRepresentation()
Moves the visual representation module&#39;s icon to the new position on the screen.
Definition: MobilityBase.cc:157
virtual void setInitialPosition()
Initializes the position from the display string or from module parameters.
Definition: MobilityBase.cc:99
virtual void checkPosition()
Checks whether the position is valid or not.
Definition: MobilityBase.cc:129
bool inet::MobilityBase::isOutside ( )
protectedvirtual

Returns true if the mobility is outside of the constraint area.

Referenced by checkPosition(), placeRandomlyIfOutside(), and raiseErrorIfOutside().

191 {
195 }
double z
Definition: Coord.h:51
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Coord constraintAreaMax
Definition: MobilityBase.h:75
virtual int inet::MobilityBase::numInitStages ( ) const
inlineoverrideprotectedvirtual
void inet::MobilityBase::placeRandomlyIfOutside ( Coord targetPosition)
protectedvirtual

Utility function to place the node randomly if it goes outside the constraint area.

Decision is made on lastPosition, but targetPosition will also be updated. (Pass a dummy you don't have it).

Referenced by handleIfOutside().

251 {
252  if (isOutside()) {
253  Coord newPosition = getRandomPosition();
254  targetPosition += newPosition - lastPosition;
255  lastPosition = newPosition;
256  }
257 }
virtual Coord getRandomPosition()
Returns a new random position satisfying the constraint area.
Definition: MobilityBase.cc:181
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
virtual bool isOutside()
Returns true if the mobility is outside of the constraint area.
Definition: MobilityBase.cc:190
void inet::MobilityBase::raiseErrorIfOutside ( )
protectedvirtual

Utility function to raise an error if the node gets outside the constraint area.

Referenced by handleIfOutside(), inet::RandomWPMobility::move(), inet::ANSimMobility::move(), inet::BonnMotionMobility::move(), and inet::Ns2MotionMobility::move().

260 {
261  if (isOutside()) {
262  throw cRuntimeError("Mobility moved outside the area %g,%g,%g - %g,%g,%g (x=%g,y=%g,z=%g)",
266  }
267 }
double z
Definition: Coord.h:51
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
virtual bool isOutside()
Returns true if the mobility is outside of the constraint area.
Definition: MobilityBase.cc:190
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Coord constraintAreaMax
Definition: MobilityBase.h:75
void inet::MobilityBase::reflectIfOutside ( Coord targetPosition,
Coord speed,
double &  angle 
)
protectedvirtual

Utility function to reflect the node if it goes outside the constraint area.

Decision is made on pos, but the variables passed as args will also be updated. (Pass dummies you don't have some of them).

Referenced by handleIfOutside().

209 {
210  int sign;
211  double dummy = NaN;
213  sign = reflect(constraintAreaMin.x, constraintAreaMax.x, lastPosition.x, speed.x);
214  reflect(constraintAreaMin.x, constraintAreaMax.x, targetPosition.x, dummy);
215  angle = 90 + sign * (angle - 90);
216  }
218  sign = reflect(constraintAreaMin.y, constraintAreaMax.y, lastPosition.y, speed.y);
219  reflect(constraintAreaMin.y, constraintAreaMax.y, targetPosition.y, dummy);
220  angle = sign * angle;
221  }
223  sign = reflect(constraintAreaMin.z, constraintAreaMax.z, lastPosition.z, speed.z);
224  reflect(constraintAreaMin.z, constraintAreaMax.z, targetPosition.z, dummy);
225  // NOTE: angle is not affected
226  }
227 }
int sign(double i)
Returns 1 if the parameter is greater or equal to zero, -1 otherwise.
Definition: INETMath.h:146
double z
Definition: Coord.h:51
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
#define NaN
Definition: INETMath.h:103
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Coord constraintAreaMax
Definition: MobilityBase.h:75
void inet::MobilityBase::setInitialPosition ( )
protectedvirtual

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

Reimplemented in inet::MoBANCoordinator, inet::MoBANLocal, inet::Ns2MotionMobility, inet::TurtleMobility, inet::CircleMobility, inet::RectangleMobility, inet::LinearNodeDistributionMobility, inet::BonnMotionMobility, inet::TractorMobility, inet::ANSimMobility, inet::VehicleMobility, inet::StaticConcentricMobility, and inet::StaticGridMobility.

Referenced by initializePosition(), inet::RectangleMobility::setInitialPosition(), and inet::TurtleMobility::setInitialPosition().

100 {
101  // reading the coordinates from omnetpp.ini makes predefined scenarios a lot easier
102  bool filled = false;
103  auto coordinateSystem = getModuleFromPar<IGeographicCoordinateSystem>(par("coordinateSystemModule"), this, false);
104  if (hasPar("initFromDisplayString") && par("initFromDisplayString").boolValue() && visualRepresentation) {
105  const char *s = visualRepresentation->getDisplayString().getTagArg("p", 2);
106  if (s && *s)
107  throw cRuntimeError("The coordinates of '%s' are invalid. Please remove automatic arrangement"
108  " (3rd argument of 'p' tag) from '@display' attribute.", visualRepresentation->getFullPath().c_str());
109  filled = parseIntTo(visualRepresentation->getDisplayString().getTagArg("p", 0), lastPosition.x) &&
110  parseIntTo(visualRepresentation->getDisplayString().getTagArg("p", 1), lastPosition.y);
111  if (filled)
112  lastPosition.z = hasPar("initialZ") ? par("initialZ").doubleValue() : 0.0;
113  }
114  // not all mobility models have "initialX", "initialY" and "initialZ" parameters
115  else if (coordinateSystem == nullptr && hasPar("initialX") && hasPar("initialY") && hasPar("initialZ")) {
116  lastPosition.x = par("initialX");
117  lastPosition.y = par("initialY");
118  lastPosition.z = par("initialZ");
119  filled = true;
120  }
121  else if (coordinateSystem != nullptr && hasPar("initialLatitude") && hasPar("initialLongitude") && hasPar("initialAltitude")) {
122  lastPosition = coordinateSystem->computePlaygroundCoordinate(GeoCoord(par("initialLatitude"), par("initialLongitude"), par("initialAltitude")));
123  filled = true;
124  }
125  if (!filled)
127 }
cModule * visualRepresentation
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:69
double z
Definition: Coord.h:51
virtual Coord getRandomPosition()
Returns a new random position satisfying the constraint area.
Definition: MobilityBase.cc:181
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
value< double, units::s > s
Definition: Units.h:1049
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
void inet::MobilityBase::updateVisualRepresentation ( )
protectedvirtual

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

Reimplemented in inet::MoBANLocal.

Referenced by initializePosition(), inet::MovingMobilityBase::moveAndUpdate(), and inet::RotatingMobilityBase::rotateAndUpdate().

158 {
159  EV_DEBUG << "current position = " << lastPosition << endl;
160 #ifdef WITH_VISUALIZERS
161  if (hasGUI() && visualRepresentation != nullptr) {
163  }
164 #else
166  char buf[32];
167  snprintf(buf, sizeof(buf), "%lf", position.x);
168  buf[sizeof(buf) - 1] = 0;
169  visualRepresentation->getDisplayString().setTagArg("p", 0, buf);
170  snprintf(buf, sizeof(buf), "%lf", position.y);
171  buf[sizeof(buf) - 1] = 0;
172  visualRepresentation->getDisplayString().setTagArg("p", 1, buf);
173 #endif
174 }
cModule * visualRepresentation
Pointer to visual representation module, to speed up repeated access.
Definition: MobilityBase.h:69
static void setPosition(cModule *visualRepresentation, cFigure::Point position)
Definition: MobilityCanvasVisualizer.cc:193
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
const CanvasProjection * canvasProjection
The 2D projection used on the canvas.
Definition: MobilityBase.h:72
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
void inet::MobilityBase::wrapIfOutside ( Coord targetPosition)
protectedvirtual

Utility function to wrap the node to the opposite edge (torus) if it goes outside the constraint area.

Decision is made on pos, but targetPosition will also be updated. (Pass a dummy you don't have it).

Referenced by handleIfOutside().

235 {
238  wrap(constraintAreaMin.x, constraintAreaMax.x, targetPosition.x);
239  }
242  wrap(constraintAreaMin.y, constraintAreaMax.y, targetPosition.y);
243  }
246  wrap(constraintAreaMin.z, constraintAreaMax.z, targetPosition.z);
247  }
248 }
double z
Definition: Coord.h:51
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
Coord constraintAreaMin
3 dimensional position and size of the constraint area (in meters).
Definition: MobilityBase.h:75
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
Coord constraintAreaMax
Definition: MobilityBase.h:75

Member Data Documentation

const CanvasProjection* inet::MobilityBase::canvasProjection
protected

The 2D projection used on the canvas.

Referenced by initialize(), and updateVisualRepresentation().

Coord inet::MobilityBase::lastPosition
protected

The last position that was reported.

Referenced by checkPosition(), inet::TurtleMobility::executeStatement(), inet::LinearNodeDistributionMobility::finish(), inet::MovingMobilityBase::getCurrentPosition(), initialize(), inet::MoBANCoordinator::initialize(), inet::LineSegmentsMobilityBase::initializePosition(), isOutside(), inet::LineSegmentsMobilityBase::move(), inet::LinearMobility::move(), inet::VehicleMobility::move(), inet::RectangleMobility::move(), inet::MassMobility::move(), inet::CircleMobility::move(), placeRandomlyIfOutside(), inet::GaussMarkovMobility::preventBorderHugging(), raiseErrorIfOutside(), inet::MoBANCoordinator::readConfigurationFile(), reflectIfOutside(), inet::TurtleMobility::resumeScript(), inet::MoBANCoordinator::selectDestination(), inet::MoBANCoordinator::selectPosture(), inet::StaticGridMobility::setInitialPosition(), inet::StaticConcentricMobility::setInitialPosition(), inet::VehicleMobility::setInitialPosition(), inet::ANSimMobility::setInitialPosition(), inet::BonnMotionMobility::setInitialPosition(), inet::TractorMobility::setInitialPosition(), inet::LinearNodeDistributionMobility::setInitialPosition(), inet::TurtleMobility::setInitialPosition(), inet::Ns2MotionMobility::setInitialPosition(), inet::MoBANLocal::setInitialPosition(), setInitialPosition(), inet::MoBANLocal::setMoBANParameters(), inet::RandomWPMobility::setTargetPosition(), inet::ConstSpeedMobility::setTargetPosition(), inet::ChiangMobility::setTargetPosition(), inet::ANSimMobility::setTargetPosition(), inet::BonnMotionMobility::setTargetPosition(), inet::TractorMobility::setTargetPosition(), inet::GaussMarkovMobility::setTargetPosition(), inet::MassMobility::setTargetPosition(), inet::Ns2MotionMobility::setTargetPosition(), inet::MoBANLocal::setTargetPosition(), inet::MoBANCoordinator::setTargetPosition(), inet::MoBANLocal::updateVisualRepresentation(), updateVisualRepresentation(), and wrapIfOutside().


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