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

Adaptions on movement and energy model

parent f92bfcd0
......@@ -76,7 +76,7 @@ public class StatelessMotorComponent implements EnergyComponent {
* @return
*/
public double getMaxThrust() {
return characteristics.getLast().getThrust();
return characteristics.getLast().getThrust() * numberOfActuators;
}
/**
......@@ -115,10 +115,10 @@ public class StatelessMotorComponent implements EnergyComponent {
*/
public double requestThrust(double targetThrust) {
if(targetThrust == 0 || targetThrust <= characteristics.getFirst().getThrust()) {
if(targetThrust == 0 || targetThrust <= numberOfActuators * characteristics.getFirst().getThrust()) {
setLoad(characteristics.getFirst());
}
else if(targetThrust >= characteristics.getLast().getThrust()) {
else if(targetThrust >= numberOfActuators * characteristics.getLast().getThrust()) {
setLoad(characteristics.getLast());
}
else {
......@@ -134,11 +134,11 @@ public class StatelessMotorComponent implements EnergyComponent {
* @return The power consumption for the target thrust in uW (micro watt)
*/
public double estimatePowerConsumptionWatt(double targetThrust) {
if(targetThrust == 0 || targetThrust <= characteristics.getFirst().getThrust()) {
if(targetThrust == 0 || targetThrust <= numberOfActuators * characteristics.getFirst().getThrust()) {
// not allowed
return Double.NaN;
}
else if(targetThrust > characteristics.getLast().getThrust()) {
else if(targetThrust > numberOfActuators * characteristics.getLast().getThrust()) {
// not allowed
return Double.NaN;
}
......@@ -165,16 +165,16 @@ public class StatelessMotorComponent implements EnergyComponent {
// find the lower and upper bounding characteristics
for (MotorCharacteristic ch : characteristics) {
//
if(ch.getThrust() == targetThrust) {
if(ch.getThrust() * numberOfActuators == targetThrust) {
return ch.getCurrent();
}
else {
// list is sorted, lower bound is the biggest that is lower
if(ch.getThrust() < targetThrust) {
if(ch.getThrust() * numberOfActuators < targetThrust) {
lower = ch;
}
// the first that is greater is used as upper bound
else if(ch.getThrust() > targetThrust) {
else if(ch.getThrust() * numberOfActuators > targetThrust) {
upper = ch;
break;
}
......@@ -185,7 +185,7 @@ public class StatelessMotorComponent implements EnergyComponent {
throw new UnsupportedOperationException("Lower or upper bounds cannot be null");
}
if(upper.getThrust() < targetThrust || lower.getThrust() > targetThrust) {
if(upper.getThrust() * numberOfActuators < targetThrust || lower.getThrust() * numberOfActuators > targetThrust) {
throw new UnsupportedOperationException("Lower or upper bound do not match");
}
......@@ -193,7 +193,7 @@ public class StatelessMotorComponent implements EnergyComponent {
* Calculate the approximated current with the upper and lower bounds:
* Amp_approx = Amp_lower + (T_target - T_lower)/(T_upper - T_lower) * (Amp_upper - Amp_lower)
*/
double delta = (targetThrust - lower.getThrust())/(upper.getThrust() - lower.getThrust());
double delta = (targetThrust - (lower.getThrust() * numberOfActuators))/(numberOfActuators * (upper.getThrust() - lower.getThrust()));
return lower.getCurrent() + delta * (upper.getCurrent() - lower.getCurrent());
}
......
......@@ -25,6 +25,8 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
import de.tud.kom.p2psim.api.energy.Battery;
import de.tud.kom.p2psim.api.topology.movement.UAVMovementModel;
import de.tud.kom.p2psim.impl.energy.components.StatelessMotorComponent;
import de.tud.kom.p2psim.impl.topology.component.UAVTopologyComponent;
......@@ -54,12 +56,12 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
private StatelessMotorComponent motor;
private double mass = 1.465; // kg
private final double airdensity = 1.2255; // kg/m^3
private final double airdensity = 1.2045; // kg/m^3
private final double gravity = 9.807; // m/s^2
private double A_top = 0.245; // m^2
private double A_front = 0.04; // m^2
private double dragCoefficient = 0.5;
private double maxPitchAngle = Math.toRadians(45); // 45° max angle
private double A_front = 0.1; // m^2
private double dragCoefficient = 0.7;
private double maxPitchAngle = Math.toRadians(60); // 45° max angle
private double descentVelocityMax = 5; // m/s
private double maxTurnAngle = Math.toRadians(90); // 90° per second turn angle
......@@ -70,10 +72,30 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
}
boolean first = true;
@Override
public void move(long timeBetweenMovementOperations) {
if(first) {
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());
......@@ -228,7 +250,7 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
Vector2D v = new Vector2D(Math.abs(direction.getX()) + Math.abs(direction.getY()), Math.abs(direction.getZ()));
v = v.normalize();
double areaExposedFront = v.getX() * (Math.sin(angleRadians) * A_top + Math.cos(angleRadians) * A_front);
double areaExposedFront = v.getX() * (Math.sin(angleRadians) * A_top + Math.cos(angleRadians) * A_front );
double areaExposedTop = v.getY() * (Math.cos(angleRadians) * A_top + Math.sin(angleRadians) * A_front);
return areaExposedFront + areaExposedTop;
......
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