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