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

Simple Movement now correctly takes the target speed as input

parent 68fb363a
...@@ -20,16 +20,11 @@ ...@@ -20,16 +20,11 @@
package de.tud.kom.p2psim.impl.topology.movement.aerial; package de.tud.kom.p2psim.impl.topology.movement.aerial;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import javax.persistence.criteria.CriteriaBuilder.In;
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
import org.joda.time.tz.ZoneInfoProvider;
import de.tud.kom.p2psim.api.topology.movement.UAVMovementModel; import de.tud.kom.p2psim.api.topology.movement.UAVMovementModel;
import de.tud.kom.p2psim.impl.energy.components.StatelessMotorComponent; import de.tud.kom.p2psim.impl.energy.components.StatelessMotorComponent;
import de.tud.kom.p2psim.impl.topology.component.UAVTopologyComponent; import de.tud.kom.p2psim.impl.topology.component.UAVTopologyComponent;
...@@ -51,7 +46,7 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -51,7 +46,7 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
private double currentAngleOfAttack; private double currentAngleOfAttack;
private double currentSpeed; private double currentSpeed;
private double targetedSpeed; private double targetSpeed;
private LinkedList<PositionVector> route = new LinkedList<>(); private LinkedList<PositionVector> route = new LinkedList<>();
private Map<PositionVector, ReachedLocationCallback> locationCallbacks = new LinkedHashMap<>(); // TODO callback interface private Map<PositionVector, ReachedLocationCallback> locationCallbacks = new LinkedHashMap<>(); // TODO callback interface
...@@ -146,9 +141,9 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -146,9 +141,9 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
else { else {
// get to speed // get to speed
if(targetedSpeed > 0 && targetedSpeed < horizontalMaxVelocity()) { if(targetSpeed > 0 && targetSpeed < horizontalMaxVelocity()) {
motor.requestThrust(estimateRequiredThrust(targetedSpeed)); motor.requestThrust(estimateRequiredThrust(targetSpeed));
currentSpeed = targetedSpeed; currentSpeed = targetSpeed;
} }
else { else {
motor.requestThrust(horizontalMaxVelocityRequiredTotalThrust()); motor.requestThrust(horizontalMaxVelocityRequiredTotalThrust());
...@@ -182,8 +177,15 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -182,8 +177,15 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
else { else {
double timefactor = timeBetweenMovementOperations / Time.SECOND; double timefactor = timeBetweenMovementOperations / Time.SECOND;
motor.requestThrust(horizontalMaxVelocityRequiredTotalThrust()); // get to speed
currentSpeed = horizontalMaxVelocity(); if(targetSpeed > 0 && targetSpeed < horizontalMaxVelocity()) {
motor.requestThrust(estimateRequiredThrust(targetSpeed));
currentSpeed = targetSpeed;
}
else {
motor.requestThrust(horizontalMaxVelocityRequiredTotalThrust());
currentSpeed = horizontalMaxVelocity();
}
PositionVector directionToTarget = new PositionVector(target); PositionVector directionToTarget = new PositionVector(target);
directionToTarget.subtract(position); directionToTarget.subtract(position);
...@@ -301,7 +303,7 @@ public class SimpleMulticopterMovement implements UAVMovementModel { ...@@ -301,7 +303,7 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
@Override @Override
public void setPreferredSpeed(double v_pref) { public void setPreferredSpeed(double v_pref) {
this.targetedSpeed = v_pref; this.targetSpeed = v_pref;
} }
@Override @Override
......
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