Commit e5811653 authored by hengwen's avatar hengwen
Browse files

Limit max. simulation duration

parent c2ffea70
......@@ -6,6 +6,7 @@ import org.jgrapht.GraphPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import server.restful.graph.structures.OverlayEdge;
import server.restful.model.Dataframe;
import server.restful.model.VehicleModel;
import server.restful.registry.RemoteAutopilotService;
import server.restful.registry.ServiceRegistry;
......@@ -314,7 +315,9 @@ public class VehicleService {
// if vehicle is driving away from target while it very close to it, consider it has reached its target.
// this avoids the vehicle circling around at the destination without stopping, due to some bug in the simulator.
if (distToTarget < 1) {
List<Dataframe> frames = currentSimulator.getResultByVehicleID(id).getFrames();
Integer maxDuration = Integer.parseInt(Util.getProperties().getProperty("max_simulation_time_ms", "10000"));
if (distToTarget < 1 || (frames != null && frames.size() > 0 && frames.get(frames.size()-1).getTotalTime() > maxDuration)) {
return true;
}
......
......@@ -12,3 +12,6 @@ simulation_step_ms=500
# Set to true if you are developing on windows
windows_dev_mode=false
# define the maximum simulation duration
max_simulation_time_ms=10000
\ No newline at end of file
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