11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

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> { ...@@ -68,8 +68,14 @@ public class VTrajectory implements Iterable<FootStep> {
return clone().cut(startSimTime, endSimTime).length(); return clone().cut(startSimTime, endSimTime).length();
} }
public double duration() { public Optional<Double> duration() {
return footSteps.peekLast().getEndTime() - footSteps.peekFirst().getStartTime(); if(footSteps.isEmpty()) {
return Optional.empty();
}
else {
double duration = footSteps.peekLast().getEndTime() - footSteps.peekFirst().getStartTime();
return Optional.of(duration);
}
} }
public Optional<Double> speed() { public Optional<Double> speed() {
...@@ -77,7 +83,7 @@ public class VTrajectory implements Iterable<FootStep> { ...@@ -77,7 +83,7 @@ public class VTrajectory implements Iterable<FootStep> {
return Optional.empty(); return Optional.empty();
} }
else { 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