LOGO-style movement model, with the script coming from XML. See NED file for more info. More...
#include <TurtleMobility.h>
Inherits LineSegmentsMobilityBase.
Public Member Functions | |
virtual void | initialize (int) |
Initializes mobility model parameters. | |
Protected Member Functions | |
virtual void | setTargetPosition () |
Overridden from LineSegmentsMobilityBase. Invokes resumeScript(). | |
virtual void | fixIfHostGetsOutside () |
Overridden from BaseMobility. | |
void | resumeScript () |
Process next statements from script. | |
void | executeStatement (cXMLElement *nextStatement) |
Execute the given statement. | |
double | getValue (const char *s) |
Parse attrs in the script -- accepts things like "uniform(10,50)" as well. | |
void | gotoNextStatement () |
Advance nextStatement pointer. | |
Protected Attributes | |
cXMLElement * | turtleScript |
cXMLElement * | nextStatement |
double | angle |
BorderPolicy | borderPolicy |
std::stack< long > | loopVars |
LOGO-style movement model, with the script coming from XML. See NED file for more info.
NOTE: Does not yet support 3-dimensional movement.
Definition at line 34 of file TurtleMobility.h.
void TurtleMobility::initialize | ( | int | stage | ) | [virtual] |
Initializes mobility model parameters.
Reads the parameters. If the host is not stationary it calculates a random position and schedules a timer to trigger the first movement
Reimplemented from LineSegmentsMobilityBase.
Definition at line 31 of file TurtleMobility.cc.
References Move::getStartPos(), BaseMobility::move, Move::setSpeed(), LineSegmentsMobilityBase::targetPos, LineSegmentsMobilityBase::targetTime, BaseWorldUtility::use2D(), and BaseMobility::world.
{ LineSegmentsMobilityBase::initialize(stage); debugEV << "initializing TurtleMobility stage " << stage << endl; if(stage == 0) { turtleScript = par("turtleScript"); nextStatement = turtleScript->getFirstChild(); move.setSpeed(1); angle = 0; borderPolicy = REFLECT; // a dirty trick to extract starting position out of the script // (start doing it, but then rewind to the beginning) // does not really work // we need to set the startPos initially for which there is no option in // turtlemobility // -> always starting with random position... (Daniel) //resumeScript(); //nextStatement = turtleScript->getFirstChild(); //while (!loopVars.empty()) loopVars.pop(); // WATCH for member 'speed' of the Move is disabled at the moment // because the member is not accessible directly anymore //WATCH(move.speed); WATCH(angle); WATCH(borderPolicy); } else if(stage == 1){ if(!world->use2D()) { opp_warning("This mobility module does not yet support 3 dimensional movement."\ "Movements will probably be incorrect."); } targetPos = move.getStartPos(); stepTarget = move.getStartPos(); targetTime = simTime(); } }
void TurtleMobility::resumeScript | ( | ) | [protected] |
Process next statements from script.
Will set a new targetTime and targetPos
Definition at line 98 of file TurtleMobility.cc.
References executeStatement(), gotoNextStatement(), BaseMobility::move, Move::setSpeed(), and LineSegmentsMobilityBase::targetTime.
Referenced by setTargetPosition().
{ if (!nextStatement) { move.setSpeed(0); debugEV << "no statement found -> not moving!\n"; return; } simtime_t now = targetTime; // interpret statement while (nextStatement && targetTime==now) { executeStatement(nextStatement); gotoNextStatement(); } }