title: How to set node position in NetAnim? I always get Use SetConstantPosition if it is stationary error
body: <p>I am new to ns-3. I am trying to understand from the very basic. I created a network simulation containing two switches, then I want to visualize it using NetAnim.</p>
  <p>Followings are my code</p>
  <pre><code>
  /* -*- Mode:C++; c-file-style:&quot;gnu&quot;; indent-tabs-mode:nil; -*- */
  /*
   * 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 &quot;ns3/core-module.h&quot;
  #include &quot;ns3/point-to-point-module.h&quot;
  #include &quot;ns3/network-module.h&quot;
  #include &quot;ns3/applications-module.h&quot;
  #include &quot;ns3/mobility-module.h&quot;
  #include &quot;ns3/csma-module.h&quot;
  #include &quot;ns3/internet-module.h&quot;
  #include &quot;ns3/yans-wifi-helper.h&quot;
  #include &quot;ns3/ssid.h&quot;
  #include &quot;ns3/netanim-module.h&quot;
  #include &quot;stdio.h&quot;
  
  using namespace ns3;
  
  NS_LOG_COMPONENT_DEFINE (&quot;HMTMRSim&quot;);
  
  int 
  main (int argc, char *argv[])
  {
  
    std::cout &lt;&lt; &quot;create switches&quot; &lt;&lt; std::endl;
    NodeContainer switches;
    switches.Create(2); // create two switches
  
    AnimationInterface anim(&quot;myanim.xml&quot;);
  
    std::cout &lt;&lt; &quot;set position for switches&quot; &lt;&lt; std::endl;
  
    anim.SetConstantPosition(switches.Get(0), 48.0, 70.0, 0);
    anim.SetConstantPosition(switches.Get(1), 48.0, 90.0, 0);
  
    anim.UpdateNodeDescription(0, &quot;Main&quot;);
    anim.UpdateNodeDescription(1, &quot;Rack0&quot;);
  
    anim.UpdateNodeSize(0, 10, 10);
    anim.UpdateNodeColor(0, 0, 0, 255);
    Simulator::Run ();
    Simulator::Destroy ();
    return 0;
  }
  
  </code></pre>
  <p>When I run it, it works without problem, but I get this warning</p>
  <pre><code>Waf: Leaving directory `/Users/arwankhoiruddin/Downloads/ns-allinone-3.30.1/ns-3.30.1/build'
  Build commands will be stored in build/compile_commands.json
  'build' finished successfully (18.508s)
  create switches
  AnimationInterface WARNING:Node:0 Does not have a mobility model. Use SetConstantPosition if it is stationary
  AnimationInterface WARNING:Node:1 Does not have a mobility model. Use SetConstantPosition if it is stationary
  AnimationInterface WARNING:Node:0 Does not have a mobility model. Use SetConstantPosition if it is stationary
  AnimationInterface WARNING:Node:
  </code></pre>
  <p>When I open in NetAnim (shown in the picture below), it seems to ignore the position that I defined in my code. As you see in the following properties, the first node (node 0) has position of (x,y) = (81.00, 83.00).</p>
  <p>I am aware that I can change the position by changing the value in properties, but later using ns-3, I want to create quite a complex network, so it will be difficult to set them manually.</p>
  <p>In internet, I found this suggestion, i.e. adding mobility to replace the SetConstantPosition. However, the result in NetAnim is still similar.</p>
  <pre><code>MobilityHelper mobility;
  Ptr&lt;ListPositionAllocator&gt; positionAlloc = CreateObject&lt;ListPositionAllocator&gt;();
  positionAlloc-&gt;Add(Vector(0.0, 0.0, 0.0));
  positionAlloc-&gt;Add(Vector(5.0, 0.0, 0.0));
  mobility.SetPositionAllocator(positionAlloc);
  mobility.SetMobilityModel(&quot;ns3::ConstantPositionMobilityModel&quot;);
  mobility.Install(switches);
  </code></pre>
  <p>Please let me know how to set the position from my code and get rid of the warning.</p>
  <p>Thank you for your kind helps</p>
  <p><a href="https://i.stack.imgur.com/i4b8V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i4b8V.png" alt="netanim" /></a></p>