How to change the nodes position with time?

210 views
Skip to first unread message

Mahmudul Islam

unread,
Jun 28, 2021, 11:00:53 PM6/28/21
to ns-3-users
Hello everyone,

I want to change the nodes position with time to a specific location. For example in the network, at time t=0, I have two nodes A (0.0, 0.0, 0.0) and B (0.0, 10.0, 0.0) with these initial positions. After 10 seconds I want node A to be at position (0.0, 20.0, 0.0) and node B at (50.0, 20.0, 0.0). After 10 seconds I want the nodes to be another specific location and so on.

How can I set the mobility of the nodes in such a way?

Adil Alsuhaim

unread,
Jul 5, 2021, 9:06:55 AM7/5/21
to ns-3-users
You install some mobility model to the nodes first. For example, ConstantPositionMobilityModel. What this does is aggregate a mobility model object to the node. You can obtain that object from any node that has mobility install to it like this:

//Get a pointer to node 3. FYI, ns-3 keeps pointers to all nodes in NodeList
Ptr <Node> my_node = NodeList::GetNode (3);

//Get the mobility model of that node
Ptr <MobilityModel> mm = my_node->GetObject <MobilityModel> ();

//Change the position of node 3
mm->SetPosition (Vector (10,20,0));

So this code can be placed inside a function that you would scheduled every time you want to update the node's position

Cheers,
Adil

Mahmudul Islam

unread,
Jul 7, 2021, 5:34:02 AM7/7/21
to ns-3-users
Thank you for your reply. I found another way and it is to use WaypointMobility model. I used this to achieve the mobility that I wanted.

  MobilityHelper mobilityUAV;
  mobilityUAV.SetMobilityModel("ns3::WaypointMobilityModel");
  
  mobilityUAV.Install(nodes.Get (2));

  Ptr<WaypointMobilityModel> wayMobility;

  wayMobility = nodes.Get(2)->GetObject<WaypointMobilityModel>();

  Waypoint waypointStart(Seconds(0), Vector3D(0, 200, 1.5));
  Waypoint waypointEnd(Seconds(4.9), Vector3D(1200, 200, 1.5));

  wayMobility->AddWaypoint(waypointStart);
  wayMobility->AddWaypoint(waypointEnd);

  Waypoint waypointStart1(Seconds(5), Vector3D(1150, 200, 1.5));
  Waypoint waypointEnd1(Seconds(10), Vector3D(1200, 200, 1.5));

  wayMobility->AddWaypoint(waypointStart1);
  wayMobility->AddWaypoint(waypointEnd1);

Hemant Saini

unread,
Jul 7, 2021, 5:41:28 AM7/7/21
to ns-3-...@googlegroups.com

Hi Mahmud can you pl tell how calculate energy consumption with simulation time in ns3


--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/6e3196e6-4a29-4ea1-b3f7-ecf04d0ed95fn%40googlegroups.com.

Mahmudul Islam

unread,
Jul 7, 2021, 5:54:22 AM7/7/21
to ns-3-users
Hello Saini,
I am sorry, I actually don't know how to calculate the energy consumption of nodes.

To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.

Hemant Saini

unread,
Jul 7, 2021, 7:53:22 AM7/7/21
to ns-3-...@googlegroups.com

Hi Mahmud
Am also working in uav
Actually am not understanding what you want to do
R u making scenario
Or doing changes in mobility

I think u need vector I can help you you connect me on my mail

For hint you would take vector position=get position()
Then you will get one by one position
Where you can also do changes


To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+unsubscribe@googlegroups.com.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/3ed50604-6627-4f4a-8d9e-5114006262fdn%40googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages