64 #include "ns3/core-module.h"
65 #include <ns3/mobility-module.h>
66 #include "ns3/network-module.h"
67 #include "ns3/buildings-module.h"
78 if (node ==
nullptr)
return;
80 if (model ==
nullptr)
return;
89 std::ofstream outFile;
90 outFile.open (filename.c_str (), std::ios_base::out | std::ios_base::trunc);
91 if (!outFile.is_open ())
100 Box box = (*it)->GetBoundaries ();
101 outFile <<
"set object " << index
102 <<
" rect from " << box.
xMin <<
"," << box.
yMin
103 <<
" to " << box.
xMax <<
"," << box.
yMax
109 main (
int argc,
char *argv[])
112 uint32_t numPrints = 800;
113 bool useHelper =
false;
116 cmd.AddValue (
"useHelper",
"Whether to use helper code", useHelper);
117 cmd.Parse (argc, argv);
119 g_timeSeries.open (
"outdoor-group-mobility-time-series.mob");
142 std::vector<Ptr<Building> > buildingVector;
144 building->SetBoundaries (
Box (45, 55, 5, 15, 0, 10));
145 buildingVector.push_back (building);
146 building = CreateObject<Building> ();
147 building->SetBoundaries (
Box (45, 55, 35, 45, 0, 10));
148 buildingVector.push_back (building);
149 building = CreateObject<Building> ();
150 building->SetBoundaries (
Box (17.5, 22.5, 22.5, 27.5, 0, 10));
151 buildingVector.push_back (building);
152 building = CreateObject<Building> ();
153 building->SetBoundaries (
Box (77.5, 82.5, 22.5, 27.5, 0, 10));
154 buildingVector.push_back (building);
163 int64_t streamIndex = 1;
164 if (useHelper ==
false)
178 outdoorMm->SetAttribute (
"Tolerance",
DoubleValue (2));
180 outdoorMm->SetPosition (Vector (10, 10, 0));
181 streamIndex += outdoorMm->AssignStreams (streamIndex);
189 hierarchical0->SetParent (outdoorMm);
193 child0->SetPosition (Vector (1, 0, 0));
196 hierarchical0->SetChild (child0);
201 hierarchical1->SetParent (outdoorMm);
203 child1->SetPosition (Vector (-1, 0, 0));
204 hierarchical1->SetChild (child1);
207 hierarchical2->SetParent (outdoorMm);
209 child2->SetPosition (Vector (0, 1, 0));
210 hierarchical2->SetChild (child2);
227 listPosition->Add (Vector (10, 10, 0));
231 listPosition = CreateObject<ListPositionAllocator> ();
232 listPosition->Add (Vector (1, 0, 0));
233 listPosition->Add (Vector (-1, 0, 0));
234 listPosition->Add (Vector (0, 1, 0));
249 for (
unsigned int i = 0; i < numPrints; i++)
251 for (
auto nodeIt = n.
Begin (); nodeIt != n.
End (); ++nodeIt)
Manage ASCII trace files for device models.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
double yMax
The y coordinate of the top bound of the box.
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
std::vector< Ptr< Building > >::const_iterator Iterator
Const Iterator.
static Iterator End(void)
static Iterator Begin(void)
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class used to assign positions and mobility models to nodes for a group mobility configuration...
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the mobility models on t...
void SetMemberPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of the member mobility...
void Install(Ptr< Node > node)
Install and configure a hierarchical mobility model to the given node, based on the configured refere...
void SetReferenceMobilityModel(Ptr< MobilityModel > mobility)
Set the reference mobility model which will be installed as the parent mobility model during GroupMob...
void SetReferencePositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of the reference mobil...
void SetMemberMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
Configure the mobility model which will be installed as the member (child) mobility model during Grou...
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
Keep track of the current position and velocity of an object.
Vector GetPosition(void) const
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t GetId(void) const
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
AttributeValue implementation for Rectangle.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Run(void)
Run the simulation.
static Time Now(void)
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void PrintGnuplottableBuildingListToFile(std::string filename)
std::ofstream g_timeSeries
void PrintPosition(Ptr< Node > node)