A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::WaypointMobilityModel Class Reference

Waypoint-based mobility model. More...

#include <waypoint-mobility-model.h>

+ Inheritance diagram for ns3::WaypointMobilityModel:
+ Collaboration diagram for ns3::WaypointMobilityModel:

Public Member Functions

 WaypointMobilityModel ()
 Create a path with no waypoints at location (0,0,0). More...
 
virtual ~WaypointMobilityModel ()
 
void AddWaypoint (const Waypoint &waypoint)
 
void EndMobility (void)
 Clear any existing waypoints and set the current waypoint time to infinity. More...
 
Waypoint GetNextWaypoint (void) const
 Get the waypoint that this object is traveling towards. More...
 
uint32_t WaypointsLeft (void) const
 Get the number of waypoints left for this object, excluding the next one. More...
 
- Public Member Functions inherited from ns3::MobilityModel
 MobilityModel ()
 
virtual ~MobilityModel ()=0
 
int64_t AssignStreams (int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model. More...
 
double GetDistanceFrom (Ptr< const MobilityModel > position) const
 
Vector GetPosition (void) const
 
double GetRelativeSpeed (Ptr< const MobilityModel > other) const
 
Vector GetVelocity (void) const
 
void SetPosition (const Vector &position)
 
- Public Member Functions inherited from ns3::Object
 Object ()
 
virtual ~Object ()
 
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 Run the DoDispose methods of this object and all the objects aggregated to it. More...
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 This method calls the virtual DoInitialize method on all the objects aggregated to this object. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::MobilityModel
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 Noop. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Member Functions

virtual void DoDispose (void)
 This method is called by Object::Dispose or by the object's destructor, whichever comes first. More...
 
virtual Vector DoGetPosition (void) const
 
virtual Vector DoGetVelocity (void) const
 
virtual void DoSetPosition (const Vector &position)
 
void Update (void) const
 

Private Attributes

Waypoint m_current
 
bool m_first
 
bool m_initialPositionIsWaypoint
 
bool m_lazyNotify
 
Waypoint m_next
 
Vector m_velocity
 
std::deque< Waypointm_waypoints
 

Friends

class ::WaypointMobilityModelNotifyTest
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::MobilityModel
void NotifyCourseChange (void) const
 Must be invoked by subclasses when the course of the position changes to notify course change listeners. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoInitialize (void)
 This method is called only once by Object::Initialize. More...
 
virtual void NotifyNewAggregate (void)
 This method is invoked whenever two sets of objects are aggregated together. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 This method is invoked once all member attributes have been initialized. More...
 

Detailed Description

Waypoint-based mobility model.

Each object determines its velocity and position at a given time from a set of ns3::Waypoint objects. Past waypoints are discarded after the current simulation time greater than their time value.

By default, the initial position of each object corresponds to the position of the first waypoint, and the initial velocity of each object is zero. Upon reaching the last waypoint, object position becomes static and velocity is zero.

When a node is in between waypoint times, it moves with a constant velocity between the position at the previous waypoint and the position at the current waypoint. To make a node hold a certain position for a time interval, two waypoints with the same position (but different times) should be inserted sequentially.

Waypoints can be added at any time, and setting the current position of an object will set its velocity to zero until the next waypoint time (at which time the object jumps to the next waypoint), unless there are no more waypoints in which case it will not change without user intervention.

The model has two attributes with methods that allow clients to get the next waypoint value (NextWaypoint) and the number of waypoints left (WaypointsLeft) beyond (but not including) the next waypoint.

In addition, there are two attributes that govern model behavior. The first, LazyNotify, governs how the model calls the CourseChange trace. By default, LazyNotify is false, which means that each time that a waypoint time is hit, an Update() is forced and the CourseChange callback will be called. When LazyNotify is true, Update() is suppressed at waypoint times, and CourseChange callbacks will only occur when there later are actual calls to Update () (typically when calling GetPosition ()). This option may be enabled for execution run-time performance improvements, but when enabled, users should note that course change listeners will in general not be notified at waypoint times but instead at the next Update() following a waypoint time, and some waypoints may not be notified to course change listeners.

The second, InitialPositionIsWaypoint, is false by default. Recall that the first waypoint will set the initial position and set velocity equal to 0 until the first waypoint time. In such a case, the call to SetPosition(), such as from a PositionAllocator, will be ignored. However, if InitialPositionIsWaypoint is set to true and SetPosition() is called before any waypoints have been added, the SetPosition() call is treated as an initial waypoint at time zero. In such a case, when SetPosition() is treated as an initial waypoint, it should be noted that attempts to add a waypoint at the same time will cause the program to fail.

Config Paths

ns3::WaypointMobilityModel is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/$ns3::MobilityModel/$ns3::WaypointMobilityModel

Attributes

  • NextWaypoint: The next waypoint used to determine position.
  • WaypointsLeft: The number of waypoints remaining.
  • LazyNotify: Only call NotifyCourseChange when position is calculated.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read
  • InitialPositionIsWaypoint: Calling SetPosition with no waypoints creates a waypoint.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read

Attributes defined in parent class ns3::MobilityModel

  • Position: The current position of the mobility model.
  • Velocity: The current velocity of the mobility model.

No TraceSources are defined for this type.

TraceSources defined in parent class ns3::MobilityModel

  • CourseChange: The value of the position and/or velocity vector changed

Definition at line 86 of file waypoint-mobility-model.h.

Constructor & Destructor Documentation

ns3::WaypointMobilityModel::WaypointMobilityModel ( )

Create a path with no waypoints at location (0,0,0).

Definition at line 67 of file waypoint-mobility-model.cc.

ns3::WaypointMobilityModel::~WaypointMobilityModel ( )
virtual

Definition at line 73 of file waypoint-mobility-model.cc.

Member Function Documentation

void ns3::WaypointMobilityModel::AddWaypoint ( const Waypoint waypoint)
Parameters
waypointwaypoint to append to the object path.

Add a waypoint to the path of the object. The time must be greater than the previous waypoint added, otherwise a fatal error occurs. The first waypoint is set as the current position with a velocity of zero.

Definition at line 82 of file waypoint-mobility-model.cc.

References m_current, m_first, m_lazyNotify, m_next, m_waypoints, NS_ABORT_MSG_IF, ns3::Simulator::Schedule(), ns3::Waypoint::time, and Update().

Referenced by WaypointMobilityModelNotifyTest::DoRun(), WaypointInitialPositionIsWaypoint::DoRun(), WaypointMobilityModelViaHelper::DoRun(), and DoSetPosition().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::WaypointMobilityModel::DoDispose ( void  )
privatevirtual

This method is called by Object::Dispose or by the object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.

It is safe to call GetObject from within this method.

Reimplemented from ns3::Object.

Definition at line 77 of file waypoint-mobility-model.cc.

References ns3::Object::DoDispose().

+ Here is the call graph for this function:

Vector ns3::WaypointMobilityModel::DoGetPosition ( void  ) const
privatevirtual
Returns
the current position.

Concrete subclasses of this base class must implement this method.

Implements ns3::MobilityModel.

Definition at line 175 of file waypoint-mobility-model.cc.

References m_current, ns3::Waypoint::position, and Update().

+ Here is the call graph for this function:

Vector ns3::WaypointMobilityModel::DoGetVelocity ( void  ) const
privatevirtual
Returns
the current velocity.

Concrete subclasses of this base class must implement this method.

Implements ns3::MobilityModel.

Definition at line 211 of file waypoint-mobility-model.cc.

References m_velocity.

void ns3::WaypointMobilityModel::DoSetPosition ( const Vector position)
privatevirtual
Parameters
positionthe position to set.

Concrete subclasses of this base class must implement this method.

Implements ns3::MobilityModel.

Definition at line 181 of file waypoint-mobility-model.cc.

References AddWaypoint(), m_current, m_first, m_initialPositionIsWaypoint, m_next, m_velocity, ns3::MobilityModel::NotifyCourseChange(), ns3::Simulator::Now(), ns3::Waypoint::position, ns3::Waypoint::time, and Update().

+ Here is the call graph for this function:

void ns3::WaypointMobilityModel::EndMobility ( void  )

Clear any existing waypoints and set the current waypoint time to infinity.

Calling this is only an optimization and not required. After calling this function, adding waypoints behaves as it would for a new object.

Definition at line 203 of file waypoint-mobility-model.cc.

References m_current, m_first, m_next, m_waypoints, and ns3::Waypoint::time.

Waypoint ns3::WaypointMobilityModel::GetNextWaypoint ( void  ) const

Get the waypoint that this object is traveling towards.

Definition at line 102 of file waypoint-mobility-model.cc.

References m_next, and Update().

Referenced by GetTypeId().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TypeId ns3::WaypointMobilityModel::GetTypeId ( void  )
static

Definition at line 38 of file waypoint-mobility-model.cc.

References ns3::TypeId::ATTR_GET, GetNextWaypoint(), m_initialPositionIsWaypoint, m_lazyNotify, ns3::TypeId::SetParent(), and WaypointsLeft().

+ Here is the call graph for this function:

void ns3::WaypointMobilityModel::Update ( void  ) const
private
uint32_t ns3::WaypointMobilityModel::WaypointsLeft ( void  ) const

Get the number of waypoints left for this object, excluding the next one.

Definition at line 108 of file waypoint-mobility-model.cc.

References m_waypoints, and Update().

Referenced by GetTypeId(), and WaypointInitialPositionIsWaypoint::TestNumWaypoints().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class ::WaypointMobilityModelNotifyTest
friend

Definition at line 128 of file waypoint-mobility-model.h.

Member Data Documentation

Waypoint ns3::WaypointMobilityModel::m_current
mutableprivate
bool ns3::WaypointMobilityModel::m_first
private

Definition at line 136 of file waypoint-mobility-model.h.

Referenced by AddWaypoint(), DoSetPosition(), and EndMobility().

bool ns3::WaypointMobilityModel::m_initialPositionIsWaypoint
private

Definition at line 138 of file waypoint-mobility-model.h.

Referenced by DoSetPosition(), and GetTypeId().

bool ns3::WaypointMobilityModel::m_lazyNotify
private

Definition at line 137 of file waypoint-mobility-model.h.

Referenced by AddWaypoint(), and GetTypeId().

Waypoint ns3::WaypointMobilityModel::m_next
mutableprivate
Vector ns3::WaypointMobilityModel::m_velocity
mutableprivate

Definition at line 142 of file waypoint-mobility-model.h.

Referenced by DoGetVelocity(), DoSetPosition(), and Update().

std::deque<Waypoint> ns3::WaypointMobilityModel::m_waypoints
mutableprivate

Definition at line 139 of file waypoint-mobility-model.h.

Referenced by AddWaypoint(), EndMobility(), Update(), and WaypointsLeft().


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