On node B, ensure that mobility
is enabled, and the location
and origin
are set, so that you're in local coordinate systems in meters. If your coordinate system is not geo-referenced, you can set origin
to [NaN, NaN]
:
def node = agentForService org.arl.unet.Services.NODE_INFO
node.origin = [Float.NaN, Float.NaN] // or GPS coordinates
node.location = [0, 0, 0] // or wherever you want to start
node.mobility = true
Now, when you receive your datagram on node B, your agent can set the node.speed
and node.heading
to your desired speed and heading. For example:
node.heading = 90 // head East
node.speed = 1 // at 1 m/s
In reality, you may want to compute the heading to your desired waypoint.
Your agent can monitor the position of the node (perhaps using a TickerBehavior
), and when it's time to stop (e.g. you've reached close enough to your way point [2,0,0]
), set the speed to 0:
// if within 1 m of waypoint, stop
if (MathUtils.distance(node.location, [2,0,0] as double[]) < 1) {
node.speed = 0
}