|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
20 #include "ns3/simulator.h"
24 #include "ns3/string.h"
25 #include "ns3/pointer.h"
38 static TypeId tid =
TypeId (
"ns3::RandomDirection2dMobilityModel")
40 .SetGroupName (
"Mobility")
42 .AddAttribute (
"Bounds",
"The 2d bounding area",
46 .AddAttribute (
"Speed",
"A random variable to control the speed (m/s).",
47 StringValue (
"ns3::UniformRandomVariable[Min=1.0|Max=2.0]"),
49 MakePointerChecker<RandomVariableStream> ())
50 .AddAttribute (
"Pause",
"A random variable to control the pause (s).",
51 StringValue (
"ns3::ConstantRandomVariable[Constant=2.0]"),
53 MakePointerChecker<RandomVariableStream> ())
60 m_direction = CreateObject <UniformRandomVariable> ();
101 const Vector vector (std::cos (direction) * speed,
102 std::sin (direction) * speed,
123 direction += M_PI / 2;
126 direction += -M_PI / 2;
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
RandomDirection2dMobilityModel()
void BeginPause(void)
Pause, cancel currently scheduled event, schedule end of pause event.
void SetVelocity(const Vector &vel)
Set new velocity vector.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual void DoInitialize(void)
Initialize() implementation.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ConstantVelocityHelper m_helper
helper for velocity computations
Random direction mobility model.
void DoInitializePrivate(void)
Sets a new random direction and calls SetDirectionAndSpeed.
AttributeValue implementation for Rectangle.
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void DoDispose(void)
Destructor implementation.
virtual Vector DoGetVelocity(void) const
Ptr< const AttributeAccessor > MakeRectangleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< RandomVariableStream > m_pause
a random variable to control pause
Vector GetCurrentPosition(void) const
Get current position vector.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
Vector CalculateIntersection(const Vector ¤t, const Vector &speed) const
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Rectangle m_bounds
the 2D bounding area
Simulation virtual time values and global simulation resolution.
void Unpause(void)
Resume mobility from current position at current velocity.
virtual void DoInitialize(void)
Initialize() implementation.
Ptr< UniformRandomVariable > m_direction
rv to control direction
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Hold variables of type string.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
void SetDirectionAndSpeed(double direction)
Set new velocity and direction, and schedule next pause event
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
void UpdateWithBounds(const Rectangle &rectangle) const
Update position, if not paused, from last position and time of last update.
Ptr< const AttributeChecker > MakeRectangleChecker(void)
Time Seconds(double value)
Construct a Time in the indicated unit.
void Update(void) const
Update position, if not paused, from last position and time of last update.
EventId m_event
event ID of next scheduled event
Side GetClosestSide(const Vector &position) const
void SetPosition(const Vector &position)
Set position vector.
Keep track of the current position and velocity of an object.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Ptr< RandomVariableStream > m_speed
a random variable to control speed
void Pause(void)
Pause mobility at current position.
virtual void DoDispose(void)
Destructor implementation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
virtual void DoSetPosition(const Vector &position)
Vector GetVelocity(void) const
Get velocity; if paused, will return a zero vector.
virtual Vector DoGetPosition(void) const
void ResetDirectionAndSpeed(void)
Set a new direction and speed.