Position Allocator exceptions

892 views
Skip to first unread message

Naeem Ahmad

unread,
Apr 13, 2013, 3:12:34 AM4/13/13
to ns-3-...@googlegroups.com
Hello everyone
I am using below code. but giving exception like  .....

assert failed. cond="m_position", msg="No position allocator added before using this model", file=../src/mobility/model/random-waypoint-mobility-model.cc, line=63
terminate called without an active exception

Kindly give the solution if anybody have... thanks in advance

Code is ....

 MobilityHelper mobility;

 mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "Rho", StringValue ("ns3::UniformRandomVariable[Min=0|Max=30]"));

 mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
                             "Speed", StringValue ("ns3::UniformRandomVariable[Min=0|Max=60]"),
                             "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"),
                             "PositionAllocator", PointerValue ());

 mobility.Install (nodes);




Konstantinos

unread,
Apr 13, 2013, 7:19:07 AM4/13/13
to ns-3-...@googlegroups.com
Hi Naeem,

You are trying to set the Position Allocator for the randomwaypoint mobility model like this :

  "PositionAllocator", PointerValue ());

But you are not giving it any actual value. 
So, I would suggest not to include it at all, it is not required, since you have used the mobility.SetPositionAllocator.

Naeem Ahmad

unread,
Apr 13, 2013, 7:24:51 AM4/13/13
to ns-3-...@googlegroups.com
thanks Konstantinos

now its working.


--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/Qaf7p8lO9CE/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

abdul

unread,
May 28, 2014, 5:15:09 AM5/28/14
to ns-3-...@googlegroups.com

Hello,

Can you please tell me how you solved your problem for the randomwaypoint mobility model ?
I have the same exactly and It does not work
The piece of concered code is:
///
 
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();

positionAlloc->Add(Vector (50,50,0.0)); //for node 0
positionAlloc->Add(Vector (60,60,0.0));    // for node 1
positionAlloc->Add(Vector (70,70,0.0));// for node 2


mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
                             "Speed", StringValue ("ns3::UniformRandomVariable[Min=20|Max=70]"),
                             "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=2.0]"));
mobility.SetPositionAllocator(positionAlloc);

mobility.Install (wifiStaNodes);
///

The output error is:

assert failed. cond="m_position", msg="No position allocator added before using this model", file=../src/mobility/model/random-waypoint-mobility-model.cc, line=63
terminate called without an active exception

Thanks in advance

Konstantinos

unread,
May 28, 2014, 5:42:22 AM5/28/14
to ns-3-...@googlegroups.com
The RandomWaypointModel requires the position allocator as an attribute as well as in the mobility helper. See the highlighted text bellow.
mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
                           
"Speed", StringValue ("ns3::UniformRandomVariable[Min=20|Max=70]"),

                           
"Pause", StringValue ("ns3::ConstantRandomVariable[Constant=2.0]"),
                           
"PositionAllocator", PointerValue (positionAlloc));
mobility
.SetPositionAllocator(positionAlloc);

abdul

unread,
May 28, 2014, 11:21:07 AM5/28/14
to ns-3-...@googlegroups.com
Hello,

Many many thanks dear Konstantino !

It works very fine now

Best regards,

Abdulhalim

Fernaz Nur

unread,
Jul 15, 2015, 5:05:13 AM7/15/15
to ns-3-...@googlegroups.com
I've also the same problem, How can I fix it?


MobilityHelper mobility;

 mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "Rho", StringValue ("ns3::UniformRandomVariable[Min=0|Max=30]"));

 mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
                             "Speed", StringValue ("ns3::UniformRandomVariable[Min=0|Max=60]"),
                             "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]")
                             );

Error:

assert failed. cond="m_position", msg="No position allocator added before using this model", file=../src/mobility/model/random-waypoint-mobility-model.cc, line=63
terminate called without an active exception
 Please help me in this regard.


Konstantinos

unread,
Jul 15, 2015, 5:27:13 AM7/15/15
to ns-3-...@googlegroups.com, fern...@gmail.com
Since you have the same problem as above and a solution is given (twice), why don't you follow that solution?
The RandomWayPointMobilityModel requires an attribute for PositionAllocator that you are not setting.

Fernaz Nur

