Search code examples
omnet++inet

Position of INET sink node defined by $ParameterName is not updated


I set up a wireless sensor network as below.(Emphasis on sink node definition)

import  inet.physicallayer.wireless.apsk.packetlevel.ApskScalarRadioMedium;                                          
import inet.node.inet.SensorNode;
network SensorNetwork
{      
int numNodes = default(15);   
string interfaceTableModule = default("interfaceTable");    
int areaX @unit(m) = 500m;             
int areaY @unit(m) = 500m;            
int sinkX @unit(m) = int (this.areaX*(0.5));                
int sinkY @unit(m) = this.areaY;                
@display("bgb=$areaX,$areaY;bgu=m");

submodules:
    sink: SensorNode {
      @display("i=device/antennatower;p=$sinkX,$sinkY");
    }

    node[numNodes]: SensorNode;

    radioMedium: ApskScalarRadioMedium {
        @display("p=45,79");
    }
}

I would like to highlight the fact that sink position is given by parameters. When I run the project, and go to check the details related to the mobility submodule of the sink node I find that the last position coordinate is (lastPosition (Coord) (0, 0, 0) m) whereas it should have the current coordinate of the sink node in the network. When I delete the parameter and give the numeric values to X and Y from @display("p=500,500;i=device/antennatower");,the position is well updated as (lastPosition (Coord) (500, 500, 0) m).

How to fix it?

Please, your advice is highly appreciated.

Thanks in advance.


Solution

  • When I try to reproduce this (I'm using omnetpp-pre13 development branch + inet 4.4 development branch), I get an error:

    Mobility position is not a finite number after initialize (x=-nan,y=-nan,z=-nan) -- in module (inet::StationaryMobility)

    However, you can specify node positions via the mobility module in the .INI file (initialX, initialY, initialZ parameters), which I think is the intended way. You can use variables for the position there as well.