Lawn Mowing

In Class Exercise

package agentSystem;

import igeo.IVec;
import igeo.IPoint;

public class MowingAgent extends Agent {

float vel = 25;
double mowerwidth = 25;
double desiredoverlap = 0.25;
IVec baseDir;
IVec currDir;
boolean done = false;
int time = 0;
IPoint pt;
IVec newPos;
double turn = 1.57;

public MowingAgent(AgentManager _p5, IVec _pos, IVec _bdir) {
super(_p5,_pos);
this.pt = new IPoint(this.pos);
this.newPos = new IVec(this.pos);
this.baseDir = _bdir;
}

public void mow() {

//determine which direction I need to be going
if(!this.inBounds())
{
//change direction
baseDir.neg();
//turn opposite each time
this.turn = -this.turn;
//turn around and shift down to get the desired mower overlap
this.newPos = this.pos.dup().add(this.currDir.dup().rot(this.turn).len(mowerwidth-(mowerwidth*desiredoverlap)));
this.pos.set(this.newPos);
//get back into the lawn
this.pos.set(this.pos.dup().add(this.currDir.dup().len(vel)));

}

//determine how far Im mowing
this.newPos.set(this.pos.dup().add(this.currDir.dup().len(vel)));

//mow
this.pos.set(this.newPos);
}

public boolean inBounds() {
return this.p5.boundaryCrv.isInside2d(this.pos);
}

public void update() {
if(!done) {
mow();
} else {
System.out.println("whew, time for a beer");
}
}

public void redraw() {
pt.pos = this.pos;
}

}

Advertisements

SENSOR/GPS DATA INTERPOLATION

The issue start with the different kinds of data. We got 1903 light data from sensor which was based on time, and got 107 GPS points which was based on distance.

So, the problem need be solved here is interpolate more GPS points for each light data. Here is the JAVA program.

STEP 1, IMPORT DATA

1

STEP2, INTERPOLATE DATA

W-2

 

STEP 3, EXPORT DATA

5

With this program we got a new CSV files with 1903 data include light data and gps data. Here is the QGIS visualize the data. (The blue point is the original 107 GPS points we got, the red point between is the new point we interpolate.)

2222

image