This fork contains additional logic in Agent.cpp so agents can set a collabCoeff to denote how collaborative they are:
collabCoeff > 0.5: overly cooperative agent, will add more than 1/2*u to its velocitycollabCoeff = 0.5: standard ORCA (each agent does 1/2 the work)collabCoeff in (0, 0.5): less cooperative agent, will barely adjust its velocity to avoid otherscollabCoeff = 0: non-cooperative, will just follow its prefVelcollabCoeff < 0: anti-cooperative agent, will ignore its own prefVel and try to collide with the nearest agent (position-wise), collabCoeff trades off mimicing the other agent (collab=0 ==> prefVel = other->veloc) vs. trying to hit immediately (collab=-inf ==> prefVel=relPos)
This repository contains the RVO2 framework, as described below, along with Cython-based Python bindings. Its home is GitHub. New updates are released there. There are no explicit version numbers -- all commits on the master branch are supposed to be stable.
Install Cmake toolchain, if not yet available:
sudo apt-get install cmake build-essentialBuild the package: This command will install all dependencies, build and install the package.
python3 -m pip install .If running into errors during installation delete build/ and dist/ and try again.
The python RVO2 package relies on precompiled bindings - this requires Python.h files. If you encounter the installation issues like
...
src/rvo2.cpp:48:10: fatal error: Python.h: No such file or directory
48 | #include "Python.h"
...
It is very likely that you have not the python developer package. To install this, run for your python version
sudo apt install python3.11-dev
#!/usr/bin/env python
import rvo2
sim = rvo2.PyRVOSimulator(1/60., 1.5, 5, 1.5, 2, 0.4, 2)
# Pass either just the position (the other parameters then use
# the default values passed to the PyRVOSimulator constructor),
# or pass all available parameters.
a0 = sim.addAgent((0, 0))
a1 = sim.addAgent((1, 0))
a2 = sim.addAgent((1, 1))
a3 = sim.addAgent((0, 1), 1.5, 5, 1.5, 2, 0.4, 2, (0, 0))
# Obstacles are also supported.
o1 = sim.addObstacle([(0.1, 0.1), (-0.1, 0.1), (-0.1, -0.1)])
sim.processObstacles()
sim.setAgentPrefVelocity(a0, (1, 1))
sim.setAgentPrefVelocity(a1, (-1, 1))
sim.setAgentPrefVelocity(a2, (-1, -1))
sim.setAgentPrefVelocity(a3, (1, -1))
print('Simulation has %i agents and %i obstacle vertices in it.' %
(sim.getNumAgents(), sim.getNumObstacleVertices()))
print('Running simulation')
for step in range(20):
sim.doStep()
positions = ['(%5.3f, %5.3f)' % sim.getAgentPosition(agent_no)
for agent_no in (a0, a1, a2, a3)]
print('step=%2i t=%.3f %s' % (step, sim.getGlobalTime(), ' '.join(positions)))Calling Python-RVO2 from multiple threads has not been tested. However, code that
may take longer to run (doStep(), processObstacles() and queryVisibility(...))
release the Global Interpreter Lock (GIL) so that other Python threads can run while
RVO2 is processing.
Copyright 2008 University of North Carolina at Chapel Hill
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Please send all bug reports for the Python wrapper to Python-RVO2, and bug report for the RVO2 library itself to geom@cs.unc.edu.
The RVO2 authors may be contacted via:
Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, and Dinesh Manocha Dept. of Computer Science 201 S. Columbia St. Frederick P. Brooks, Jr. Computer Science Bldg. Chapel Hill, N.C. 27599-3175 United States of America