Giter Site home page Giter Site logo

yuxiang-gao / pysocialforce Goto Github PK

View Code? Open in Web Editor NEW
114.0 6.0 34.0 78.97 MB

Extended Social Force Model in Python for social navigation research

License: MIT License

Python 96.88% TeX 3.12%
social-force-model social-navigation python py-social-force pedestrian-social-groups

pysocialforce's Introduction

Hi there ๐Ÿ‘‹ Yuxiang Gao Here

  • ๐Ÿค– I study socially-aware mobile robots.
  • ๐Ÿ“ซ How to reach me:[email protected]

yuxiang-gao's GitHub stats

pysocialforce's People

Contributors

0oshowero0 avatar svenkreiss avatar thedebugger811 avatar yuxiang-gao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pysocialforce's Issues

An improvement about Obstacle calculation

Hi, thanks for your great work about this social force simulator. I've tried this simulator and find it very useful.
I have a suggestion to improve the computation efficiency about the force calculation, that is the ObstacleForce class.
the _get_force() func will calculate the distance first for all the points in obstacle lines, then it add masks. When there are lots of obstacles this function will greatly slow-down the process.

To speed up this process, now I add a simple judgement to pre-select nearby obstacles. This improvement will speed up the process from 14sec/step to 0.05sec/step in our case. Note that the solution here is not very elegant. You can try to improve by this thought.

class ObstacleForce(Force):
    def _get_force(self):
        sigma = self.config("sigma", 0.2)
        threshold = self.config("threshold", 0.2) + self.peds.agent_radius
        force = np.zeros((self.peds.size(), 2))
        if len(self.scene.get_obstacles()) == 0:
            return force
        obstacles = np.vstack(self.scene.get_obstacles())
        pos = self.peds.pos()

        for i, p in enumerate(pos):
            diff = p - obstacles
            diff_select = diff[np.logical_and(np.logical_and(diff[:,0]<10,diff[:,0]>-10),np.logical_and(diff[:,1]<10,diff[:,1]>-10))]
            if diff_select.shape[0] == 0:
                continue
            else:
                directions, dist = stateutils.normalize(diff_select)
                dist = dist - self.peds.agent_radius
                if np.all(dist >= threshold):
                    continue
                dist_mask = dist < threshold
                directions[dist_mask] *= np.exp(-dist[dist_mask].reshape(-1, 1) / sigma)
                force[i] = np.sum(directions[dist_mask], axis=0)

        return force * self.factor

Improve Overall Performance

Hi guys,

I'm using your PySocialForce package to model a robot / pedestrian interaction in a 2D world. It's really a great effort from your side to create this package and put it on PyPI. Unfortunately, it's a bit too slow for my reinforcement learning purposes in order to achieve a reasonable amount of training episodes for my robot. (I know I could scale out with A3C, but I'm just a poor student ๐Ÿ˜‚)

I've seen you've already put Numba optimizations into your code and modeled everything as NumPy array, so you're probably aware of the fact that performance is critical to a simulation environment. Have you ever profiled your package, e.g. with cProfile or the new Scalene? (I know, silly question, but I'll have to ask anyways. I can create a profile for you if you want ๐Ÿ˜‚)

I think you've still got lots of Python C-API overhead in your routines which could easily be eliminated by more Numba vectorizations. For example, you're computing the forces sequentially (https://github.com/yuxiang-gao/PySocialForce/blob/master/pysocialforce/simulator.py#L78). And for modeling the forces you're using OOP inheritance which could be replaced by a single function returning a float (https://github.com/yuxiang-gao/PySocialForce/blob/master/pysocialforce/forces.py#L39).

I'm willing to make a major contribution to your project in the near future in case I can figure out some sensible optimizations. Are you interested in a collaboration of any kind? I'll be carrying out this optimization anyways because I need a faster training for my master thesis ๐Ÿ˜‚

Best wishes,
Marco

agent_radius has not been considered in social force

Hi,

Thanks for your excellent repository.

I have a question about the agent radius. I am not seeing that you are using agent radius in your SocialForce class. How do you consider avoiding a collision when you do not use agent radius? As I am changing the radius, agents still collide with each other lots of times because the radius has not been considered (I know that SFM does not guarantee to avoid collision, but their behavior shows that they do not know the radius). You only take the agent radius into account for avoiding obstacles in ObstacleForce class.

Thanks in advance for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.