irsim.lib.algorithm.rvo#
This file is the implementation of the Reciprocal Velocity Obstacle (RVO) algorithm for multi-robot collision avoidance.
Author: Ruihua Han
reference: MengGuo/RVO_Py_MAS
Classes#
A class to implement the Reciprocal Velocity Obstacle (RVO) algorithm for multi-robot collision avoidance. |
Module Contents#
- class irsim.lib.algorithm.rvo.reciprocal_vel_obs(state: list, obs_state_list=None, vxmax=1.5, vymax=1.5, acce=0.5, factor=1.0, line_obs_list=None)[源代码]#
A class to implement the Reciprocal Velocity Obstacle (RVO) algorithm for multi-robot collision avoidance.
- 参数:
state (list) -- The rvo state of the agent [x, y, vx, vy, radius, vx_des, vy_des].
obs_state_list (list) -- List of states of static obstacles [[x, y, vx, vy, radius]].
vxmax (float) -- Maximum velocity in the x direction.
vymax (float) -- Maximum velocity in the y direction.
acce (float) -- Acceleration limit.
factor (float) -- Penalty weighting factor for velocity selection.
line_obs_list (list) -- List of line segments [[x1, y1, x2, y2], ...].
- state#
- obs_state_list = None#
- line_obs_list = None#
- vxmax = 1.5#
- vymax = 1.5#
- acce = 0.5#
- factor = 1.0#
- update(state, obs_state_list, line_obs_list=None)[源代码]#
Update the agent, circular-obstacle, and line-obstacle states.
- cal_vel(mode='rvo')[源代码]#
Calculate the velocity of the agent based on the Reciprocal Velocity Obstacle (RVO) algorithm.
- 参数:
mode (str) -- The vo configure to calculate the velocity. It can be "rvo", "hrvo", or "vo". - rvo: Reciprocal Velocity Obstacle (RVO) algorithm, for multi-robot collision avoidance. - hrvo: Hybrid Reciprocal Velocity Obstacle (HRVO) algorithm, for multi-robot collision avoidance. - vo: Velocity Obstacle (VO) algorithm, for obstacle-robot collision avoidance.
- 返回:
Selected velocity [vx, vy].
- 返回类型:
list[float]
- config_rvo_mode(obstacle)[源代码]#
Build one RVO cone for a circular obstacle.
- 参数:
obstacle -- Moving obstacle state
[x, y, vx, vy, radius]or static circular obstacle state[x, y, radius].- 返回:
[apex, left_vector, right_vector]cone description.- 返回类型:
list
- config_hrvo_mode(obstacle)[源代码]#
Build one HRVO cone for a circular obstacle.
- 参数:
obstacle -- Moving obstacle state
[x, y, vx, vy, radius]or static circular obstacle state[x, y, radius].- 返回:
[apex, left_vector, right_vector]cone description.- 返回类型:
list | None
- config_vo_mode(obstacle)[源代码]#
Build one VO cone for a circular obstacle.
- 参数:
obstacle -- Moving obstacle state
[x, y, vx, vy, radius]or static circular obstacle state[x, y, radius].- 返回:
[apex, left_vector, right_vector]cone description.- 返回类型:
list
- config_vo_lines()[源代码]#
Compute VO cones for line segment obstacles.
For each segment, compute the angular span as seen from the agent, expanded by asin(r / dist) on each side to account for the agent radius. The apex is [0, 0] since line obstacles are static.
- vel_candidate(rvo_list)[源代码]#
Sample reachable velocities and split them by VO feasibility.
- 参数:
rvo_list -- Velocity-obstacle cone descriptions
[apex, left, right].- 返回:
Feasible velocities outside all cones and infeasible velocities inside at least one cone.
- 返回类型:
tuple[list, list]
- vel_select(vo_outside, vo_inside)[源代码]#
Select the best velocity from feasible candidates or penalized fallback.
Both arguments may be lists of
[vx, vy]or(N, 2)arrays; the first minimum is returned, asminwould.
- penalties(vels, vel_des, factor)[源代码]#
Vectorized
penalty()for an(N, 2)array of velocities.Same formulas and branches as the scalar version, evaluated for all candidates at once; the crowded-scene fallback otherwise calls
penaltyhundreds of times per robot per step.
- penalty(vel, vel_des, factor)[源代码]#
Scalar
penalties()for one velocity, kept for compatibility.