AI Libraries for Panda3D

Return to Panda Features in Development

Postby peerpanda » Wed Jan 27, 2010 5:23 pm

I did everything again and uploaded every file and source code. Hope this can help you and me much more.

First I created plane with 3x3 faces in Blender 2.49b:
http://sin3.de/pandai/mesh3x3.blend

and exported it with Chicken R85:
http://sin3.de/pandai/mesh.egg

Then I removed the face in the center:
http://sin3.de/pandai/mesh3x3_missing_center.blend

and again created egg-file:
http://sin3.de/pandai/col_mesh.egg

After that I converted the egg-files
Code: Select all
D:\Programme\Panda3D-1.6.2\bin\egg-trans -C -o mesh1.egg mesh.egg
D:\Programme\Panda3D-1.6.2\bin\egg-trans -C -o col_mesh1.egg col_mesh.egg
to http://sin3.de/pandai/mesh1.egg and http://sin3.de/pandai/col_mesh1.egg

Finally I created the csv-file
Code: Select all
meshgen mesh1.egg col_mesh1.egg

and I got http://sin3.de/pandai/navmesh.csv

I ran the programm again with this files and again the same behavior. If you want to have a look on the code: http://sin3.de/pandai/pathfinding_demo.zip
Not really nice coding but should work.

I really hope you can find the mistake and I hope that I made it.

If you need more information or i have missed to upload a part of the code or something else, please let me know!
peerpanda
 
Posts: 16
Joined: Tue Jan 26, 2010 2:38 pm

Postby NNair » Wed Jan 27, 2010 5:49 pm

This is good info!...Will check it out and get back to you.
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby treeform » Wed Jan 27, 2010 7:29 pm

Would there be a way to generate a navmesh from a collision scene?
User avatar
treeform
 
Posts: 2106
Joined: Sat May 05, 2007 5:15 pm
Location: SF, CA

Postby NNair » Wed Jan 27, 2010 7:41 pm

Do u mean a scene created in Panda with collision boxes and so on?
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby treeform » Wed Jan 27, 2010 7:47 pm

Yes and level based collisions.

