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

Tractor movement model. More...

#include <TractorMobility.h>

Inheritance diagram for inet::TractorMobility:
inet::LineSegmentsMobilityBase inet::MovingMobilityBase inet::MobilityBase inet::IMobility

Public Member Functions

 TractorMobility ()
 
virtual double getMaxSpeed () const override
 Returns the maximum possible speed at any future time. More...
 
- Public Member Functions inherited from inet::LineSegmentsMobilityBase
 LineSegmentsMobilityBase ()
 
- Public Member Functions inherited from inet::MovingMobilityBase
virtual Coord getCurrentPosition () override
 Returns the current position at the current simulation time. More...
 
virtual Coord getCurrentSpeed () override
 Returns the current speed at the current simulation time. More...
 
virtual EulerAngles getCurrentAngularPosition () override
 Returns the current angular position at the current simulation time. More...
 
- Public Member Functions inherited from inet::MobilityBase
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 ()
 

Protected Member Functions

virtual int numInitStages () const override
 Returns the required number of initialize stages. More...
 
virtual void initialize (int) override
 Initializes mobility model parameters. More...
 
virtual void setInitialPosition () override
 Initializes the position according to the mobility model. More...
 
void setTargetPosition () override
 Calculate a new target position to move to. More...
 
- Protected Member Functions inherited from inet::LineSegmentsMobilityBase
virtual void initializePosition () override
 Initializes mobility position. More...
 
virtual void move () override
 Moves according to the mobility model to the current simulation time. More...
 
- Protected Member Functions inherited from inet::MovingMobilityBase
 MovingMobilityBase ()
 
virtual ~MovingMobilityBase ()
 
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 moveAndUpdate ()
 Moves and notifies listeners. More...
 
- Protected Member Functions inherited from inet::MobilityBase
 MobilityBase ()
 
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 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

double speed
 
double x1
 
double y1
 
double x2
 
double y2
 rectangle bounds of the field More...
 
int rowCount
 the number of rows that the tractor must take More...
 
int step
 
- Protected Attributes inherited from inet::LineSegmentsMobilityBase
Coord targetPosition
 End position of current linear movement. More...
 
- Protected Attributes inherited from inet::MovingMobilityBase
cMessage * moveTimer
 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...
 
Coord lastSpeed
 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...
 

Detailed Description

Tractor movement model.

See NED file for more info.

NOTE: Does not yet support 3-dimensional movement.

Author
Peterpaul Klein Haneveld

Constructor & Destructor Documentation

inet::TractorMobility::TractorMobility ( )
27 {
28  speed = 0;
29  x1 = 0;
30  y1 = 0;
31  x2 = 0;
32  y2 = 0;
33  rowCount = 0;
34  step = 0;
35 }
double x2
Definition: TractorMobility.h:39
double speed
Definition: TractorMobility.h:38
int rowCount
the number of rows that the tractor must take
Definition: TractorMobility.h:40
double y1
Definition: TractorMobility.h:39
double x1
Definition: TractorMobility.h:39
double y2
rectangle bounds of the field
Definition: TractorMobility.h:39
int step
Definition: TractorMobility.h:41

Member Function Documentation

virtual double inet::TractorMobility::getMaxSpeed ( ) const
inlineoverridevirtual

Returns the maximum possible speed at any future time.

Reimplemented from inet::MobilityBase.

57 { return speed; }
double speed
Definition: TractorMobility.h:38
void inet::TractorMobility::initialize ( int  stage)
overrideprotectedvirtual

Initializes mobility model parameters.

Reimplemented from inet::MovingMobilityBase.

38 {
40 
41  EV_TRACE << "initializing TractorMobility stage " << stage << endl;
42  if (stage == INITSTAGE_LOCAL) {
43  speed = par("speed");
44  x1 = par("x1");
45  y1 = par("y1");
46  x2 = par("x2");
47  y2 = par("y2");
48  rowCount = par("rowCount");
49  step = 0;
50  }
51 }
double x2
Definition: TractorMobility.h:39
virtual void initialize(int stage) override
Initializes mobility model parameters.
Definition: MovingMobilityBase.cc:42
double speed
Definition: TractorMobility.h:38
int rowCount
the number of rows that the tractor must take
Definition: TractorMobility.h:40
double y1
Definition: TractorMobility.h:39
double x1
Definition: TractorMobility.h:39
Local initializations.
Definition: InitStages.h:35
double y2
rectangle bounds of the field
Definition: TractorMobility.h:39
int step
Definition: TractorMobility.h:41
virtual int inet::TractorMobility::numInitStages ( ) const
inlineoverrideprotectedvirtual

Returns the required number of initialize stages.

Reimplemented from inet::MobilityBase.

44 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::TractorMobility::setInitialPosition ( )
overrideprotectedvirtual

Initializes the position according to the mobility model.

Reimplemented from inet::MobilityBase.

54 {
55  lastPosition.x = x1;
56  lastPosition.y = y1;
57 }
double y1
Definition: TractorMobility.h:39
double x1
Definition: TractorMobility.h:39
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
double y
Definition: Coord.h:50
double x
Definition: Coord.h:49
void inet::TractorMobility::setTargetPosition ( )
overrideprotectedvirtual

Calculate a new target position to move to.

Implements inet::LineSegmentsMobilityBase.

60 {
61  int sign;
62  Coord positionDelta = Coord::ZERO;
63  switch (step % 4) {
64  case 0:
65  positionDelta.x = x2 - x1;
66  break;
67 
68  case 1:
69  case 3:
70  sign = (step / (2 * rowCount)) % 2 ? -1 : 1;
71  positionDelta.y = (y2 - y1) / rowCount * sign;
72  break;
73 
74  case 2:
75  positionDelta.x = x1 - x2;
76  break;
77  }
78  step++;
79  targetPosition = lastPosition + positionDelta;
80  nextChange = simTime() + positionDelta.length() / speed;
81 }
double x2
Definition: TractorMobility.h:39
int sign(double i)
Returns 1 if the parameter is greater or equal to zero, -1 otherwise.
Definition: INETMath.h:146
double speed
Definition: TractorMobility.h:38
int rowCount
the number of rows that the tractor must take
Definition: TractorMobility.h:40
double y1
Definition: TractorMobility.h:39
double x1
Definition: TractorMobility.h:39
Coord lastPosition
The last position that was reported.
Definition: MobilityBase.h:78
simtime_t nextChange
The next simulation time when the mobility module needs to update its internal state.
Definition: MovingMobilityBase.h:60
Coord targetPosition
End position of current linear movement.
Definition: LineSegmentsMobilityBase.h:41
static const Coord ZERO
Definition: Coord.h:41
double x
Definition: Coord.h:49
double y2
rectangle bounds of the field
Definition: TractorMobility.h:39
int step
Definition: TractorMobility.h:41

Member Data Documentation

int inet::TractorMobility::rowCount
protected

the number of rows that the tractor must take

Referenced by initialize(), setTargetPosition(), and TractorMobility().

double inet::TractorMobility::speed
protected
int inet::TractorMobility::step
protected
double inet::TractorMobility::x1
protected
double inet::TractorMobility::x2
protected
double inet::TractorMobility::y1
protected
double inet::TractorMobility::y2
protected

rectangle bounds of the field

Referenced by initialize(), setTargetPosition(), and TractorMobility().


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