MengeCrowdSim / Menge

The source code for the Menge crowd simulation framework
Apache License 2.0
138 stars 64 forks source link

Generate navmesh\roadmap\guidancefield #140

Open xiangyuanhang opened 4 years ago

xiangyuanhang commented 4 years ago

Hi! I have read the documentation and read the relative issues, but still confused how to generate navmesh file or guidancefiled. For roadmap, I know that we can draw by hand using the Python utilitiy provided.

  1. From this comment, I realized that the navigation mesh should be drawn by hand in a 3D modeling tool and then be translated to .nav file using the objToNavMesh.py, correct me if I'm wrong :(. If this is the case, could you please recommend me a good 3D modeling tool to use to draw a navigation mesh, Blender?

  2. How can we generate a guidancefield? I notice that there is a file named fieldM.txt. what's the workflow to generate such file?

  3. For roadmap, we can generate it using the Python tool roapmapBuilder.py, is there any other option?

Thank you so much.

curds01 commented 4 years ago

Answers to your question:

  1. Yep. I use blender and/or maya for that purpose. Just create some continguous mesh that represents the traversable space and objToNavMesh will convert it. It's a bit fragile and doesn't do a good job of error reporting if it finds a problem with your nav mesh. I may upgrade that program to be a blender plug in to help facilitate creating navigation meshes.

  2. roadmapBuilder.py has a context that allows for the creation and editing of fields. Right now there's no automatic method (just like with navigation meshes and road maps). But you can create a field, specify its resolution, align it with your simulation domain and then paint the guidance field.

  3. roadmapBuilder.py is currently the only path I use for creating roadmaps. One of these days I'll implement one of the algorithms that does it automatically.

Sorry, this is all by hand. :-/

xiangyuanhang commented 4 years ago

Thank you for your answers 👍

xiangyuanhang commented 4 years ago

Hi, I'm trying to use objToNavMesh to convert my .obj file. I test this code on a simple .obj file as following: v 0 0 0 v 2 0 0 v 2 3 0 v 4 3 0 v 4 0 0 v 6 3 0 f 1 2 3 f 2 3 4 f 2 4 5 f 4 5 6 However, objToNavMesh.py still reports error numpy.linalg.LinAlgError: Singular matrix. Could you please give me some instructions on how to build the mesh(is there any specific requirements for this mesh?) that is suitable for objToNavMesh.py? Thank you so much.

curds01 commented 4 years ago

Sorry for the slow delay. I was on vacation with my family.

I've now tackled your problem. The solution is in this PR: https://github.com/curds01/MengeUtils/pull/5. Essentially, it's doing more analysis on the input file and tries to give helpful feedback on the properties of the input mesh that are causing problems.

In the case of your file:

You can try exercising the PR directly. Or you can wait a bit and I'll merge it into master. I like taking a bit of time between "fixing" a problem and merging the solution so I can look at it with fresh eyes. Alternatively, if you'd like to look at it and review it for me, that'd be great too.

curds01 commented 4 years ago

Ooops -- the PR has moved to https://github.com/curds01/MengeUtils/pull/6.

xiangyuanhang commented 4 years ago

Thanks you so much! In fact, I have also assumed that it could be the problem of coordinate system.

Besides, I am also trying to use roadmapBuilder.py to generate guidance field. I used these two files as input: 1.feildM.txt, which is the original field file for the scene globalNavSwap. 2.global.xml, which is the original obstacle file for the scene globalNavSwap. (This can be successfully loaded alone)

However, it seems that the roadmapBuilder.py cannot correctly parse the fieldM.txt. And it reports the following errors:

File "roadmapBuilder.py", line 340, in main field = GLVectorField( (0,0), (1, 1), 1 ) File "D:\menge\Menge2017\mengeutils-master-new-new\MengeUtils-master\vField.py", line 299, in init VectorField.init( self, minPoint, size, cellSize ) File "D:\menge\Menge2017\mengeutils-master-new-new\MengeUtils-master\vField.py", line 28, in init self.setDimensions( size ) File "D:\menge\Menge2017\mengeutils-master-new-new\MengeUtils-master\vField.py", line 87, in setDimensions self.gridChanged() File "D:\menge\Menge2017\mengeutils-master-new-new\MengeUtils-master\vField.py", line 313, in gridChanged self.genArrowDL() File "D:\menge\Menge2017\mengeutils-master-new-new\MengeUtils-master\vField.py", line 328, in genArrowDL self.arrowID = glGenLists(1) File "D:\menge\Menge2017\mengeutils-master-new-new\MengeUtils-master\venv\lib\site-packages\OpenGL\platform\baseplatform.py", line 402, in call return self( *args, **named ) File "D:\menge\Menge2017\mengeutils-master-new-new\MengeUtils-master\venv\lib\site-packages\OpenGL\error.py", line 232, in glCheckError baseOperation = baseOperation, OpenGL.error.GLError: GLError( err = 1282, description = '\xce\xde\xd0\xa7\xb2\xd9\xd7\xf7', baseOperation = glGenLists, cArguments = (1,), result = 0L )

Could this be the problem of the version of PyOpenGL package? :/

xiangyuanhang commented 4 years ago

oh, the function VectorField.gridChanged() has been override. The problem solved after commenting the second declaration of this function.