MengeCrowdSim / Menge

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

How can I plug in my own navigation algorithm to Menge? #87

Open Aaricis opened 6 years ago

Aaricis commented 6 years ago

I have seen that some prior crowd movement simulation algorithms can be easily implemented within Menge. Now, I want to visualize my own multiple-agents navigation algorithm but I do not know how to implement?

curds01 commented 6 years ago

So, there's not necessarily a straight-forward answer. The answer is "it depends".

  1. For agents that make purely personal decisions, the VelocityComponent is the mechanism. But that's only for agents whose navigation depends only on their own state (e.g., the velocity components that cause agents to traverse road maps, navigation meshes, etc.)
  2. I infer from "multiple-agents navigation" that you have an algorithm that is coordinated in some sense. That a single agent's preferred velocity is a function of other agents. If that's true, a reasonable example might be the Formation plug-in example. It's a combination of Task and VelocityModifier (on top of a simple VelocityComponent.

To give you a more concrete answer I need to have a more in-depth understanding of the properties of your algorithm. We can either have that conversation here in this issue (where everyone can benefit), or, if your algorithm is proprietary, you can email menge@cs.unc.edu and we can discuss it offline.

Aaricis commented 6 years ago

Thank you for the fast response. To state my issue clearly. Recently, I have read the paper about HRVO. I know Menge is based on ORCA now. And I want to see some differences between HRVO and ORCA. After all, the two algorithm are all about navigation. I download HRVO in GAMMA Lab Homepage.

curds01 commented 6 years ago

Oh, good. This is much easier. In this case, you just want an additional Agent model. If you look in the Plugins directory, there are multiple alternate models. Just copy one of the Agt* projects, changing names to something like AgtHRVO. The key to HRVO, as with all of the agent models, is defining the actual velocity relative to the preferred velocity and neighbor agents and obstacles. So, the most important thing is to define the computeNewVelocity() method.

Aaricis commented 6 years ago

I have checked out the Plugins directory and I have HRVO source code. But I do not know how to add this HRVO model to Menge. I think maybe I should add the HRVO source code to AgtHRVO and add some information in .xml file. Is it right?

curds01 commented 6 years ago

You have to implement several interfaces: BaseAgent, SimulatorBase, and SimulatorDBEntry.

BaseAgent: This is the base class for the actual agents moving around. The most important part of this functionality is the computeNewVelocity() method. This is where HRVO's brains go. SimulatorBase: This is largely responsible for parsing any global parameters for the HRVO model; i.e. parameters that affect all agents. SimulatorDBEntry: This is the class that allows the system to recognize HRVO agents delcared on the command-line and instantiate the right kind of agent.

AgtDummy gives the simplest version of all of these.

Tying HRVO into Menge is going to require implementing all of these interfaces and is not just a case of adding HRVO source code.