Factory example does not work
See original GitHub issueWhen trying to run FactoryExample.java
the following error appears:
Exception in thread "main" java.lang.IllegalArgumentException: A MovingRoadUser can not be added on an already occupied position (1140.0,90.0).
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:146)
at com.github.rinde.rinsim.core.model.road.CollisionGraphRoadModelImpl.addObjectAt(CollisionGraphRoadModelImpl.java:152)
at com.github.rinde.rinsim.core.model.pdp.PDPObjectImpl.initRoadUser(PDPObjectImpl.java:77)
at com.github.rinde.rinsim.core.model.road.AbstractRoadModel.doRegister(AbstractRoadModel.java:298)
at com.github.rinde.rinsim.core.model.road.GenericRoadModel.register(GenericRoadModel.java:106)
at com.github.rinde.rinsim.core.model.road.GenericRoadModel.register(GenericRoadModel.java:34)
at com.github.rinde.rinsim.core.model.ModelManager.doRegister(ModelManager.java:95)
at com.github.rinde.rinsim.core.model.ModelManager.register(ModelManager.java:115)
at com.github.rinde.rinsim.core.Simulator.register(Simulator.java:110)
at com.github.rinde.rinsim.examples.demo.factory.FactoryExample.run(FactoryExample.java:167)
at com.github.rinde.rinsim.examples.demo.factory.FactoryExample.main(FactoryExample.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
The problem is at this line.
If we change it by
for (int i = 0; i < NUM_VEHICLES; i++) {
final List<Point> l = points.get(rng.nextInt(points.size()));
final Point p = l.get(i);
simulator.register(new AGV(p));
}
it seems to work, but I don’t know if the purpose of this demo is to initialise the AGVs
in certain positions. (Don’t think so, as they are initialised randomly).
Let me know if I have to create a PR to fix this issue.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Solve application issues with the factory pattern
The factory pattern streamlines application issues, like when a developer must reply to users based upon the machine they are using.
Read more >Factory Method Pattern Example in Java troubles
I'm trying to create a really simple Factory Method design pattern example in Java. I don't really know Java, I am new to...
Read more >Factory Method Pattern - the problem and what does it do ...
First, object creation, broadly in the abstract, is not a responsibility; responsibilities should be more domain oriented. Second, your ...
Read more >Understanding Design Patters: Factory Method
The factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to ......
Read more >How to (Not) Create a Factory Function in JavaScript
In this article, we will look at how to create a factory function (aka the Crockford constructor) in JavaScript. Factory functions are an ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have tried in both
4.5.0-SNAPSHOT
and4.4.1
in Mac OS 10.11 with Java 1.8. I’ll try to reproduce the issue in another computer and I’ll keep you updated.Thanks for letting me know!