This is the local mobility module of MoBAN. It should be instantiated in each node that belongs to a WBAN. The NED parameter "coordinatorIndex" determine to which WBAN (MoBANCoordinator) it belongs. The current implementation uses the Random Walk Mobility Model (RWMM) for individual (local) movement with a sphere around the node, with given speed and sphere radius of the current posture. The reference point of the node it the current posture, the sphere radius, and the speed is given by the corresponding coordinator through the blackboard. RWMM determines the location of node at ant time relative to the given reference point. More...
#include <MoBANLocal.h>
Inherits BaseMobility.
Public Member Functions | |
virtual void | initialize (int) |
Initializes the parameters of the local mobility module. | |
Protected Member Functions | |
virtual void | makeMove () |
Move the node. | |
virtual void | setTargetPosition () |
Selects a target position for the next move and set the corresponding variables. | |
virtual void | receiveBBItem (int category, const BBItem *details, int scopeModuleId) |
Function which is called when something is written to the blackboard of this node. | |
Coord | insideWorld (Coord apoint) |
Gets a position and return the nearest point inside the simulation area if the point is outside the area. | |
Protected Attributes | |
Coord | referencePoint |
Reference point of the node in the current posture. It is gotten from the MoBAN coordinator through blackboard. | |
double | radius |
The radius of local mobility of the node in the current posture. It is gotten from the MoBAN coordinator through blackboard. | |
double | speed |
The speed of local mobility of the node in the current posture. It is gotten from the MoBAN coordinator through blackboard. | |
Coord | targetPos |
The relative target position of the current move. | |
Coord | stepTarget |
The relative position of the node in the next step. | |
int | catRefMove |
Variable to keep the category of the information that the coordinator publishes to the blackboard. | |
Coord | stepSize |
parameters to handle the movement of the host | |
int | numSteps |
Total number of steps. | |
int | step |
Number of steps already moved. |
This is the local mobility module of MoBAN. It should be instantiated in each node that belongs to a WBAN. The NED parameter "coordinatorIndex" determine to which WBAN (MoBANCoordinator) it belongs. The current implementation uses the Random Walk Mobility Model (RWMM) for individual (local) movement with a sphere around the node, with given speed and sphere radius of the current posture. The reference point of the node it the current posture, the sphere radius, and the speed is given by the corresponding coordinator through the blackboard. RWMM determines the location of node at ant time relative to the given reference point.
Definition at line 58 of file MoBANLocal.h.
Gets a position and return the nearest point inside the simulation area if the point is outside the area.
Gets a position and return the nearest point inside the simulation area if the point is outside the area
Definition at line 176 of file MoBANLocal.cc.
References BaseWorldUtility::getPgs(), Coord::getX(), Coord::getY(), Coord::getZ(), Coord::setX(), Coord::setY(), Coord::setZ(), and BaseMobility::world.
Referenced by makeMove(), receiveBBItem(), and setTargetPosition().
{ double xmax, ymax, zmax; Coord NearestBorder = apoint; xmax = world->getPgs()->getX(); ymax = world->getPgs()->getY(); zmax = world->getPgs()->getZ(); if (NearestBorder.getX() < 0) NearestBorder.setX(0.0); if (NearestBorder.getY() < 0) NearestBorder.setY(0.0); if (NearestBorder.getZ() < 0) NearestBorder.setZ(0.0); if (NearestBorder.getX() > xmax) NearestBorder.setX(xmax); if (NearestBorder.getY() > ymax) NearestBorder.setY(ymax); if (NearestBorder.getZ() > zmax) NearestBorder.setZ(zmax); return NearestBorder; }
void MoBANLocal::makeMove | ( | ) | [protected, virtual] |
Move the node.
Move the host if the destination is not reached yet. Otherwise calculate a new random position. This function is called by the BaseMobility module considering the given update time interval.
Reimplemented from BaseMobility.
Definition at line 128 of file MoBANLocal.cc.
References Move::info(), insideWorld(), BaseMobility::move, numSteps, referencePoint, Move::setStart(), setTargetPosition(), step, stepSize, and stepTarget.
{ // increment number of steps step++; if( step == numSteps ){ EV << "destination reached. " << move.info() << endl; setTargetPosition(); } else if( step < numSteps ){ // step forward stepTarget += stepSize; move.setStart(insideWorld(stepTarget+referencePoint),simTime()); } else{ error("step cannot be bigger than numSteps"); } }
void MoBANLocal::receiveBBItem | ( | int | category, | |
const BBItem * | details, | |||
int | scopeModuleId | |||
) | [protected, virtual] |
Function which is called when something is written to the blackboard of this node.
This function is called once something is written to the blackboard of this node. If the written item has specific category dedicated for the type that MoBAN coordinator writes, the item will be read and the corresponding variables are set.
Reimplemented from BaseModule.
Definition at line 152 of file MoBANLocal.cc.
References catRefMove, FWMath::close(), insideWorld(), BaseMobility::move, radius, referencePoint, Move::setSpeed(), Move::setStart(), speed, and stepTarget.
{ if(category == catRefMove) { BBMoBANMessage m(*static_cast<const BBMoBANMessage*>(details)); referencePoint= m.position; speed = m.speed; if ( !FWMath::close(speed,0.0) ) move.setSpeed(speed); // IF WE SET ZERO, it is not going to move anymore radius = m.radius; move.setStart(insideWorld(stepTarget+referencePoint),simTime()); EV<<"Node "<< getParentModule()->getIndex() <<" received new reference point."<<endl; EV<< "New speed:" << speed <<" , new radius: "<< radius <<endl; } }
void MoBANLocal::setTargetPosition | ( | ) | [protected, virtual] |
Selects a target position for the next move and set the corresponding variables.
Calculate a new random position within a sphere around the reference point with the given radius. It also calculates the number of steps the node needs to reach this position with the given speed
Definition at line 73 of file MoBANLocal.cc.
References Coord::distance(), Move::getSpeed(), Move::getStartPos(), Coord::info(), insideWorld(), BaseMobility::move, numSteps, radius, referencePoint, FWMath::round(), Move::setStart(), Coord::setX(), Coord::setY(), Coord::setZ(), speed, step, stepSize, stepTarget, targetPos, and BaseMobility::updateInterval.
Referenced by makeMove().
{ Coord currentRelativePosition; if (speed != 0) { // Find a uniformly random position within a sphere around the reference point double x = uniform(-1*radius, radius); double y = uniform(-1*radius, radius); double z = uniform(-1*radius, radius); while (x*x+y*y+z*z > radius*radius) { x = uniform(-1*radius, radius); y = uniform(-1*radius, radius); z = uniform(-1*radius, radius); } targetPos.setX(x); targetPos.setY(y); targetPos.setZ(z); currentRelativePosition = move.getStartPos()- referencePoint; double distance = currentRelativePosition.distance(targetPos); simtime_t totalTime = distance / move.getSpeed(); if (totalTime >= updateInterval) numSteps = FWMath::round(totalTime / updateInterval); else numSteps = 1; //The selected target position is quite close so that in less than one step, it will be reached with the given velocity. stepSize = (targetPos - currentRelativePosition)/numSteps; stepTarget = (move.getStartPos()-referencePoint) + stepSize; } else { numSteps = 1; targetPos = referencePoint; stepSize = Coord(0,0,0); stepTarget = Coord(0,0,0); } move.setStart(insideWorld(stepTarget + referencePoint),simTime()); step = 0; EV << "new targetPos: " << targetPos.info() << " numSteps=" << numSteps << endl; }
Coord MoBANLocal::stepSize [protected] |
parameters to handle the movement of the host
Size of a step
Definition at line 74 of file MoBANLocal.h.
Referenced by initialize(), makeMove(), and setTargetPosition().