BonnMotion mobility example
This commit is contained in:
65
src/mobility/examples/bonnmotion-ns2-example.cc
Normal file
65
src/mobility/examples/bonnmotion-ns2-example.cc
Normal file
@@ -0,0 +1,65 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright 2012 Eric Gamess
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
void showPosition (Ptr<Node> node, double deltaTime)
|
||||
{
|
||||
uint32_t nodeId = node->GetId ();
|
||||
Ptr<MobilityModel> mobModel = node->GetObject<MobilityModel> ();
|
||||
Vector3D pos = mobModel->GetPosition ();
|
||||
Vector3D speed = mobModel->GetVelocity ();
|
||||
std::cout << "At " << Simulator::Now ().GetSeconds () << " node " << nodeId
|
||||
<< ": Position(" << pos.x << ", " << pos.y << ", " << pos.z
|
||||
<< "); Speed(" << speed.x << ", " << speed.y << ", " << speed.z
|
||||
<< ")" << std::endl;
|
||||
|
||||
Simulator::Schedule (Seconds (deltaTime), &showPosition, node, deltaTime);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::cout.precision (2);
|
||||
std::cout.setf (std::ios::fixed);
|
||||
|
||||
double deltaTime = 100;
|
||||
std::string traceFile = "src/mobility/examples/bonnmotion.ns_movements";
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("traceFile", "Ns2 movement trace file", traceFile);
|
||||
cmd.AddValue ("deltaTime", "time interval (s) between updates (default 100)", deltaTime);
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
Ptr<Node> n0 = CreateObject<Node> ();
|
||||
|
||||
Ns2MobilityHelper ns2 = Ns2MobilityHelper (traceFile);
|
||||
ns2.Install ();
|
||||
|
||||
Simulator::Schedule (Seconds (0.0), &showPosition, n0, deltaTime);
|
||||
|
||||
Simulator::Stop (Seconds (1000.0));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
13
src/mobility/examples/bonnmotion.ns_movements
Normal file
13
src/mobility/examples/bonnmotion.ns_movements
Normal file
@@ -0,0 +1,13 @@
|
||||
$node_(0) set X_ 329.82427591159615
|
||||
$node_(0) set Y_ 66.06016140869389
|
||||
$ns_ at 0.0 "$node_(0) setdest 378.37542668840655 45.5928630482057 0.5734697219630068"
|
||||
# $ns_ at 91.87745989691848 "$node_(0) setdest 378.37542668840655 45.5928630482057 0.0"
|
||||
$ns_ at 119.3714959084341 "$node_(0) setdest 286.6872580249029 142.51631507750932 1.332870521776484"
|
||||
# $ns_ at 219.47118355124258 "$node_(0) setdest 286.6872580249029 142.51631507750932 0.0"
|
||||
$ns_ at 276.35353365269884 "$node_(0) setdest 246.3202938897401 107.57197005511536 0.7008963309037789"
|
||||
# $ns_ at 352.52885253886916 "$node_(0) setdest 246.3202938897401 107.57197005511536 0.0"
|
||||
$ns_ at 354.65588903148546 "$node_(0) setdest 27.380316338943658 186.9421090132031 1.0371865939384077"
|
||||
# $ns_ at 579.1889287677668 "$node_(0) setdest 27.380316338943658 186.9421090132031 0.0"
|
||||
$ns_ at 594.0371861260464 "$node_(0) setdest 241.0193442850251 42.45159418309071 0.9183517582470467"
|
||||
# $ns_ at 874.8806114578338 "$node_(0) setdest 241.0193442850251 42.45159418309071 0.0"
|
||||
$ns_ at 884.7739898066011 "$node_(0) setdest 309.59230940611315 37.21622103424196 0.5968489961030224"
|
||||
4
src/mobility/examples/bonnmotion.ns_params
Normal file
4
src/mobility/examples/bonnmotion.ns_params
Normal file
@@ -0,0 +1,4 @@
|
||||
set val(x) 420.0
|
||||
set val(y) 220.0
|
||||
set val(nn) 1
|
||||
set val(duration) 1000.0
|
||||
12
src/mobility/examples/bonnmotion.params
Normal file
12
src/mobility/examples/bonnmotion.params
Normal file
@@ -0,0 +1,12 @@
|
||||
model=RandomWaypoint
|
||||
ignore=3600.0
|
||||
randomSeed=1347984564833
|
||||
x=400.0
|
||||
y=200.0
|
||||
duration=1000.0
|
||||
nn=1
|
||||
circular=false
|
||||
dim=3
|
||||
minspeed=0.5
|
||||
maxspeed=1.5
|
||||
maxpause=60.0
|
||||
@@ -19,3 +19,7 @@ def build(bld):
|
||||
obj = bld.create_ns3_program('ns2-mobility-trace',
|
||||
['core', 'mobility'])
|
||||
obj.source = 'ns2-mobility-trace.cc'
|
||||
|
||||
obj = bld.create_ns3_program('bonnmotion-ns2-example',
|
||||
['core', 'mobility'])
|
||||
obj.source = 'bonnmotion-ns2-example.cc'
|
||||
|
||||
Reference in New Issue
Block a user