Tractor movement model. See NED file for more info. More...
#include <TractorMobility.h>
Inherits BaseMobility.
Public Member Functions | |
virtual void | initialize (int) |
Initializes mobility model parameters. | |
Protected Member Functions | |
virtual void | makeMove () |
Move the host. | |
virtual void | fixIfHostGetsOutside () |
Should be redefined in subclasses. | |
void | calculateXY () |
Maps d to (x,y) coordinates. | |
Protected Attributes | |
double | x1 |
double | y1 |
double | x2 |
double | y2 |
rectangle bounds of the field | |
double | dx |
double | dy |
dimensions of the field | |
double | rows |
the number of rows that the tractor must take | |
double | row_length |
double | row_width |
the lenght and width of a row | |
double | path_length |
double | position |
Coord | targetPos |
Target position of the host. |
Tractor movement model. See NED file for more info.
NOTE: Does not yet support 3-dimensional movement.
Definition at line 33 of file TractorMobility.h.
void TractorMobility::fixIfHostGetsOutside | ( | ) | [protected, virtual] |
Should be redefined in subclasses.
Should invoke handleIfOutside() and pass the references to the parameters to be modified.
Additional action after border handling (such as choosing a new target position if the BorderPolicy is PLACERANDOMLY) should be implemented here.
Reimplemented from BaseMobility.
Definition at line 77 of file TractorMobility.cc.
References BaseMobility::handleIfOutside(), BaseMobility::RAISEERROR, targetPos, BaseWorldUtility::use2D(), and BaseMobility::world.
Referenced by makeMove().
{ Coord dummy(world->use2D()); double dum; handleIfOutside( RAISEERROR, targetPos, dummy, dummy, dum ); }
void TractorMobility::initialize | ( | int | stage | ) | [virtual] |
Initializes mobility model parameters.
Reads the parameters and initializes members.
Reimplemented from BaseMobility.
Definition at line 30 of file TractorMobility.cc.
References calculateXY(), dy, BaseMobility::move, row_width, rows, Move::setSpeed(), Move::setStart(), targetPos, BaseWorldUtility::use2D(), BaseMobility::world, and y2.
{ BaseMobility::initialize(stage); debugEV << "initializing TractorMobility stage " << stage << endl; if (stage == 0) { x1 = par("x1"); y1 = par("y1"); x2 = par("x2"); y2 = par("y2"); rows = par("rows"); move.setSpeed(par("speed")); dx = x2-x1; dy = y2-y1; row_length = dx; row_width = dy / rows; path_length = rows * (row_length + row_width); position = 0.0; calculateXY(); move.setStart(targetPos); } else { if(!world->use2D()) { opp_warning("This mobility module does not yet support 3 dimensional movement."\ "Movements will probably be incorrect."); } } }