Commit b038fd09 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

In "VTrajectory", method "duration()" returns an "Optional<Double>" instead of...

In "VTrajectory", method "duration()" returns an "Optional<Double>" instead of "double" (required if trajectory is empty).
parent bedc4daa
Pipeline #114774 canceled with stages
......@@ -68,8 +68,14 @@ public class VTrajectory implements Iterable<FootStep> {
return clone().cut(startSimTime, endSimTime).length();
}
public double duration() {
return footSteps.peekLast().getEndTime() - footSteps.peekFirst().getStartTime();
public Optional<Double> duration() {
if(footSteps.isEmpty()) {
return Optional.empty();
}
else {
double duration = footSteps.peekLast().getEndTime() - footSteps.peekFirst().getStartTime();
return Optional.of(duration);
}
}
public Optional<Double> speed() {
......@@ -77,7 +83,7 @@ public class VTrajectory implements Iterable<FootStep> {
return Optional.empty();
}
else {
return Optional.of(length() / duration());
return Optional.of(length() / duration().get());
}
}
......
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