basic-simulator issueshttps://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues2021-10-20T17:45:03+02:00https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues/6Please add Issues for the basic-simulator in the simulation project (with the...2021-10-20T17:45:03+02:00Jean MeuricePlease add Issues for the basic-simulator in the simulation project (with the 'basic-simulator' label) for better overviewhttps://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues/5OpenGL visualization2021-10-20T17:38:42+02:00Jean MeuriceOpenGL visualization## Problem
- Right now, the 2D visualization of the maps and vehicles uses the `Graphics2D` java class inside the `Swing` components.
- This is not a very efficient rendering method, especially for large scale cities.
- It is also not p...## Problem
- Right now, the 2D visualization of the maps and vehicles uses the `Graphics2D` java class inside the `Swing` components.
- This is not a very efficient rendering method, especially for large scale cities.
- It is also not precise: the polygon geometry can only be passed with integer pixel positions.
## Solution
Use OpenGL rendering.
- As OpenGL library (for example): [JOGL](https://jogamp.org/jogl/www/)
- [JOGL in Swing](https://www.tutorialspoint.com/jogl/jogl_canvas_with_swing.htm) (Still up-to-date ?)
- [OpenGL 4 JOGL sample](https://github.com/jvm-graphics-labs/hello-triangle)
- TODOs:
- Test a simple 2D triangle with a basic shader.
- Make it build and run using the JOGL maven artifacts.
- Make a *colored triangle* shader with an orthogonal view matrix, test binding it to the map controls (position, zoom). Render a simple triangle (or 2)
- Make a *colored line* shader, same view matrix, test a simple outline.
- Generate the building geometry in one VBO/VAO/EBO set.
- Use the already split convex parts
- The *convex* polygon parts can be rendered using the `GL_TRIANGLE_FAN` drawing mode
- In combination with the [Primitive Restart](https://stackoverflow.com/questions/4386861/opengl-jogl-multiple-triangle-fans-in-a-vertex-array)
- Use an Element-Buffer
- Use the `PRIMITIVE_RESTART` index to separate triangle fans for different polygons
- Since we only want to draw contiguous vertices, the `glMultiDrawElements()` method can be useful
- Generate the road geometry (or visualization lines)
- Generate the vehicle geometry (one VBO/EBO/VAO set)
- Same triangle shader, but give it a view+model matrix (pre-multiplied)
- All the debug lines/elements (AABB, building outlines, ...) can be in their own VBO/EBO/VAO.
- **Check the thread interaction between Swing and OpenGL**. The OpenGL calls are not thread-safe for a given context. Be sure that the OpenGL calls happen in the correct thread.
- [Swing Threads](http://www.javapractices.com/topic/TopicAction.do?Id=153)
**Note**: The existing visualization already "pre-generates" the geometry in some way to save computation. Changing to save this geometry in OpenGL buffer would not be a big change.https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues/4Time-control bugs2021-10-20T17:39:36+02:00Jean MeuriceTime-control bugs## Problem
The time-control of the visualization does not seem to be correct.
For example, with the "simulation-speed" set to low values (1/4, 1/8, ...) the control loop can stop advancing the simulation.
Generally, the visualization ...## Problem
The time-control of the visualization does not seem to be correct.
For example, with the "simulation-speed" set to low values (1/4, 1/8, ...) the control loop can stop advancing the simulation.
Generally, the visualization does not handle the rendering time well in order to prioritize the simulation speed.
## Fixes
A correct time-control loop should adapt the FPS to keep-up the desired simulation speed up to a certain minimum FPS limit.
Right now, the updates are handled in a java `Timer` callback. This is used in order to be in the GUI thread. However this makes the control loop logic hard. Ideally, the control logic should be as presented [here](https://gafferongames.com/post/fix_your_timestep/) (with fixed time-steps).
**If the [Async Simulation and Visualization](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues/3) are implemented again**, the visualization control loop would be completely different since the simulation would not have to be updated in parallel.https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues/3Async Simulation and Visualization + Data-Export system2021-10-20T17:40:34+02:00Jean MeuriceAsync Simulation and Visualization + Data-Export systemIdea: Run the simulations in another thread.
Advantages:
- Some performance improvement since one thread can run the simulation full speed, the other render the visualization.
- (Re-)develop the simulation data exporting. The relevant s...Idea: Run the simulations in another thread.
Advantages:
- Some performance improvement since one thread can run the simulation full speed, the other render the visualization.
- (Re-)develop the simulation data exporting. The relevant simulation data-points are saved per frame (can be a different rate then the simulation rate). The simulation "client" would register which data-points should be exported (to save bandwidth).
- The basic-sim can store the frames for a simulation. This allows to watch a simulation as it is simulated, but also to watch back/navigate the simulation using a timeline.
- This simplifies the time control logic between visualization and simulation.
- The data-export system can also directly be used to save simulation results.
- The data-export system could also be used to watch simulations remotely (would update the *visualization* project)
- A solid data-export system would make exporting any data (also inspection data for plotting, ...) cleaner and more generic.https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues/2Feature Request: Scenario folders2021-10-20T17:57:37+02:00TamfaetFeature Request: Scenario foldersIt would be really convenient to provide a path to other scenario files. Thus project files can be contained in their corresponding projects and no need for copy-pasting would be needed.It would be really convenient to provide a path to other scenario files. Thus project files can be contained in their corresponding projects and no need for copy-pasting would be needed.https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/basic-simulator/-/issues/1Laggy simulation2021-10-20T17:46:55+02:00TamfaetLaggy simulationIt seems, that the simulator needs to wait internally for things. When I run it, my CPU utilization is at maximum at 15 %. Still the Simulator is not able to reach 30 FPS.
Maybe some parallelization could help there.It seems, that the simulator needs to wait internally for things. When I run it, my CPU utilization is at maximum at 15 %. Still the Simulator is not able to reach 30 FPS.
Maybe some parallelization could help there.