unread,
Jul 15, 2015, 5:52:16 AM7/15/15
to ns-3-...@googlegroups.com, fern...@gmail.com
I've tried that solution, the difference from that code is I'm using RandomDiscPositionAllocator. I've given below the code. When I'm writing the code without PositionAllocator exception is given and when I am giving the PositionAllocator error is given.


mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
                                 "X", StringValue ("100.0"),
                                 "Y", StringValue ("100.0"),
                                 "Rho", StringValue ("ns3::UniformRandomVariable[Min=0|Max=30]"));

 mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
                             "Speed", StringValue ("ns3::UniformRandomVariable[Min=0|Max=60]"),
                             "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"),
                             "PositionAllocator", PointerValue (RandomDiscPositionAllocator));

Error:
error: expected primary-expression before ‘(’ token
                              "PositionAllocator", PointerValue (RandomDiscPositionAllocator)
                                                                ^
../scratch/mobiledcd.cc:278:92: error: expected primary-expression before ‘)’ token
                              "PositionAllocator", PointerValue (RandomDiscPositionAllocator)
                                                                                            ^
cc1plus: all warnings being treated as errors

I am new in NS3, please help me. . . .

Tommaso Pecorella

unread,
Jul 15, 2015, 10:03:37 AM7/15/15
to ns-3-...@googlegroups.com
This is not an ns-3 problem. This is a plain, old C++ mistake. You're using a class name instead of a instance pointer.
Can I suggest to triple check the error messages ? They are informative sometimes.

T.

Fernaz Nur

unread,
Jul 16, 2015, 3:57:06 AM7/16/15
to ns-3-...@googlegroups.com
Thank you very much...................
Message has been deleted

Konstantinos

unread,
Jul 16, 2015, 5:22:19 AM7/16/15
to ns-3-...@googlegroups.com, fern...@gmail.com
Yes, you can. See the examples in /examples/wireless
There are cases where some nodes are moving and others are static (in the same scenario)

Please do not ask irrelevant questions in the topic. If you have another question, ask it in a new topic.

On Thursday, July 16, 2015 at 10:18:54 AM UTC+1, Fernaz Nur wrote:
Can i make 1 node static which acts as sink and others mobile nodes for a wireless network?

anubhav asthana

unread,
Aug 2, 2017, 3:48:41 PM8/2/17
to ns-3-users, fern...@gmail.com
Hello every one, I am using the following code:-

 MobilityHelper mobility;
 


  /*uniform disc position allocator*/

  /*ObjectFactory pos;
  pos.SetTypeId ("ns3::UniformDiscPositionAllocator");
  pos.Set ("rho", DoubleValue (50.0));
  pos.Set ("X", DoubleValue (0.0));
  pos.Set ("Y", DoubleValue (0.0));

 
 
 
 
  std::ostringstream speedConstantRandomVariableStream;
  speedConstantRandomVariableStream << "ns3::ConstantRandomVariable[Constant="
                                   << m_nodeSpeed
                                   << "]";

  Ptr <PositionAllocator> taPositionAlloc = pos.Create ()->GetObject <PositionAllocator> ();
  mobility.SetPositionAllocator (taPositionAlloc);
  mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel", "Speed", StringValue (speedConstantRandomVariableStream.str ()),
                             "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=2.0]"), "PositionAllocator", PointerValue      (taPositionAlloc));*/




    mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
                                "rho",  DoubleValue (50.0),
                                 "X",  DoubleValue (0.0),
                                "Y",DoubleValue (0.0));



 
  mobility.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
                             "Speed",StringValue ("ns3::UniformRandomVariable[Min=0.4|Max=10.0]"),
                             "Pause",StringValue ("ns3::ConstantRandomVariable[Constant=2.0]"),
                             "PositionAllocator", StringValue ("ns3::UniformDiscPositionAllocator"));

  mobility.Install (nodes);
 my question is that at first part I am using pointer value in random way point mobility model and analyzing the result at pyviz its working.

 But in the later part when I am passing the string value in random way point mobility model and analyzing the result using pyviz then it is found that all nodes gets collected at position (0,0) and their is no movement in nodes. 


dsdv-UDA.cc
Reply all
Reply to author
Forward
0 new messages