Skip to content

ddebenedittis/lightsfm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lightsfm

A lightweight implementation of the Social Force Model for Social Local Navigation. It is based on the initial model proposed by Helbing and Molnar [1] and extended for social groups by Moussaid et Al. [2][3]:

  • [1] Helbing, Dirk & Molnar, Peter. (1998). Social Force Model for Pedestrian Dynamics. Physical Review E. 51. 10.1103/PhysRevE.51.4282.
  • [2] Moussaid M, Helbing D, Garnier S, Johansson A, Combe M, et al. (2009) Experimental study of the behavioural mechanisms underlying self-organization in human crowds. Proceedings of the Royal Society B: Biological Sciences 276: 2755–2762.
  • [3] Moussaïd, Mehdi & Perozo, Niriaska & Garnier, Simon & Helbing, Dirk & Theraulaz, Guy. (2010). The Walking Behaviour of Pedestrian Social Groups and Its Impact on Crowd Dynamics. PloS one. 5. e10047. 10.1371/journal.pone.0010047.

The model consists on the definition of different attractive and repulsive forces that describe the local navigation behavior of pedestrians.

*Note: vectors are indicated with capital letters

Social Forces

1. Attractive force to reach the goal (DesiredForce Fgoal)

With:

  • Desired velocity value.

  • Desired direction vector with:

    • the desired goal position.
    • the current agent position.
  • Actual velocity vector.

And parameters:

  • Strength Factor of the desire to reach the goal (default: 2.0).
  • Relaxation time (default: 0.5 seg).

2. Repulsive force of obstacles (ObstacleForce Fobs)

We use a monotonic decreasing potential of the force (an exponential in our case) based on the distance between the agent and the obstacles.

With:

  • Unit vector in the direction from the pedestrian p to the obstacle o.
  • Position of the obstacle o relative to the pedestrian p.

And parameters:

  • Strength Factor of the desire to walk away the obstacles (default: 10.0).
  • Exponential parameter (default: 0.2).

3. Respulsive force of other pedestrians (SocialForce Fsoc)

Other pedestrians will prokove a repulsive effect on the agent. In the initial model [1], a potential with the form of an ellipse directed in the motion direction of the pedestrian is proposed. However, in the empirical study carried out in [2], the authors specify a more advanced interaction function based on two components, and , describing the deceleration along the interaction direction and directional changes along the normal vector to the interaction direction oriented to the left, .

in which the interaction direction between the agent p and the pedestrian i, is the unit vector

And the interaction vector computed as a composition of the direction of relative motion and the direction in which the interaction pedestrian i is located:

If denotes the distance between two pedestrians p and i and the angle between the interaction direction and the vector pointing from agent p to pedestrian i, we have:

This represents an exponential decay of the deceleration with distance d.

With:

  • the sign of the angle (=[0, 1, -1]). It takes into account the discontinuity in the angular motion, reflecting the binary decision to evade the other pedestrian either to the left or to the right.

Parameters:

  • Strength Factor of the desire to walk away the other pedestrians (default: 2.1).
  • reflects the relative importance of the two directions (default: 2.0).
  • increases in the interaction direction by large relative speeds, while the repulsion towards the sides is reduced (default: 0.35).
  • (default: 2.0).
  • , n' > n, which corresponds to a larger angular interaction range. (default: 3.0).

4. Force of interaction groups (GroupForce Fgroup)

This force is a combination of another subforces that describes the formation of the social group, as described in [3].

4.1. Force of vision field of the group (GroupGazeForce Fggaze)

It is based on the rotation angle of the pedestrian's head (gazing direction) so that the group's mass center is included in the vision field (~90º). The greater the head rotation the less comfortable is the turning for walking, and therefore the pedestrian adjusts its position to reduce the head rotation. In our implementation we can not detect the gaze direction, so we check if the group's mass center is beyond the vision field of the pedestrian according to his/her movement direction. Therefore, if the angle to communicate with the group (look to the mass center) is greater than the vision field we apply the following force:

With:

  • Value based on the desired direction and the distante to the mass center.

Where is the position of the group's mass center g relative to the pedestrian p.

  • Desired direction vector.

Parameters:

  • Strength Factor of the vision of the group (default: 3.0).

4.2. Attraction force to the group's center of mass (GroupCoherenceForce Fgcoh)

The agent feels an attraction to keep close to its interaction group (to keep the coherence of the group).

With:

  • is the position of the group's mass center g relative to the pedestrian p.

  • is a saturation factor in the range [-1,1] based on the distance to the group's center and a distance threshold. with the Euclidean distance between the agent p and the group's center g; and n the number of agents in the group.

    Parameters:

  • Strength Factor of the desire to walk with the group (default: 2.0).

4.3. Respulsion force of overlaping group members (GroupRespulsionForce Fgrep)

Repulsion effect so that the group members do not overlap each other.

With:

  • is the position of the group member i relative to the group member p.
  • is an activation parameter that takes value 1 when the Euclidean distance between the agents p and i is smaller than a threshold value d, that is one body diameter plus some safety distance, otherwise 0.

Parameters:

  • Strength Factor for not overlapping the group's members (default: 1.0).

Code indications

This is header-only library that does not depend on ROS. All the agents positions, velocities, obstacles, etc must be provided according to the same selected coordinate frame.

  • sfm.hpp contains the methods for computating of all the described forces.
  • angle.hpp and vector2d.hpp contain different help structures and methods that are employed in the forces computation.
  • map.hpp contains an optional structure for representing the obstacles of the static map, and some virtual methods to check obstacles.

How to use it

First, you need to compile and install the library:

make

sudo make install

The library will be installed in the directory /usr/local/include/lightsfm

To use the library in you project, you need two things mainly:

  • First, you need to use the structure Agent (sfm.hpp) to represent your pedestrians.

  • Secondly, to define you agents' obstacles. Two options: by implementing the virtual methods of the map.hpp header (to pass them through Map* map). Or by filling the obstacles vectors of the agents.

  • Finally, with your defined obstacles and agents, you can call different methods:

    std::vector<Agent>& computeForces(std::vector<Agent>& agents, Map* map) const; To compute the social forces for all the agents.

    void computeForces(Agent& me, std::vector<Agent>& agents, Map* map); To compute the social forces for the indicated agent.

    std::vector<Agent>& updatePosition(std::vector<Agent>& agents, double dt) const; To update the state of all the agents after a time step indicated by dt.

    void updatePosition(Agent& me, double dt) const; To update the state of the indicated agent after a time step indicated by dt.

An example of the use of the library can be seen in:

About

A lightweight Social Force Model library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.3%
  • Other 1.7%