Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate navmesh\roadmap\guidancefield #140

Open
xiangyuanhang opened this issue Sep 22, 2019 · 7 comments
Open

Generate navmesh\roadmap\guidancefield #140

xiangyuanhang opened this issue Sep 22, 2019 · 7 comments

Comments

@xiangyuanhang
Copy link

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
Copy link
Collaborator

curds01 commented Sep 22, 2019

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
Copy link
Author

Thank you for your answers 👍

@xiangyuanhang
Copy link
Author

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
Copy link
Collaborator

curds01 commented Nov 13, 2019

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

I've now tackled your problem. The solution is in this PR: curds01/MengeUtils#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've got a z-up world and the objToNavMesh assumed a y-up. I've added a flag to specify a z-up.
  • You've got inconsistent winding in your mesh faces. You want to make sure that your vertices are always ordered in a counter-clockwise order when looking "down" at the polygon.

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
Copy link
Collaborator

curds01 commented Nov 13, 2019

Ooops -- the PR has moved to curds01/MengeUtils#6.

@xiangyuanhang
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants