Commit 4c53019c authored by Julian Zobel's avatar Julian Zobel
Browse files

Moved the database output for UAV models to the respective movement model.

parent 6599a3a1
......@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.energy.components;
import java.util.Comparator;
import java.util.LinkedList;
import de.tud.kom.p2psim.api.energy.ComponentType;
import de.tud.kom.p2psim.api.energy.EnergyEventListener;
import de.tud.kom.p2psim.api.energy.EnergyState;
......
......@@ -34,12 +34,10 @@ import de.tud.kom.p2psim.api.topology.movement.UAVMovementModel;
import de.tud.kom.p2psim.api.topology.placement.PlacementModel;
import de.tud.kom.p2psim.impl.energy.RechargeableBattery;
import de.tud.kom.p2psim.impl.energy.components.ActuatorComponent;
import de.tud.kom.p2psim.impl.energy.components.StatelessActuatorComponent;
import de.tud.kom.p2psim.impl.energy.models.AbstractEnergyModel;
import de.tud.kom.p2psim.impl.topology.placement.UAVBasePlacement;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayComponent;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint;
......@@ -51,7 +49,7 @@ import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocation
import de.tudarmstadt.maki.simonstrator.api.uavsupport.communication.UAVToBaseInterface;
/**
* Topology component used for UAVs.
* Topology component extension prividing a broader topology functionality for UAVs
*
* @author Julian Zobel
* @version 1.0, 06.09.2018
......
......@@ -24,12 +24,17 @@ package de.tud.kom.p2psim.impl.topology.movement.aerial;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
import de.tud.kom.p2psim.api.topology.movement.UAVMovementModel;
import de.tud.kom.p2psim.impl.energy.components.ActuatorComponent;
import de.tud.kom.p2psim.impl.energy.components.StatelessActuatorComponent;
import de.tud.kom.p2psim.impl.topology.component.UAVTopologyComponent;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.util.db.metric.CustomMeasurement;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocationCallback;
......@@ -65,7 +70,7 @@ public class MulticopterMovement implements UAVMovementModel {
private double maximumPitchAngleAllowed; // ° max angle
private double maximumDecentVelocityAllowed; // m/s
// FIXME currently not used
// TODO currently not used
private double maximumTurnAngle; // 90° per second turn angle
......@@ -508,4 +513,62 @@ public class MulticopterMovement implements UAVMovementModel {
UAVDragCoefficient, maximumPitchAngleAllowed, maximumDecentVelocityAllowed, maximumTurnAngle);
}
}
// For evaluation only!
@Entity
@Table(name = "energyModel")
public static class EnergyModelPropertyMeasurement extends CustomMeasurement {
/*
* For DB performance reasons, we only store up to 15 characters of the
* topic (longer topics are truncated)
*/
@Column(nullable = false, name = "[velocity]")
final float velocity;
@Column(nullable = false, name = "[thrust]")
final float thrust;
@Column(nullable = false, name = "[ampere]")
final float ampere;
@Column(nullable = false, name = "[watt]")
final float watt;
@Column(nullable = false, name = "[wattPerMeter]")
final float wattperdistance;
public EnergyModelPropertyMeasurement(double velocity, double thrust, double ampere, double watt) {
/*
* Store all relevant fields
*/
this.velocity = (float) velocity;
this.thrust = (float) thrust;
this.ampere = (float) ampere;
this.watt = (float) watt;
if (velocity == 0) {
this.wattperdistance = -1;
} else
this.wattperdistance = this.watt / this.velocity;
}
public static EnergyModelPropertyMeasurement getPropoertyMeasurement(MulticopterMovement m, double velocity) {
double th = m.estimateRequiredThrust(velocity);
if (th == -1) {
return null;
}
double w = m.estimatePowerConsumptionWatt(velocity);
double amp = w / 14.8;
return new EnergyModelPropertyMeasurement(velocity, th, amp, w);
}
}
}
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