But reading more about navmeshes ( http://www.ai-blog.net/archives/000152.htm ) I think its probably better to draw them by hand.

Then i came up with a second question: would be able to convert a navmesh drawn in blender to your csv representation?
User avatar
treeform
 
Posts: 2106
Joined: Sat May 05, 2007 5:15 pm
Location: SF, CA

Postby NNair » Wed Jan 27, 2010 11:31 pm

It is easier to implement it by drawing by hand and it isn't too much work for the artist too I feel. This is why we chose this direction.

We create a plane with subdivisions as a grid in max, maya or blender and export it as an egg from which we generate a navigation mesh and create nodes for path finding.

The more dynamic creation of path finding is something we looked into earlier on but was out of scope then. We also looked into Recast and Detour but that was in its research phase and was hard to integrate into Panda for our project.
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby JohnKol » Thu Jan 28, 2010 12:38 am

Thanks for that detailed info peerpanda. It really helped. So we have narrowed down the problem and it is being caused due to Blender. By taking a closer look at the .csv file we found out that the row and col indices are not matched against the node positions, and this is why you were getting the weird behavior with pathfinding.

We had tested our pathfinding with eggs generated from blender previously and it had worked fine. However, when we create the .csv file using egg files that you provided, the data is getting corrupted. I am not sure what may be causing this. It might be an issue with how our mesh generation tool works and the way Blender stores its vertex data. We are currently testing more with Blender to see what the problem could be and provide a solution. Meanwhile, if you have access to Max or Maya, the pathfinding should just work fine.

Thanks for your patience!
John Kolencheryl

Project PandAI
Entertainment Technology Center
Carnegie Mellon
JohnKol
 
Posts: 35
Joined: Thu Aug 27, 2009 3:40 pm
Location: ETC, Carnegie Mellon University

Postby NNair » Thu Jan 28, 2010 2:23 am

To add to this, we think that Blender exports the vertices for a similar scene (in Max or Maya) in a different order (of vertices and quads). This will cause our mesh generator code to not create the mesh (navmesh.csv) correctly and hence the faulty pathfinding.

We did not test extensively with Blender as we were using Max and Maya at that time and so I guess will have to look into this a little more. Might even have to add a separate extension of the Mesh Gen for Blender.
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby peerpanda » Fri Jan 29, 2010 11:05 am

I tried the same thing with 3ds max 7 and everything worked fine. But would be nice if you can support Blender, too.
Thanks for your fast and effevtive help!
peerpanda
 
Posts: 16
Joined: Tue Jan 26, 2010 2:38 pm

Postby NNair » Fri Jan 29, 2010 2:48 pm

Glad you got it working!

We know what the problem is with the Blender export -> meshgen. Currently we are looking into fixing it.

Will update the post when a fix is ready!

In the mean time since you have 3dsmax 7, you might be able to export your mesh from blender to a .3ds format and create the egg in max, just for the path finding to work.
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby darek » Fri Feb 26, 2010 1:17 pm

Excellent library !

Some thoughts about new features:

1. Defining forward vector for AICharacter. It's hardcoded to -Y (or did I miss something ?), but several people has several settings. My characters are faced to +Y.

2. Optonally instead of taking control on NodePath - just returning desired position and direction. This will make PandaAI universal and ready to use with physics cars for example.

3. Movement looks quite predictable. Are you using always the same random seed ?
darek
 
Posts: 63
Joined: Wed Feb 03, 2010 3:18 pm

Postby NNair » Sun Feb 28, 2010 3:28 am

Hi derek,

1. Yes it is hard coded as -y for now. Something to change for the future. We actually left it that way since orienting the model 180deg around is a simple requirement.

2. We left it this way since there was a way to do what you ask. You can create an empty nodepath as an AICharacter and then get the position and orientation from it.

3. By movement, do you mean the wander function? Because we did have an issue with our random number generator which would generate random numbers but in the same pattern. This is something we probably need to fix in a future version.

Thanks for the feedback.
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby sorcus » Sun Feb 28, 2010 3:41 am

Hi Derek,

Adding to what NNair posted, we felt that since Panda3D loads models in their -Y axis it wasn't really necessary to have an axis toggle in there. We were using some core functions within Panda3D for the direction vector of the NodePath which will still return -Y as forward and so we left it was -Y axis.

Thanks a lot for the feedback.
sorcus
 
Posts: 23
Joined: Thu Jun 04, 2009 1:31 pm
Location: ETC_Carnegie Mellon

Postby drwr » Sun Feb 28, 2010 5:02 am

Hmm, the Panda convention is that +Y is the forward direction.

David
drwr
 
Posts: 11253
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby NNair » Sun Feb 28, 2010 11:38 am

Added to the to be fixed list. Control will be given for a user specified heading direction.

Thanks.
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby darek » Sun Feb 28, 2010 2:13 pm

Sounds great. Btw by moving I mean wandering, yes.

Thanks.
darek
 
Posts: 63
Joined: Wed Feb 03, 2010 3:18 pm

Postby sorcus » Mon Mar 01, 2010 12:44 am

hmm, If it's +Y direction that is normal for Panda3D then it should be +Y. David, the lookAt function uses the original orientation of the 3D asset to rotate it to face the location we want it to. So if the 3D asset created in Maya is in -Y then it will be reverse, right?

Derek, We had some trouble with the random seeding with wander. That is something that definitely needs to be added.

Thanks
sorcus
 
Posts: 23
Joined: Thu Jun 04, 2009 1:31 pm
Location: ETC_Carnegie Mellon

Postby drwr » Mon Mar 01, 2010 1:01 pm

The lookAt() function rotates the +Y axis of the model to face the indicated direction. If your model was created with his nose looking down the -Y axis, then lookAt() will appear to rotate your model facing the wrong direction.

It is a very common mistake for models to be created looking down the -Y axis, because that means the modeler gets to look him in the face when he creates him. But "forward" means looking into the screen, not out of the screen.

David
drwr
 
Posts: 11253
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby sorcus » Mon Mar 01, 2010 1:14 pm

Hmm, I got it. So can I add a toggle in the lookAt() function so that it turns to look at the specified direction through time t rather than immediately doing so?

Or should i just write my own?
sorcus
 
Posts: 23
Joined: Thu Jun 04, 2009 1:31 pm
Location: ETC_Carnegie Mellon

Postby drwr » Mon Mar 01, 2010 1:48 pm

We usually do that sort of thing with an interval.
drwr
 
Posts: 11253
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby LetterRip » Wed Mar 03, 2010 9:09 pm

Has any thought been given to integration of the PandAI library into Blender?

I know some Panda3D users create their meshes, animations, etc in Blender, then export them to Panda3D. I suspect with Blender 2.5 coming out this summer that the numbers will increase substantially.

Being able to design the AI within Blender and then export the AI behaviour with the created characters and levels would probably be a large benefit to the Panda3D community.

My thoughts are that the following libraries would be desireable in addition to PandAI


http://code.google.com/p/libbehavior/
http://code.google.com/p/recastnavigation/

There is currently work on making Blenders logic tools node based

http://wiki.blender.org/index.php/Dev:S ... NodalLogic

which will make design even easier for users.

Perhaps it could be done as a Google Summer of Code project?

Thanks for your time,

Tom M
LetterRip
 
Posts: 1
Joined: Wed Mar 03, 2010 8:53 pm

Postby darek » Thu Mar 04, 2010 2:35 pm

It would be good to change
from libpandaai import *
to
from panda3d.ai import *
mentioned in tutorial at download page.
First one doesn't work in windows 1.7.0 package.
darek
 
Posts: 63
Joined: Wed Feb 03, 2010 3:18 pm

Postby Mindblighter » Tue Mar 16, 2010 6:38 am

Since I had lots of problems trying to implement my own AI, I was excited about PandAI, but it appears it is currently a bit too limited for my use. Do the devs of the lib have the resources to continue developing it and if so, it would be interesting to see some kind of priority list on what might be expected to come?
Mindblighter
 
Posts: 98
Joined: Thu Aug 02, 2007 7:33 am
Location: Finland

Postby JohnKol » Wed Mar 17, 2010 11:23 pm

Hello Mindblighter,

What kind of AI functionality are you looking to use? Currently the developers of PandAI are a little held up with other projects and internships, however we are hoping to add some minor tweaks and fixes to the library as soon as we get some time. Meanwhile, if you could describe the AI you want to use we might be able to help you.

Thanks!
John Kolencheryl

Project PandAI
Entertainment Technology Center
Carnegie Mellon
JohnKol
 
Posts: 35
Joined: Thu Aug 27, 2009 3:40 pm
Location: ETC, Carnegie Mellon University

Postby Mindblighter » Fri Mar 19, 2010 3:34 am

Thanks for the reply JohnKol.
My idea revolves around dynamically building random levels from blocks (originally tiles but squares are so limiting) for a Diablo style game. For example, a room or a piece of a corridor would make up a single block. Since you currently can't create autogenerate a navmesh or, as far as I can tell, input your runtime generated navmesh node data except through saving them on a file first, this is a bit of a hassle.

My next concern is the actual AI chars. I would need to have lots of models (a few dozen at least) running around after the player. If I'm not entirely mistaken, you currently can't have the models effectively pathfinding towards a target (player) and dodge collisions with each other.

This is one of the problems I ran into when I tried to create my own A* based system with tiles. I came up with using a feeler object like you do, but updating the A* path map turned out to be very difficult :wink:

I think the scenario I described is not very unusual, but it seems to be tricky to solve for amateurs like myself. Now that I'm writing this, I also thought of line of sight. Some kind of method for checking LOS based on the navmesh node data might be useful and fast for making certain decisions like whether the AI char should try to shoot at something or not.
Mindblighter
 
Posts: 98
Joined: Thu Aug 02, 2007 7:33 am
Location: Finland

Postby peerpanda » Fri Mar 19, 2010 4:07 am

I would wish me some more examples how to use the code. Yeah, i know on download section is explained how to use it. But when i do this i total fail.

For example evade:
aichar does nothing until i reach his destination and then he runs away and never stops or changes direction even i move in his way. and my relax_distance is twice the panic_distance.

i tried to make a swarm. after adding them all to swarm, swarm behavior was disabled. i checked c++-code and found a function to start this behavior. but nothing changed.


examples on download section are really good, iff they would do what i expect. so some graphical examples that shows behavior would be great. only small examples not that big like rralph. just a plane and then some chars which are using the behavior.

and it would be great if you can release your examples that you used for your videos. there is this swarm example with these moving trees and those chickens.

would be really nice!


btw our advancement:

1. we edited code so every aichar uses the same navmesh in the world for pathfinding. disadvantage is that you can only do one A* at the same time. We don't know how big this disadvantage is for bigger worlds but it is still possible that every aichar uses his own navmesh if coder wants to.

2. Another thing we did is what darek mentioned. It is possible to do a A*-search on the navmesh and a Python list with waypoints will be returned. Then you can do stuff like using physics or assure a consistent world in a p2p game (thats what we do :lol:).

i know, not much progress but team has much to do for university in the last weeks. Next week we focus on PandAI again and hopefully fix some issues.
peerpanda
 
Posts: 16
Joined: Tue Jan 26, 2010 2:38 pm

Postby NNair » Fri Mar 19, 2010 4:03 pm

@ Mindblighter

My next concern is the actual AI chars. I would need to have lots of models (a few dozen at least) running around after the player. If I'm not entirely mistaken, you currently can't have the models effectively pathfinding towards a target (player) and dodge collisions with each other.


We did try dynamic pathfinding which you talk about. Could you check out the demo on our downloads page:

http://www.etc.cmu.edu/projects/pandai/Download.html

called Dynamic Obstacle Avoidance Demo.

We did not test this extensively for the maximum number of characters it could support but it did dynamically avoid other pathfinding characters.

Also, the LOS is a neat feature, I will add it to the to do list.
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby NNair » Fri Mar 19, 2010 4:13 pm


@ derek


Thanks for the info. Will be updated.

@ peerpanda

Will put up the video examples. Thanks for adding to Pandai (yay for opensource!).
Srinavin Nair
PandAI,
Entertainment Technology Center,
Carnegie Mellon
NNair
 
Posts: 126
Joined: Thu Aug 27, 2009 3:38 pm
Location: ETC - Carnegie Mellon

Postby JohnKol » Sat Mar 20, 2010 11:13 am

1. we edited code so every aichar uses the same navmesh in the world for pathfinding. disadvantage is that you can only do one A* at the same time. We don't know how big this disadvantage is for bigger worlds but it is still possible that every aichar uses his own navmesh if coder wants to.

2. Another thing we did is what darek mentioned. It is possible to do a A*-search on the navmesh and a Python list with waypoints will be returned. Then you can do stuff like using physics or assure a consistent world in a p2p game (thats what we do ).


Thanks a lot guys for doing this! This is what open source is all about. We really hope the libraries will grow this way by adding new features and fixes. Also since you are editing the code, a few things to keep in mind,
1. Please make sure you are following all the Panda3D conventions. This is a must if it has to get into CVS. You can get the details here,


http://panda3d.cvs.sourceforge.net/viewvc/*checkout*/panda3d/panda/src/doc/coding-style.txt


2. Comment the code clearly so that people can easily understand and make modifications in future.
3. It would be great to have a maintenance log at the top of each file that you are editing. This would record the new features you have added and on what date.
4. We want to start updating the Panda3D manual soon so that it is easier to understand and implement the AI. If you guys can maintain a document of how to use the new features you have added that will be very helpful while we update the manual.

aichar does nothing until i reach his destination and then he runs away and never stops or changes direction even i move in his way. and my relax_distance is twice the panic_distance.


Could you provide a code snippet of how you are using the evade function? That would really help us to find out why it is not working.

i tried to make a swarm. after adding them all to swarm, swarm behavior was disabled. i checked c++-code and found a function to start this behavior. but nothing changed.


Same goes for this one too. A code snippent of how you are doing it will be really helpful. Did you add the flock object to the AI World? That is very important.

Once again thanks for all your help and suggestions. We really want to push some fixes and features into the library. We shall come up with a priority list and share it with everyone soon.[/url]
John Kolencheryl

Project PandAI
Entertainment Technology Center
Carnegie Mellon
JohnKol
 
Posts: 35
Joined: Thu Aug 27, 2009 3:40 pm
Location: ETC, Carnegie Mellon University

Postby Hypnos » Mon Mar 22, 2010 8:23 am

am i missing something or is the update mechanism bound to the system clock? (i'd like to be able to accelerate and delay gameplay/movement speed).

i am currently trying to recompile with a added timeDelta in update of AiWorld and AiCharacter and a modified acceleration calculation ( LVecBase3f acceleration = steering_force / _mass * timeDelta; )
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

PreviousNext

Return to Panda Features in Development

Who is online

Users browsing this forum: No registered users and 0 guests