Commit be48ff82 authored by Julian Zobel's avatar Julian Zobel
Browse files

Config Attraction Point gegerator

parent 32541a7c
......@@ -76,26 +76,7 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
@Override
public void move(long timeBetweenMovementOperations) {
if(false) {
System.out.println(hoverThrustRequired());
System.out.println(motor.getMaxThrust());
System.out.println(horizontalMaxVelocity());
for(int i = 0; i <= horizontalMaxVelocity(); i++) {
double J = motor.estimatePowerConsumptionWatt(estimateRequiredThrust(i));
System.out.println("v = " + i + " ==> " + J + " J => "
+ ((topologyComponent.getMaximumBatteryCapacity() / Battery.uJconverison) / J / 60) + " minutes" );
}
first =false;
}
if(motor.isOn() && !route.isEmpty()) {
PositionVector position = new PositionVector(topologyComponent.getRealPosition());
......
......@@ -2,6 +2,7 @@ package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
/**
* A basic attraction point, as simple as it can get. Really just a named location
......@@ -18,7 +19,11 @@ public class BasicAttractionPoint extends PositionVector implements AttractionPo
this.name = name;
}
@XMLConfigurableConstructor({ "name", "x", "y" })
public BasicAttractionPoint(String name, double x, double y) {
this(name, new PositionVector(x, y));
}
@Override
public String getName() {
return name;
......
......@@ -19,10 +19,7 @@
*/
package de.tud.kom.p2psim.impl.topology.movement.modularosm.attraction;
import java.util.LinkedList;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
/**
......@@ -33,15 +30,14 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
*/
public class ConfigAttractionGenerator implements IAttractionGenerator {
private final List<AttractionPoint> points = new LinkedList<>();
@Override
public List<AttractionPoint> getAttractionPoints() {
return points;
return attractionPoints;
}
public void setAttractionPoint(AttractionPoint point) {
this.points.add(point);
attractionPoints.add(point);
}
}
......@@ -47,7 +47,7 @@ public class CsvAttractionGenerator implements IAttractionGenerator {
private final String SEP = ";";
private List<AttractionPoint> attractionPoints;
private double radius = 0;
/**
*
......@@ -58,12 +58,17 @@ public class CsvAttractionGenerator implements IAttractionGenerator {
this.worldDimensions = Binder.getComponentOrNull(Topology.class)
.getWorldDimensions();
this.file = placementFile;
readData();
}
public void setRadius(double radius) {
this.radius = radius;
}
@Override
public List<AttractionPoint> getAttractionPoints() {
if (attractionPoints == null) {
attractionPoints = new LinkedList<>();
if (attractionPoints == null) {
readData();
}
return attractionPoints;
......@@ -93,8 +98,37 @@ public class CsvAttractionGenerator implements IAttractionGenerator {
+ y);
continue;
}
attractionPoints.add(new AttractionPointImpl("AP"+i, new PositionVector(x,
y)));
AttractionPoint ap = new AttractionPointImpl("AP"+i, new PositionVector(x, y));
ap.setRadius(radius);
attractionPoints.add(ap);
i++;
entrySuccessfullyRead = true;
} catch (NumberFormatException e) {
// Ignore leading comments
if (entrySuccessfullyRead) {
// System.err.println("CSV ParseError " + line);
}
}
}
else if(parts.length == 3) {
try {
Double x = Double.parseDouble(parts[0]);
Double y = Double.parseDouble(parts[1]);
Double r = Double.parseDouble(parts[2]);
if (x > worldDimensions.getX()
|| y > worldDimensions.getY() || x < 0
|| y < 0) {
System.err.println("Skipped entry " + x + ";"
+ y);
continue;
}
AttractionPoint ap = new AttractionPointImpl("AP"+i, new PositionVector(x, y));
ap.setRadius(r);
attractionPoints.add(ap);
i++;
entrySuccessfullyRead = true;
} catch (NumberFormatException e) {
......@@ -104,6 +138,7 @@ public class CsvAttractionGenerator implements IAttractionGenerator {
}
}
}
} else {
throw new AssertionError("To many columns in CSV.");
}
......
......@@ -54,9 +54,9 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
* assertions. Replace does now fully replace the position vector entries. PVs are now
* always at least 3D (with 0 altitude)
*
* - 14.03.2019 Louis Neumann: added timestamp when creating a PositionVector and adjusted ageOfLocation()
* - 14.03.2019 Louis Neumann: Added timestamp when creating a PositionVector and adjusted ageOfLocation()
*
* - 18.04.2019 Louis Neumann: added setAgeofLocation()
* - 04.06.2019 Julian Zobel: Clone function also clones the timestamp from the cloned position.
*
* @author Bjoern Richerzhagen, Julian Zobel, Louis Neumann
* @version 1.2, 10.09.2018
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment