MengeCrowdSim / Menge

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

Compare different crowd models #91

Closed keanudicap closed 6 years ago

keanudicap commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

I am trying to add plugin path but I have issue as shown in the repository MengeCS (https://github.com/MengeCrowdSim/MengeCS/issues/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 commented 6 years ago

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

alafi commented 6 years ago

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

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

Hope this will help.

keanudicap commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

keanudicap commented 6 years ago

@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 commented 6 years ago

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

alafi commented 6 years ago

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

keanudicap commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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

keanudicap commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

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