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

Compare different crowd models #91

Closed
keanudicap opened this issue May 22, 2018 · 23 comments
Closed

Compare different crowd models #91

keanudicap opened this issue May 22, 2018 · 23 comments

Comments

@keanudicap
Copy link

As it has been shown here (http://gamma.cs.unc.edu/Menge/intro_vids.html#crowdmodels), Menge is able to use different crowd models. But I look into the Core folder, I can find only two methods: ORCA and PEDVO. Are there any other methods available now? If there exist other methods, how can I call it in the simulator? e.g. for ORCA, the model label is "orca".

@curds01
Copy link
Collaborator

curds01 commented May 22, 2018

ORCA and PEDVO are the only models that are "built in" to Menge. The other models are all plugins.

If you execute menge with the -l or -L flag, it will list all of the pedestrian models available to it (and what there name is for execution). In my build, I get the following:

$ ./menge -l

Available pedestrian models:

	Parameter: orca
		Based on the ORCA collision avoidance algorithm
	Parameter: pedvo
		Simulator based on Pedestrian Velocity Obstacle model
	Parameter: helbing
		Simulator based on Helbing et al. 2000 pedestrian model
	Parameter: zanlungo
		Simulator based on Zanlungo's 2011 collision prediction pedestrian model
	Parameter: dummy
		Dummy simulator to illustrate introduction of pedestrian models.
	Parameter: johannson
		Simulator based on Johansson et al. 2007 pedestrian model
	Parameter: gcf
		Simulator based on generalized centrifugal force pedestrian model
	Parameter: karamouzas
		Simulator based on Karamouzas's 2009 predictive collision pedestrian model

@keanudicap
Copy link
Author

Thanks. I am running the demo (4 squares) in Unity. I tried two built in models (orca and pedvo), and both of them work fine. However, just passing the name of methods in plugin to "Initialize" function doesn't work. I have build both Menge and Plugin projects. Is there something I could do to make the plugin model works in Unity?

ps: I don't think it should be the problem of scenario, each model should work in 4 square scenario.

@curds01
Copy link
Collaborator

curds01 commented May 22, 2018

Hmm...I don't think I've explicitly tried that. There may be an error in the bindings (such that the core library gets loaded, but the plugins doesn't.) I won't be able to dig into that into much later.

When you run it, do you get a log html file generated? That might give you some insight (again, I don't remember if that happens or not.)

@keanudicap
Copy link
Author

Unfortunately, there is no log file. The unity project is based on MengeCore.dll which was generated here (https://github.com/MengeCrowdSim/MengeCS). Does it already include the models from plugin (if you can remember)?

@keanudicap
Copy link
Author

ps: there are two .dll files: MengeCore.dll and MengeCS.dll. Will there be another .dll file like Plugin.dll that I can get from somewhere?

@curds01
Copy link
Collaborator

curds01 commented May 22, 2018

Correct. There would need to be more dlls. Command-line menge works by having a plug-ins directory full of dlls. The directory gets introspected at runtime and the plugins get loaded. There should be some ability to parallel that in the unity set up; I just haven't done it.

Menge's C api includes the ability to specify a plugin path, so that suggests that it would work as long as the path is initialized properly.

@keanudicap
Copy link
Author

I am trying to add plugin path but I have issue as shown in the repository MengeCS (MengeCrowdSim/MengeCS#7). I think it is the right place to add plugin lib, right?

Here is how I did:
a. in "Simulator.cs", I add "pluginPath" as an extra parameter in "Initialize" (line 21). and also pass this parameter to line 23.
b. in "Program.cs", I add "String pluginPath", set it to be something like "..\Menge-master\projects\VS2015\Plugins", and also change line 28 as well.
c. change line 5 in MengeCS.csproj as suggest in (https://github.com/MengeCrowdSim/MengeCS/), to something like "..\Menge-master\projects\VS2015\Menge\build\lib"

Since the original project (https://github.com/MengeCrowdSim/MengeCS/) failed in build, I cannot see how to make the plugin work for Unity.

Any help would be appreciated!

@curds01
Copy link
Collaborator

curds01 commented May 22, 2018

I won't be able to look into this in more detail until later.

@alafi
Copy link

alafi commented May 23, 2018

This is what I have done to utilize Menge plugins in Unity:

  • Create a new folder for Menge plugins: Assets\Plugins\x86_64\plugins
  • Copy the required Menge plugins to this folder (I am using the 64 binaries here)
  • In the main scene controller SimController.cs get the path of your assets folder and combine it with Menge dll folder:
    string path = Application.dataPath;
    string pluginsPath = Path.Combine(path, @"Plugins\x86_64\plugins");
  • Pass it to simulator Initialize method:
    _sim_is_valid = _sim.Initialize (behavior, scene, "orca", pluginsPath);

Make sure to modify the wrapper in MengeCS to accept the plugins path parameter.

Hope this will help.

@keanudicap
Copy link
Author

Thanks @alafi , I got stuck in the last step on passing the pluginsPath. Since "Initialize" is from MengeCS.dll and defined only to pass in three parameters. I think I need to recompile this project (https://github.com/MengeCrowdSim/MengeCS) to get MengeCS.dll. However, I failed in build this project. Or do you have an available MengeCS.dll which accepts pluginsPath that you could share with me?

@alafi
Copy link

alafi commented May 23, 2018

Just copy the source code for MengaCS to your Unity scripts folder then modify it and build it as part of your Unity project.

@keanudicap
Copy link
Author

Thanks @alafi , I copied all scripts from "MengeCS" project, and now it accepts four parameters. However, it still failed in initializing simulator, i.e. MengeWrapper.InitSimulator(behaveXml, sceneXml, model, pluginPath) returns wrong. And my pluginPath folder contains all built plugin libs, like AgtDummy_d.dll, AgtGCF_d.dll, etc. Do you have any idea what could be a problem?

@alafi
Copy link

alafi commented May 23, 2018

I see that you're using the Debug version of the binaries. Build the plugins and Menge core in Release configuration and try.

@keanudicap
Copy link
Author

@alafi I've tried couple of ways, but still no luck. Here is what I did.

  1. Rebuild Menge and Plugins project, on Release and x64.
  2. Find MengeCore.dll somewhere in "..\Menge-master\projects\VS2015\Menge\build\lib\x64"
  3. copy this dll file and replace the one in "..\MengeUnity-master\Assets\Plugins\x86_64"
  4. copy all files in "..\Menge-master\projects\VS2015\Plugins\build\lib\x64" to "..\MengeUnity-master\Assets\Plugins\x86_64\plugins"
  5. add
    string path = Application.dataPath; string pluginsPath = Path.Combine(path, @"Plugins\x86_64");

@keanudicap
Copy link
Author

@alafi Is it possible for you to share the folder "\MengeUnity-master\Assets\Plugins" with me to try?

@alafi
Copy link

alafi commented May 23, 2018

I may look at it if you make a very minimal Unity project with Menge plugins and share it.

@keanudicap
Copy link
Author

@alafi I share the Unity project here (https://goo.gl/FufvKP). You may change the file directory in SimController.cs to fit your local directory. Great thanks!

@MengeCrowdSim
Copy link
Owner

@alafi Thanks so much for tackling this.

I've added an issue for this in MengeUnity. This is really an issue on that repo and not on Menge, per se.

@alafi
Copy link

alafi commented May 23, 2018

OK... It seems like Windows is looking for the dependencies of the plugin's DLL everywhere except in the DLL's folder :S
Try this, copy MengeVis.dll (or MengeVis_d.dll) plus all the DLL's in projects/resources/win/exe_rsrc/x64 to the root folder of the Unity project and run.

@curds01
Copy link
Collaborator

curds01 commented May 23, 2018

Right. Some of the plugins also depend on MengeVis.dll.

@keanudicap
Copy link
Author

@alafi Thanks for the feedback. I started with the Unity project I shared in the google drive link. I copy all the DLLs in projects/resources/win/exe_rsrc/x64 plus MengeVis.dll and MengeVis_d.dll to the root folder (I tried both root folder and Asset folder). But still no luck.

I am sorry for asking these long questions, but this problem drives me mad.

@alafi
Copy link

alafi commented May 23, 2018

@keanudicap Your project updated and shared. Please check it.
Download
I didn't do anything special: removed all plugins except AgtHelbing.dll, copied the DLL's as explained earlier, and moved the example files to the Assets folder.
BTW I am using Unity 2017.3.0f3

@keanudicap
Copy link
Author

@alafi Great thanks! It also works in 2017.1.0f3. @curds01 I think we can close this issue.

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

4 participants