Move entire "dumbbell" at a constant speed

20 views
Skip to first unread message

RedNumberOne

unread,
Apr 9, 2019, 8:47:23 PM4/9/19
to ns-3-users
I'm trying to move the dumbbell generated by this code at a constant speed. I'm not sure what to do next as whenever I add anything related to SetPositionAllocator or SetMobilityModel, all the node appear at a single point.

#include <iostream>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/netanim-module.h"
#include "ns3/applications-module.h"
#include "ns3/point-to-point-layout-module.h"
#include "ns3/mobility-module.h"

using namespace ns3;

int main (int argc, char *argv[])
{

  uint32_t    nLeftLeaf = 5;
 uint32_t    nRightLeaf = 5;
 uint32_t    nLeaf = 0; // If non-zero, number of both left and right
 std::string animFile = "dumbbell-animation.xml" ;  // Name of file for animation output

  CommandLine cmd;
 cmd.AddValue ("nLeftLeaf", "Number of left side leaf nodes", nLeftLeaf);
 cmd.AddValue ("nRightLeaf","Number of right side leaf nodes", nRightLeaf);
 cmd.AddValue ("nLeaf",     "Number of left and right side leaf nodes", nLeaf);
 cmd.AddValue ("animFile",  "File Name for Animation Output", animFile);

  cmd.Parse (argc,argv);
 if (nLeaf > 0)
   {
     nLeftLeaf = nLeaf;
     nRightLeaf = nLeaf;
   }

  // Create the point-to-point link helpers
 PointToPointHelper pointToPointRouter;
 PointToPointHelper pointToPointLeaf;

  PointToPointDumbbellHelper d (nLeftLeaf, pointToPointLeaf,
                               nRightLeaf, pointToPointLeaf,
                               pointToPointRouter);

  // Set the bounding box for animation
 d.BoundingBox (1, 1, 100, 100);

  // Create the animation object and configure for specified output
 AnimationInterface anim (animFile);
 
 Simulator::Stop (Seconds (100.0));
 
 Simulator::Run ();
 std::cout << "Animation Trace file created:" << animFile.c_str ()<< std::endl;
 Simulator::Destroy ();
 return 0;
}


pdbarnes

unread,
Apr 12, 2019, 11:25:26 AM4/12/19
to ns-3-users
Look at the HierarchicalMobilityModel.

Peter

Reply all
Reply to author
Forward
0 new messages