My vehicles will move around randomly when they have nothing to do and look for new jobs, but sometimes, right before they would collide the following exception is raised:
Exception in thread "Thread-0" com.google.common.base.VerifyException: [(14.11111111111111,0.0), (16.0,0.0), -0.36111111111111116]
at com.google.common.base.Verify.verify(Verify.java:462)
at com.github.rinde.rinsim.core.model.road.CollisionGraphRoadModelImpl.computeTravelableDistance(CollisionGraphRoadModelImpl.java:138)
at com.github.rinde.rinsim.core.model.road.GraphRoadModelImpl.doFollowPath(GraphRoadModelImpl.java:178)
at com.github.rinde.rinsim.core.model.road.CollisionGraphRoadModelImpl.doFollowPath(CollisionGraphRoadModelImpl.java:82)
at com.github.rinde.rinsim.core.model.road.AbstractRoadModel.moveTo(AbstractRoadModel.java:133)
at com.github.rinde.rinsim.core.model.road.AbstractRoadModel.moveTo(AbstractRoadModel.java:102)
at project.agents.AgvAgent.movementTick(AgvAgent.java:281)
at project.agents.AgvAgent.tickImpl(AgvAgent.java:213)
at com.github.rinde.rinsim.core.model.pdp.Vehicle.tick(Vehicle.java:55)
at com.github.rinde.rinsim.core.model.time.TimeModel.tickImpl(TimeModel.java:139)
at com.github.rinde.rinsim.core.model.time.SimulatedTimeModel.doStart(SimulatedTimeModel.java:32)
at com.github.rinde.rinsim.core.model.time.TimeModel.start(TimeModel.java:94)
at com.github.rinde.rinsim.ui.SimulationViewer$5.run(SimulationViewer.java:401)
Here is the code for moving to the destination (part of the tickImpl method) and for choosing a new destination and path:
CollisionGraphRoadModelImpl model = (CollisionGraphRoadModelImpl) getRoadModel();
if (!randomDestination.isPresent()) {
nextRandomDestination(model);
}
getRoadModel().moveTo(this, randomDestination.get(), time);
if (model.getPosition(this).equals(randomDestination.get())) {
nextRandomDestination(model);
}
void nextRandomDestination(CollisionGraphRoadModelImpl model) {
randomDestination = Optional.of(model.getRandomPosition(rng));
Point end = randomDestination.get();
Point start = model.getPosition(this);
if (model.getConnection(this).isPresent()) {
start = model.getConnection(this).get().to();
}
randomPath = new LinkedList<>(model.getShortestPathTo(start, end));
}
I tried moving to the point as well as following the path with RoadModel.followPath()
. I also copied some code from AgvAgent
and AgvExample
classes, but even though it works for them it did not work in my case. I did find some comments in GraphRoadModelImpl.doFollowPath()
about some bugs. I'm wondering if there are any workarounds for this? Or is there something obvious I am missing?