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