Commit 12e538a4 authored by Julian Zobel's avatar Julian Zobel 🦄
Browse files

Adapted a hover and fly state for fixed wing Uavs

parent aed6fe63
...@@ -43,7 +43,7 @@ public class StatefulActuatorComponent implements ActuatorComponent { ...@@ -43,7 +43,7 @@ public class StatefulActuatorComponent implements ActuatorComponent {
* *
* TODO More states reflecting a more accurate energy consumption? * TODO More states reflecting a more accurate energy consumption?
*/ */
public final EnergyState OFF, FLY, MAX; public final EnergyState OFF, HOVER, MIN, MAX;
private EnergyState currentState; private EnergyState currentState;
...@@ -53,9 +53,10 @@ public class StatefulActuatorComponent implements ActuatorComponent { ...@@ -53,9 +53,10 @@ public class StatefulActuatorComponent implements ActuatorComponent {
private double actuatorLoad; private double actuatorLoad;
public StatefulActuatorComponent(int numberOfActuators, double volt, double hoverAmp, double maxAmp) { public StatefulActuatorComponent(int numberOfActuators, double volt, double hoverAmp, double minAmp, double maxAmp) {
OFF = new DefaultEnergyState("OFF", 0); OFF = new DefaultEnergyState("OFF", 0);
FLY = new DefaultEnergyState("FLY", numberOfActuators * (hoverAmp * volt) * Battery.uJconverison); HOVER = new DefaultEnergyState("HOVER", numberOfActuators * (hoverAmp * volt) * Battery.uJconverison);
MIN = new DefaultEnergyState("MIN", numberOfActuators * (minAmp * volt) * Battery.uJconverison);
MAX = new DefaultEnergyState("MAX", numberOfActuators * (maxAmp * volt) * Battery.uJconverison); MAX = new DefaultEnergyState("MAX", numberOfActuators * (maxAmp * volt) * Battery.uJconverison);
this.currentState = OFF; this.currentState = OFF;
...@@ -74,9 +75,16 @@ public class StatefulActuatorComponent implements ActuatorComponent { ...@@ -74,9 +75,16 @@ public class StatefulActuatorComponent implements ActuatorComponent {
@Override @Override
public double calculateEnergyConsumation(EnergyState state, long timeInState) { public double calculateEnergyConsumation(EnergyState state, long timeInState) {
if(state.equals(FLY)) { if(state.equals(HOVER)) {
double consumationDelta = MAX.getEnergyConsumption() - FLY.getEnergyConsumption(); return HOVER.getEnergyConsumption() * ( (double) timeInState / (double) Time.SECOND);
double consumation = FLY.getEnergyConsumption() + consumationDelta * actuatorLoad; }
else if(state.equals(MIN)) {
double consumationDelta = MAX.getEnergyConsumption() - MIN.getEnergyConsumption();
double consumation = MIN.getEnergyConsumption() + consumationDelta * actuatorLoad;
return consumation * ( (double) timeInState / (double) Time.SECOND);
}
else if(state.equals(MAX)) {
double consumation = 0.5 * MAX.getEnergyConsumption() + MAX.getEnergyConsumption() * actuatorLoad;
return consumation * ( (double) timeInState / (double) Time.SECOND); return consumation * ( (double) timeInState / (double) Time.SECOND);
} }
else else
...@@ -84,12 +92,20 @@ public class StatefulActuatorComponent implements ActuatorComponent { ...@@ -84,12 +92,20 @@ public class StatefulActuatorComponent implements ActuatorComponent {
} }
public void useActuator(double load) { public void useActuator(double load) {
if(load < 0 || load > 1.0) { if(load < 0) {
throw new AssertionError("Actuator load must be between 0 and 1!"); throw new AssertionError("Actuator load cannot be < 0.0!");
} }
else { else {
this.actuatorLoad = load; this.actuatorLoad = load;
doStateChange(FLY); if(load == 0) {
doStateChange(HOVER);
}
else if(load <= 1.0) {
doStateChange(MIN);
}
else if(load > 1.0) {
doStateChange(MAX);
}
} }
} }
...@@ -99,8 +115,20 @@ public class StatefulActuatorComponent implements ActuatorComponent { ...@@ -99,8 +115,20 @@ public class StatefulActuatorComponent implements ActuatorComponent {
* @return Energy consumption in J/s * @return Energy consumption in J/s
*/ */
public double estimateEnergyConsumptionWatt(double load) { public double estimateEnergyConsumptionWatt(double load) {
double consumationDelta = MAX.getEnergyConsumption() - FLY.getEnergyConsumption();
double estimation = FLY.getEnergyConsumption() + consumationDelta * load; double estimation = -1;
if(load == 0) {
estimation = HOVER.getEnergyConsumption();
}
else if(load <= 1.0) {
double consumationDelta = MAX.getEnergyConsumption() - MIN.getEnergyConsumption();
estimation = MIN.getEnergyConsumption() + consumationDelta * load;
}
else if(load > 1.0) {
estimation = 0.5 * MAX.getEnergyConsumption() + MAX.getEnergyConsumption() * load;
}
// System.out.println("MAX " + ((MAX.getEnergyConsumption() / 14.8) / Battery.uJconverison)); // System.out.println("MAX " + ((MAX.getEnergyConsumption() / 14.8) / Battery.uJconverison));
// System.out.println("MIN" + ((FLY.getEnergyConsumption() / 14.8) / Battery.uJconverison)); // System.out.println("MIN" + ((FLY.getEnergyConsumption() / 14.8) / Battery.uJconverison));
...@@ -129,7 +157,7 @@ public class StatefulActuatorComponent implements ActuatorComponent { ...@@ -129,7 +157,7 @@ public class StatefulActuatorComponent implements ActuatorComponent {
public boolean turnOn() { public boolean turnOn() {
if (isAvailable()) { if (isAvailable()) {
if (currentState.equals(OFF)) { if (currentState.equals(OFF)) {
doStateChange(FLY); doStateChange(MIN);
} }
return true; return true;
} }
......
...@@ -35,11 +35,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef ...@@ -35,11 +35,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
private int numberOfActuators; private int numberOfActuators;
private double volt; private double volt;
private double hoverAmp; // in ampere private double hoverAmp; // in ampere
private double flyAmp; // in ampere private double minAmp; // in ampere
private double maxAmp; // in ampere
@Override @Override
public StatefulActuatorComponent getConfiguredEnergyComponent(SimHost host) { public StatefulActuatorComponent getConfiguredEnergyComponent(SimHost host) {
return new StatefulActuatorComponent(numberOfActuators, volt, hoverAmp, flyAmp); return new StatefulActuatorComponent(numberOfActuators, volt, hoverAmp, minAmp, maxAmp);
} }
@Override @Override
...@@ -50,7 +51,7 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef ...@@ -50,7 +51,7 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
@Override @Override
public boolean isWellConfigured() { public boolean isWellConfigured() {
if(numberOfActuators >= 1 && volt > 0 if(numberOfActuators >= 1 && volt > 0
&& hoverAmp > 0 && flyAmp > 0) && hoverAmp > 0 && minAmp > 0 && maxAmp > 0)
return true; return true;
return false; return false;
...@@ -64,8 +65,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef ...@@ -64,8 +65,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
this.hoverAmp = ampereHovering; this.hoverAmp = ampereHovering;
} }
public void setFlyAmp(double ampereFlying) { public void setMinAmp(double minamp) {
this.flyAmp = ampereFlying; this.minAmp = minamp;
}
public void setMaxAmp(double maxamp) {
this.maxAmp = maxamp;
} }
public void setVolt(double voltage) { public void setVolt(double voltage) {
......
...@@ -108,6 +108,14 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S ...@@ -108,6 +108,14 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
// retrieve base location // retrieve base location
baseLocation = UAVBasePlacement.base.position.clone(); baseLocation = UAVBasePlacement.base.position.clone();
System.out.println("optimal velocity: " + getOptimalMovementSpeed());
System.out.println("flight distance @opt: " + estimateFlightDistance(getOptimalMovementSpeed(), 1, 0));
System.out.println("flight distance @5m/s: " + estimateFlightDistance(5.0, 1, 0));
System.out.println("flight distance @"+getMaxMovementSpeed()+"m/s: " + estimateFlightDistance(getMaxMovementSpeed(), 1, 0));
System.out.println("Hover time: " + (((battery.getMaximumEnergy()) / Battery.uJconverison) / estimatePowerConsumptionWatt(0)) / 60);
System.out.println();
} }
private void setState(UAVstate newState) { private void setState(UAVstate newState) {
......
...@@ -86,7 +86,7 @@ public class MulticopterMovement implements UAVMovementModel { ...@@ -86,7 +86,7 @@ public class MulticopterMovement implements UAVMovementModel {
this.dragCoefficient = UAVDragCoefficient; this.dragCoefficient = UAVDragCoefficient;
this.maximumPitchAngleAllowed = maximumPitchAngleAllowed; this.maximumPitchAngleAllowed = maximumPitchAngleAllowed;
this.maximumDecentVelocityAllowed = maximumDecentVelocityAllowed; this.maximumDecentVelocityAllowed = maximumDecentVelocityAllowed;
this.maximumTurnAngle = maximumTurnAngle; this.maximumTurnAngle = maximumTurnAngle;
} }
boolean first = true; boolean first = true;
......
...@@ -53,15 +53,18 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -53,15 +53,18 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
private double minimumHorizontalVelocity; private double minimumHorizontalVelocity;
private double minimumVerticalVelocity; private double minimumVerticalVelocity;
private double optimalHorizontalVelocity;
private LinkedList<PositionVector> route = new LinkedList<>(); private LinkedList<PositionVector> route = new LinkedList<>();
private Map<PositionVector, ReachedLocationCallback> locationCallbacks = new LinkedHashMap<>(); private Map<PositionVector, ReachedLocationCallback> locationCallbacks = new LinkedHashMap<>();
private StatefulActuatorComponent motor; private StatefulActuatorComponent motor;
public SimpleMulticopterMovement(UAVTopologyComponent topologyComponent, double maximumHorizontalVelocity, public SimpleMulticopterMovement(UAVTopologyComponent topologyComponent, double maximumHorizontalVelocity, double optimalHorizontalVelocity,
double maximumVerticalVelocity, double minimumHorizontalVelocity, double minimumVerticalVelocity) { double maximumVerticalVelocity, double minimumHorizontalVelocity, double minimumVerticalVelocity) {
this.topologyComponent = topologyComponent; this.topologyComponent = topologyComponent;
this.maximumHorizontalVelocity = maximumHorizontalVelocity; this.maximumHorizontalVelocity = maximumHorizontalVelocity;
this.optimalHorizontalVelocity = optimalHorizontalVelocity;
this.maximumVerticalVelocity = maximumVerticalVelocity; this.maximumVerticalVelocity = maximumVerticalVelocity;
this.minimumHorizontalVelocity = minimumHorizontalVelocity; this.minimumHorizontalVelocity = minimumHorizontalVelocity;
this.minimumVerticalVelocity = minimumVerticalVelocity; this.minimumVerticalVelocity = minimumVerticalVelocity;
...@@ -101,7 +104,14 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -101,7 +104,14 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
PositionVector newPosition = new PositionVector(currentPosition); PositionVector newPosition = new PositionVector(currentPosition);
newPosition.add(direction); newPosition.add(direction);
motor.useActuator(1); if(velocity <= optimalHorizontalVelocity) {
motor.useActuator(1.0);
}
else {
motor.useActuator(2.0);
}
topologyComponent.updateCurrentLocation(newPosition); topologyComponent.updateCurrentLocation(newPosition);
} }
else if(motor.isOn()) { else if(motor.isOn()) {
...@@ -194,8 +204,11 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -194,8 +204,11 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
if(velocity == 0) { if(velocity == 0) {
wattage = motor.estimateEnergyConsumptionWatt(0); wattage = motor.estimateEnergyConsumptionWatt(0);
} }
else { else if( velocity <= optimalHorizontalVelocity){
wattage = motor.estimateEnergyConsumptionWatt(1.0); wattage = motor.estimateEnergyConsumptionWatt(1);
}
else {
wattage = motor.estimateEnergyConsumptionWatt(2);
} }
return wattage; return wattage;
...@@ -234,6 +247,12 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -234,6 +247,12 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
public void setMaximumHorizontalVelocity(double maximumHorizontalVelocity) { public void setMaximumHorizontalVelocity(double maximumHorizontalVelocity) {
this.maximumHorizontalVelocity = maximumHorizontalVelocity; this.maximumHorizontalVelocity = maximumHorizontalVelocity;
} }
private double optimalHorizontalVelocity = 10;
public void setOptimalHorizontalVelocity(double optimalHorizontalVelocity) {
this.optimalHorizontalVelocity = optimalHorizontalVelocity;
}
private double maximumVerticalVelocity = 5; private double maximumVerticalVelocity = 5;
...@@ -254,13 +273,13 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -254,13 +273,13 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
} }
public UAVMovementModel createComponent(UAVTopologyComponent topologyComponent) { public UAVMovementModel createComponent(UAVTopologyComponent topologyComponent) {
return new SimpleMulticopterMovement(topologyComponent, maximumHorizontalVelocity, return new SimpleMulticopterMovement(topologyComponent, maximumHorizontalVelocity, optimalHorizontalVelocity,
maximumVerticalVelocity, minimumHorizontalVelocity, minimumVerticalVelocity); maximumVerticalVelocity, minimumHorizontalVelocity, minimumVerticalVelocity);
} }
} }
@Override @Override
public double estimateOptimalSpeed() { public double estimateOptimalSpeed() {
return maximumHorizontalVelocity; return optimalHorizontalVelocity;
} }
} }
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