62 #include "ns3/buildings-module.h"
63 #include "ns3/core-module.h"
64 #include "ns3/network-module.h"
65 #include <ns3/mobility-module.h>
106 std::ofstream outFile;
107 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
108 if (!outFile.is_open())
117 Box box = (*it)->GetBoundaries();
118 outFile <<
"set object " << index <<
" rect from " << box.
xMin <<
"," << box.
yMin <<
" to "
119 << box.
xMax <<
"," << box.
yMax << std::endl;
124 main(
int argc,
char* argv[])
127 uint32_t numPrints = 800;
128 bool useHelper =
false;
131 cmd.AddValue(
"useHelper",
"Whether to use helper code", useHelper);
132 cmd.Parse(argc, argv);
134 g_timeSeries.open(
"outdoor-group-mobility-time-series.mob");
157 std::vector<Ptr<Building>> buildingVector;
159 building->SetBoundaries(
Box(45, 55, 5, 15, 0, 10));
160 buildingVector.push_back(building);
161 building = CreateObject<Building>();
162 building->SetBoundaries(
Box(45, 55, 35, 45, 0, 10));
163 buildingVector.push_back(building);
164 building = CreateObject<Building>();
165 building->SetBoundaries(
Box(17.5, 22.5, 22.5, 27.5, 0, 10));
166 buildingVector.push_back(building);
167 building = CreateObject<Building>();
168 building->SetBoundaries(
Box(77.5, 82.5, 22.5, 27.5, 0, 10));
169 buildingVector.push_back(building);
178 int64_t streamIndex = 1;
179 if (useHelper ==
false)
185 CreateObject<RandomWalk2dOutdoorMobilityModel>();
194 outdoorMm->SetAttribute(
"Tolerance",
DoubleValue(2));
196 outdoorMm->SetPosition(Vector(10, 10, 0));
197 streamIndex += outdoorMm->AssignStreams(streamIndex);
205 hierarchical0->SetParent(outdoorMm);
209 child0->SetPosition(Vector(1, 0, 0));
212 hierarchical0->SetChild(child0);
217 hierarchical1->SetParent(outdoorMm);
219 child1->SetPosition(Vector(-1, 0, 0));
220 hierarchical1->SetChild(child1);
223 hierarchical2->SetParent(outdoorMm);
225 child2->SetPosition(Vector(0, 1, 0));
226 hierarchical2->SetChild(child2);
245 listPosition->Add(Vector(10, 10, 0));
249 listPosition = CreateObject<ListPositionAllocator>();
250 listPosition->Add(Vector(1, 0, 0));
251 listPosition->Add(Vector(-1, 0, 0));
252 listPosition->Add(Vector(0, 1, 0));
268 for (
unsigned int i = 0; i < numPrints; i++)
270 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.
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...
void SetMemberMobilityModel(std::string type, Ts &&... args)
Configure the mobility model which will be installed as the member (child) mobility model during Grou...
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...
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
Keep track of the current position and velocity of an object.
Vector GetPosition() const
keep track of a set of node pointers.
Iterator End() 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.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
AttributeValue implementation for Rectangle.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() 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)
Print the buildings list in a format that can be used by Gnuplot to draw them.
std::ofstream g_timeSeries
The time series file.
void PrintPosition(Ptr< Node > node)
Print the node position to the time series file.