YAML配置语法#

配置文件是用于初始化环境的 YAML 文件。它包含用于模拟和可视化世界、障碍物和机器人的配置参数。你只需通过这些参数即可自定义场景并定义对象的行为。


配置总览#

一个完整的 IR-SIM 场景由最多四个顶层键描述 —— worldrobotobstacleguirobotobstacle 共享同一个对象级 schema —— 仅默认的 role 不同。展开下方的交互式树即可浏览每个键及其类型和默认值;除非默认值为 ,否则所有键均为可选。点击各部分的 full docs › 链接可跳转到详细说明。

KeyTypeDefaultDescription
worlddictsimulation environmentfull docs ›
namestr"world"world name
heightfloat10world height (m, y-axis)
widthfloat10world width (m, x-axis)
step_timefloat0.1simulation step (s)
sample_timefloatstep_timerender / sample step (s)
offsetlist[0, 0]world origin offset [x, y]
control_modestr"auto"auto | keyboard
collision_modestr"stop"stop | unobstructed | unobstructed_obstacles
statusstr"None"Running | Pause | Arrived | Collision
obstacle_mapstr/dict/nullnulloccupancy-grid source
mdownsampleint1obstacle-map downsample factor
plotdictglobal plot options
saved_figuredict{dpi:100, bbox_inches:'tight'}
figure_pixelslist[1000, 800]figure size in px
show_titlebooltrue
titlestrnullcustom title
no_axisboolfalse
tightbooltrue
viewpointnull/list/strnullcamera center or object to follow
robot / obstaclelistper-object schema (default role: robot / obstacle)full docs ›
namestr/listnullunique id, auto "<role>_<id>"
numberint1how many to create
statelist[0, 0, 0]initial [x, y, theta]
goallistnulltarget [x, y, theta] (or list of)
velocitylist[0]·diminitial control vector
rolestr"obstacle"robot | obstacle
colorstr"k"matplotlib color
staticboolfalseimmobile object
vel_minlist[-1]·dim
vel_maxlist[1]·dim
accelist[inf]·dimaccel limits
angle_rangelist[-pi, pi]
goal_thresholdfloat0.1arrival distance
arrive_modestr"position"position | state
descriptionstrnullimage label
groupint0
group_namestrnull
unobstructedboolfalseignore collisions
state_dimintnull
vel_dimintnull
fovfloatnullfield-of-view angle (rad)
fov_radiusfloatnull
distributiondictplacement when number > 1
namestr
No extra keys — set state / goal per object.
range_lowlistworld bounds +0.5lower [x, y, θ] bound
range_highlistworld bounds −0.5upper [x, y, θ] bound
min_distancefloat1.0min pairwise spacing
centerlistworld center[x, y, θ] of the circle
radiusfloatmin(w,h)/2−0.5circle radius
kinematicsdictmotion model
namestr
noiseboolfalseadd velocity noise (all variants)
alphalist[0.03, 0, 0, 0.03]noise params [α₁ … α₄]
alphalist[0.03, 0.03]noise params [α_fwd, α_lat]
alphalist[0.03, 0.03, 0.03]noise params [α_fwd, α_lat, α_yaw]
alphalist[0.03, 0, 0, 0.03]noise params
modestr"steer"steer | angular
wheelbase comes from shape.wheelbase.
shapedictgeometry
namestr
radiusfloat0.2circle radius
centerlist[0, 0]body-frame center
random_shapeboolfalserandomize radius
radius_rangelist[0.1, 1.0]when random_shape
wheelbasefloatnullrequired for acker
lengthfloat1.0x-axis length
widthfloat1.0y-axis width
wheelbasefloatnullrequired for acker
verticeslist[[x, y], …] body frame
random_shapeboolfalsegenerate random polygons
is_convexboolfalseforce convex when random
Random-gen extras: number, center_range, avg_radius_range, … (see full docs).
verticeslist[[x, y], …] body frame
random_shapeboolfalsegenerate random linestrings
is_convexbooltrueforce convex when random
behaviordictper-object motion logic
namestr
wanderboolfalseshared — new random goal on arrival
loopboolfalseshared — cycle waypoints
target_rolesstr"all"shared — all | robot | obstacle
range_lowlist[0,0,-pi]shared — wander bound
range_highlist[10,10,pi]shared — wander bound
angle_tolerancefloat0.1orientation tol. (diff/acker/omni_angular)
vxmaxfloat1.5max x velocity
vymaxfloat1.5max y velocity
accefloat1.0acceleration factor
factorfloat1.0RVO scaling
modestr"rvo"rvo | hrvo | vo
neighbor_thresholdfloat3.0neighbour filter distance
vmaxfloat1.5speed cap after force integration
neighbor_thresholdfloat10.0social interaction cutoff distance
relaxation_timefloat0.5goal-pull time constant tau
force_factor_desiredfloat1.0goal-pull weight
force_factor_socialfloat2.1inter-agent repulsion weight
force_factor_obstaclefloat10.0obstacle repulsion weight
sigma_obstaclefloat0.8obstacle force decay length
lambda_importancefloat2.0velocity vs. position weight in interaction direction
gammafloat0.35interaction range scale
n_angularfloat2.0sideways force angular sharpness
n_velocityfloat3.0slowdown force angular sharpness
safety_radiusfloat0.0personal-space buffer (m) shifting decay closer in
group_behaviordictgroup-level (ORCA)
namestrorca
neighborDistfloat15.0
timeHorizonfloat20.0
safe_radiusfloat0.1
maxSpeedfloat/nullnullfalls back to vel_max
sensorslistlidar2d or fmcw_lidar2d
namestr
range_minfloat0
range_maxfloat10
numberint100beam count
scan_timefloat0.1
noiseboolfalseboth variants
stdfloat0.2
angle_stdfloat0.02
offsetlist[0, 0, 0]
has_velocityboolfalse
plotdictsensor visualization · flat keys also accepted
alphafloat0.3plot transparency
colorstr"r"
motion_compensateboolfalseremove ego-motion from radial velocity
velocity_noise_stdfloat0.0radial-velocity noise std
scan adds radial_velocity and valid arrays.
plotdictDoppler visualization · flat keys also accepted
plotdictper-object visualization
group
obj_colorstrobject's coloroutline / fill colour
obj_alphafloat1.0transparency 0–1
obj_linestylestr"-"outline line style
obj_linewidthfloatobject's width
obj_zorderint3 / 1draw order (robot / obstacle)
show_goalboolfalsetruemaster switch — enables the keys below
goal_colorstrobject's color
goal_alphafloat0.5
show_textboolfalsetruemaster switch — enables the keys below
text_alphafloat1.0
text_positionlistradius offset[dx, dy] from center
show_arrowboolfalsetruemaster switch — enables the keys below
arrow_colorstr"gold"
arrow_lengthfloat0.4
arrow_widthfloat0.6
arrow_alphafloat1.0
show_trajectoryboolfalsetruemaster switch — enables the keys below
traj_colorstrobject's color
traj_widthfloatobject's width
traj_alphafloat0.5
keep_traj_lengthint00 = keep all
show_trailboolfalsetruemaster switch — enables the keys below
trail_freqint2plot every N steps
trail_typestrobject's shape
trail_edgecolorstrobject's color
trail_alphafloat0.7
trail_fillboolfalse
trail_colorstrobject's color
keep_trail_lengthint00 = keep all
show_sensorbooltrueshow sensor visualization
show_fovboolfalsetruemaster switch — enables the keys below
fov_colorstr"lightblue"
fov_alphafloat0.5
guidictoptional interactive controlsfull docs ›
keyboarddictactive when control_mode: keyboard
backendstr"pynput"pynput | mpl
global_hookboolfalse
key_lv_maxfloat3.0
key_ang_maxfloat1.0
key_lvfloat0.0
key_angfloat0.0
key_rotfloat0.0yaw rate (omni_angular)
key_idint0
mousedictinteractive zoom / pan
zoom_factorfloat1.1

小技巧

该树是一个快速导览 —— 点击任意键即可跳转到它的完整说明。完整的说明、示例和边界情况请参见下方各部分的文档。


快速上手示例#

配置文件主要分为三个部分:worldrobotobstacle。下面是一个可直接复制并修改的最小可用示例:

world:
  height: 10  # the height of the world
  width: 10   # the width of the world
  step_time: 0.1  # 10Hz calculate each step
  sample_time: 0.1  # 10 Hz for render and data extraction 
  offset: [0, 0] # the offset of the world on x and y 
  collision_mode: 'stop'  # 'stop', 'unobstructed', 'unobstructed_obstacles'
  plot:
    show_title: true
    figure_pixels: [1000, 800]

robot:
  - kinematics: {name: 'diff'}  # omni, diff, acker
    shape: {name: 'circle', radius: 0.2}  # radius
    # shape: {name: 'rectangle', length: 0.5, width: 0.2}  # radius
    state: [1, 1, 0]  
    goal: [9, 9, 0] 
    # acce: [3, .inf]   # acce of [linear, angular]  or [v_x, v_y] or [linear, steer]
    behavior: {name: 'dash'} # move toward to the goal directly 
  
obstacle:
  - number: 10
    distribution: {name: 'random'}
    shape: 
      - {name: 'circle', radius: 1.0}  # radius
      - {name: 'rectangle', length: 1.5, width: 1.2}  # radius
    state: 
      - [5, 5, 0]  
      - [4, 4, 0]
  
  - shape: {name: 'rectangle', length: 1.5, width: 1.2}  # radius
    state: [6, 5, 1] 

  - shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] }  # vertices
    state: [0, 0, 0] 
    unobstructed: True

重要

关键内容配置指南

  • 要在配置文件中包含多个机器人或障碍物,请在 robot 和 obstacle 部分下添加单独的条目,并使用 - 标记每个添加的条目。

  • distribution、shape、behavior、group_behavior 和 kinematics 等参数必须写成 {key: value} 字典形式。请确保每个字典都包含 name 键;省略 name 会使该参数取值为 None。

  • 当处理多个对象(即数量大于 1)时,利用 distribution 参数来定义这些对象的摆放位置的分布方式。

  • 默认情况下,同一组内的所有对象共享相同的配置。要单独自定义组内的某个对象,可使用 - 添加子参数。未显式配置的其余对象会继承组中最后一个已指定对象的设置。

  • 对象级 name 是可选的,用于标识每个对象。若省略,默认值为 "<role>_<id>"(例如 robot_0obstacle_3)。名称在所有对象间必须唯一;重复会在环境初始化时报错。请勿将对象级 nameshapekinematicsbehavior 等字典内部的 name 键混淆(后者表示组件类型)。


World 配置#

本节介绍 world 区块可用的配置参数。

World 参数表#

参数

类型

默认值

说明

name

str

"world"

世界名称

height

float

10

长(米)

width

float

10

世界的宽

step_time

float

0.1

决定仿真每一步之间的时间间隔(秒)。

sample_time

float

step_time

渲染和数据提取的采样时间间隔(秒)。如未指定则默认为 step_time

offset

float 列表

[0, 0]

世界位置在 [x, y] 坐标上的偏移量

control_mode

str

"auto"

仿真控制模式,支持 autokeyboard

collision_mode

str

"stop"

碰撞处理模式(支持:"stop""unobstructed""unobstructed_obstacles"

status

str

"None"

仿真环境状态初始化(支持 "Running""Arrived""Collision""Pause"

obstacle_map

strndarraydictnull

None

生成器配置 dict(例如 { name: image, path: '…' }{ name: perlin, resolution: 0.1, })。字符串路径是 image 生成器的简写形式。参见 配置栅格地图

mdownsample

int

1

障碍地图的降采样系数,用于降低分辨率并减少计算量。

plot

dict

{}

初始化世界图形的绘制选项。

参数详解#

world 属性
namestr,默认: "world"

定义仿真使用的世界名称,便于区分不同环境。

heightfloat,默认 10

指定世界在屏幕 Y 轴方向的垂直尺寸(米)。

widthfloat,默认 10

指定世界在屏幕 X 轴方向的水平尺寸(米)。

step_timefloat,默认 0.1

决定仿真每一步之间的时间间隔。

性能影响step_time 越小仿真频率越高(如 0.1 秒即 10 Hz),但仿真耗时也更长。

sample_timefloat,默认与 step_time 相同)

定义渲染与数据采集的时间间隔,决定可视化更新与记录的频率。未指定时默认等于 step_time

offsetfloat 列表,默认 [0, 0]

设置世界在 X、Y 轴上的初始偏移,便于在更大坐标系中定位或相对放置。

world 模式
control_mode (str, 默认: "auto")

配置仿真中对象的被控方式:

选项:

  • auto:通过 Python 脚本中定义的输入速度或 YAML 文件中的行为进行自动控制。

  • keyboard:通过键盘输入进行手动控制。按键输入在文件中定义。

collision_mode (str, 默认: "stop")

定义仿真中对象碰撞的处理方式:

选项:

  • stop:发生碰撞时立即停止(默认)。

  • unobstructed:允许对象彼此穿过,不考虑任何碰撞。

  • unobstructed_obstacles:仅允许障碍物彼此穿过而不考虑碰撞;机器人与障碍物发生碰撞时仍会停止。

status (str, 默认值: "None")

设置仿真环境的初始状态:

选项:

  • "Running":仿真正常运行(默认)。

  • "Pause": 仿真初始状态为暂停。

  • "Arrived": 仿真在机器人到达目标点的时候停止。

  • "Collision": 仿真在机器人与障碍物发生碰撞时停止。

注意:仿真过程中可以通过键盘(空格键)或程序控制动态切换状态。

world 地图
obstacle_mapdictstrndarraynull,默认值:None

占据栅格来源。标准形式是带 name 的生成器配置字典;其他类型为便捷写法/向后兼容。

  • 生成器配置dict):name 标识生成器。name: image 配合 path(例如 'cave.png')从图像加载,栅格大小取自图像。name: perlin(及其他)需要 resolution;栅格大小 = 世界大小 / resolution。参见 配置栅格地图。要新增生成器,参见 新增地图生成器

  • 图像路径str):等价于 { name: image, path: obstacle_map }(向后兼容)。

  • 占据栅格ndarray):仅供编程方式使用。浮点值 0–100;世界大小必须与栅格形状匹配。

  • null:无障碍物地图(空世界)。

可用地图:我们在 irsim/world/map 文件夹中提供了一些示例地图,你也可以使用来自 HM3DMatterPort3DGibson 等 3D 数据集的自定义地图。更多细节见 此处

# Image path
obstacle_map: 'hm3d_2.png'

# Procedural generator (grid size = world size / resolution)
obstacle_map:
  name: perlin
  resolution: 0.1
  complexity: 0.12
  fill: 0.32
  seed: 48
mdownsample (int, 默认值: 1)

设置障碍物地图图像的降采样系数。

提示:更高的取值会降低障碍地图的分辨率,减小计算负载,从而提升仿真性能。

world 可视化
plot (dict, 默认值: {})

指定初始化世界绘图时可用的绘制选项。

可视化选项:

  • saved_figure:默认 dpi100;默认格式为 png;默认 bbox_inches 为 tight。更多细节参见 matplotlib.pyplot.savefig

  • figure_pixels: 图像的像素宽和高,默认值为[1000, 800]

  • show_title: 是否显示图表标题,默认是True.

  • title:自定义图表标题;若未指定,则显示仿真时间与当前状态。

  • no_axis: 是否显示坐标轴,默认是False

  • tight: 是否使用紧凑布局,默认是True.

  • viewpoint: 控制相机(视角)的中心位置,默认值为null.

    • null:使用初始的世界边界,不进行自动移动

    • [x, y]:视角始终以固定点[x, y]为中心

    • "<object_name>":跟随该名称的对象进行动态平移,例如"robot_0"

# Examples
plot:
  viewpoint: [3, 3]        # fixed center at (3, 3)
# or
plot:
  viewpoint: "robot_0"     # follow the object named robot_0

完整世界配置示例#

world:
  name: "world"                       # Name of the world
  height: 10                          # Height of the world
  width: 10                           # Width of the world
  step_time: 0.1                      # Time interval between steps (10 Hz)
  sample_time: 0.1                    # Time interval for rendering and data extraction (10 Hz)
  offset: [0, 0]                      # Positional offset of the world on the x and y axes
  control_mode: 'keyboard'            # Control mode ('auto' or 'keyboard')
  collision_mode: 'stop'              # Collision handling mode ('stop', 'unobstructed', 'unobstructed_obstacles')
  obstacle_map: "path/to/map.png"     # Path to the obstacle map image file
  mdownsample: 2                      # Downsampling factor for the obstacle map
  status: "Running"                   # Initial simulation status
  plot:                               # Plotting configuration
    show_title: true                  # Show plot title
    title: "Custom Simulation Title"  # Custom title (optional)
    figure_pixels: [1200, 800]        # Figure size in pixels
    viewpoint: "robot_0"              # Camera center: fixed [x, y], object name, or null
    saved_figure:                     # Figure saving options
      dpi: 150                        # Resolution for saved figures
      format: "png"                   # File format

警告

obstacle_map:将 "path/to/map.png" 替换为你的障碍物地图图像的实际文件路径。请确保图像为兼容格式(如 PNG、JPEG)并正确表示障碍物位置。


Object 配置#

仿真中的 robotobstacle 都作为对象进行配置,参数结构类似但默认值可能不同。本节介绍这些对象可用的配置项。

Object Parameters Table#

Parameter

类型

默认值

描述

name

str 或者 list of str

None

对象的唯一标识符;若省略,则会自动分配为"<role>_<id>"。当number > 1时支持参数列表。

number

int

1

要创建的对象数量。

distribution

dict

{name: manual}

定义多个对象的分布方式。支持的分布方式有:manual, random, circle

kinematics

dict

None

对象的运动学模型。支持的模型有diffackeromniomni_angular

shape

dict

{name: circle}

对象的几何形状。支持的形状有circle, rectangle, polygon , linestring

state

float 列表

[0, 0, 0]

对象的初始状态向量。

velocity

float 列表

[0] * action_dim

初始速度向量。长度与运动学动作维度匹配(diff/omni/acker 为 2,omni_angular 为 3)。

goal

float列表或float列表的列表

None

目标状态向量。

behavior

dict

None

决定对象运动的行为配置,支持 dashrvo(可用性取决于 kinematics,详见配置行为)。

group_behavior

dict

None

同组对象的群体行为配置,支持 orca

role

str

"obstacle"

对象在仿真中的角色。

color

str

'k'(黑色)

对象在仿真中的显示颜色。

static

bool

False

指示对象是否是静态的。

vel_min

float 列表

[-1] * action_dim

各控制维度的最小速度限制。长度与运动学动作维度匹配。

vel_max

float 列表

[1] * action_dim

各控制维度的最大速度限制。长度与运动学动作维度匹配。

acce

float 列表

[inf] * action_dim

加速度限制。长度与运动学动作维度匹配。

angle_range

float 列表

[-pi, pi]

朝向角的弧度范围。

goal_threshold

float

0.1

判定到达目标的距离阈值。

sensors

dict 列表

None

List of sensor configurations attached to the object. Support name: lidar2d, fmcw_lidar2d

arrive_mode

str

'position'

到达检测模式。

description

str

None

对象的图像描述或标签。

group

int

0

用于组织的分组 ID,使对象可以按组管理。

group_name

str

None

用于组织的分组名称,使对象能够按组名进行管理。

unobstructed

bool

False

指示对象是否忽略碰撞。

plot

dict

{}

对象可视化的绘图选项。

state_dim

int

None

状态向量维度。

vel_dim

int

None

速度向量维度。

fov

float

None

对象传感器的视场角(弧度)。

fov_radius

float

None

对象传感器的视场半径。

参数详解#

object 属性
概述
  • number — 创建多少个对象

  • distribution — 对象摆放位置分布 (manual, random, circle)

  • state — 初始化位置 ([x, y, θ])

  • goal — 目标位姿 ([x, y, θ])

  • velocity — 初始化速度 ([v, ω], [forward, lateral], [v, φ])

  • state_dim — 状态向量维度 (auto: 3 或 4)

  • vel_dim — 速度向量维度 (auto: 2)

  • name — 对象的唯一标识符

  • role — 对象类型(robotobstacle

number (int, 默认值: 1)

指定使用该配置创建的对象数量。

# Example usage
robot:
  - number: 5
distributiondict,默认值:{name: manual})(源码

number大于1时,定义多个对象在空间中的分布方式。

选项:

  • 'manual':手动为每个对象指定初始状态和目标

    • 这种模式下必须为每个对象提供state(或目标)参数;如果提供的列表长度少于对象数量,则最后一个状态(或目标)会被重复使用。

    # Example usage
    distribution: {name: 'manual'}
    state: [[1, 1, 0], [2, 2, 0], [3, 3, 0]]
    goal: [[9, 9, 0], [8, 8, 0], [7, 7, 0]]
    
  • 'random': 在指定范围内随机分布对象。采样过程采用拒绝采样,保证任意两点在 xy 平面上的距离至少为 min_distance。可选参数:

    • range_low (list): 随机分布的下界 [x, y, theta]。默认值为世界边界向内缩进 0.5,即 [offset_x + 0.5, offset_y + 0.5, -pi]

    • range_high (list): 随机分布的上界 [x, y, theta]。默认值为 [offset_x + width - 0.5, offset_y + height - 0.5, pi]

    • min_distance (float): 采样点之间在 xy 平面上的最小两两距离。默认值为 1.0

    # Example usage
    distribution: {name: 'random', range_low: [0.5, 0.5, -3.14], range_high: [9.5, 9.5, 3.14], min_distance: 1.0}
    
  • 'circle':将对象以圆形阵列排布在指定中心周围。可选参数:

    • center (list): 圆心坐标 [x, y, theta]。默认值为世界中心 [offset_x + width / 2, offset_y + height / 2, 0]

    • radius (float): 圆的半径。默认值为 min(width, height) / 2 - 0.5,使圆形排布留有少量边距。

    # Example usage
    distribution: {name: 'circle', center: [5, 5, 0], radius: 4.0}
    
state (float列表, 默认为[0, 0, 0])

定义对象的初始状态,通常为 [x, y, theta] 格式,其中 theta 表示以弧度为单位的朝向。若提供的状态元素多于所需,多余的会被截断;若不足,缺失值以零补齐。

# Example usage
state: [1.0, 1.0, 0.2]
velocityfloat 列表,默认:[0] * action_dim

指定对象的初始速度(列表)。长度须与运动学动作维度匹配。格式取决于运动学模型:

运动学模型的格式:

  • 'diff'模型参数由[v, omega]构成, 其中 v 线速度,omega角速度。

  • 'omni'模型参数由[forward, lateral]构成,为机体坐标系下的速度(相对于朝向的前进和横向速度)。

  • 'acker'模型参数通常由[v, phi]构成,其中 v 是线速度,phi是转向角。

# Example usage
velocity: [1.0, 0.5]
goal (float 列表或 float 列表的列表,默认值:None)

设置对象应移动到的目标状态或位置。与行为配合使用以引导对象导航。格式为 [x, y, theta],或多目标时为 [[x, y, theta], [x, y, theta], ...]

# Example usage - single goal
goal: [10.0, 10.0, 0.2]

注意:对于单个对象的多个目标(注意区分多个对象的单个目标与单个对象的多个目标):

# Example usage - multiple goals
goal: 
  - [[10.0, 10.0, 0.2], [5.0, 4.0, 1.0], [3.0, 3.0, 2.0]]
state_dim (int, 默认值: None)

显式定义状态向量的维度。若未指定,则自动从运动学模型推断。对于大多数使用场景,默认推断即可满足需求。

常用值:

  • 3: 2D的位置和朝向角 [x, y, theta]

  • 4:对于具有额外状态的车辆(例如 Ackermann 模型的[x, y, theta, steer_angle]

# Example usage
state_dim: 3
vel_dim (int, 默认值: None)

显式定义速度向量的维度。若未指定,则自动从运动学模型推断。速度维度取决于特定运动学模型的控制输入。

常用值:

  • 2:对于差速驱动[v, omega]或全向 [forward, lateral]

  • 3:对于带角速度控制的全向模型 [forward, lateral, yaw_rate]

# Example usage
vel_dim: 2
groupint,默认 0

指定用于组织目的的分组标识符,允许对象被分类和管理。具有相同分组 ID 的对象可作为一个整体用于某些操作。

# Example usage
group: 1
group_name (str, 默认值为: None)

用于组织目的指定分组名称,使对象能够被分类并统一管理。具有相同分组名称的对象在某些操作中可作为一个整体进行处理。

# Example usage
group_name: "robot_flow"
namestrstr 列表,默认 None

为对象设置唯一标识符。若未提供,名称默认为 "_"(例如 robot_0obstacle_3)。名称在环境中所有对象间必须唯一;重复会在初始化时抛出 ValueError

  • 创建多个对象(number > 1)时,可提供名称列表。若列表长度小于对象数量,则最后一个名称会被重复使用;请确保名称唯一性以避免错误。

# Example usage - single object
robot:
  - name: "r1"
    kinematics: {name: 'diff'}
    shape: {name: 'circle', radius: 0.2}
    state: [1, 1, 0]
    goal: [9, 9, 0]
# Example usage - multiple objects with explicit names
robot:
  - number: 3
    name: ["r1", "r2", "r3"]
    distribution: {name: 'circle', center: [5, 5, 0], radius: 4.0}
    kinematics: {name: 'diff'}
    shape: {name: 'circle', radius: 0.2}

备注

请勿将对象级 nameshapekinematicsbehavior 等字典内部的 name 键混淆。后者指定该组件的类型,而非对象的标识符。

role (str, 默认值: 'obstacle')

定义对象在仿真中的角色,由其所属的配置区块决定:

  • 'robot':主动实体,通常由行为或输入命令控制。

  • 'obstacle':被动实体,可静止也可移动,但参与碰撞检测。

object 运动学
运动学模型
  • diff — 差速驱动,由线速度和角速度控制([v, omega]

  • omni — 全向移动,由机体坐标系下的前进和横向速度控制([forward, lateral]

  • omni_angular — 带角速度控制的全向移动,由机体坐标系下的速度和偏航角速度控制([forward, lateral, yaw_rate]

  • acker — 阿克曼转向,由线速度和转向角控制([v, phi]

kinematicsdict,默认 None

设置控制对象运动的运动学模型。

选项:

  • 'diff':差速驱动机器人,适用于原地旋转的机器人(如两轮机器人)。通过线速度和角速度控制。可选参数:

    • noise(bool):是否给速度命令添加噪声。默认为 False

    • alpha(列表):速度命令的噪声参数。默认值为 [0.03, 0, 0, 0.03]

    # Example usage
    kinematics: {name: 'diff', noise: True, alpha: [0.03, 0, 0, 0.03]}
    
  • 'omni':全向运动,允许在任意方向移动而不改变朝向。此类机器人通过机体坐标系速度 [forward, lateral] 控制。朝向角(theta)保持不变。可选参数:

    • noise(bool):是否给速度命令添加噪声。默认为 False

    • alpha(列表):速度命令的噪声参数 [alpha_forward, alpha_lateral]。默认值为 [0.03, 0.03]

    # Example usage
    kinematics: {name: 'omni', noise: True, alpha: [0.03, 0.03]}
    
  • 'omni_angular':带角速度控制的全向运动。在 omni 基础上增加偏航角速度通道以积分朝向角(theta)。此类机器人通过机体坐标系速度 [forward, lateral, yaw_rate] 控制。可选参数:

    • noise(bool):是否给速度命令添加噪声。默认为 False

    • alpha(列表):速度命令的噪声参数 [alpha_forward, alpha_lateral, alpha_yaw]。默认值为 [0.03, 0.03, 0.03]

    # Example usage
    kinematics: {name: 'omni_angular', noise: True, alpha: [0.03, 0.03, 0.03]}
    
  • 'acker':阿克曼转向,典型用于类车辆,需要转向半径。

    • noise(bool):是否给速度命令添加噪声。默认为 False

    • alpha(列表):速度命令的噪声参数。默认值为 [0.03, 0, 0, 0.03]

    • mode(str):转向模式,为 steerangular。默认为 steer

      • steer:对象通过线速度和转向角控制。

      • angular:对象通过线速度和角速度控制。

    # Example usage
    kinematics: {name: 'acker', noise: True, alpha: [0.03, 0, 0, 0.03], mode: 'steer'}
    
vel_minfloat 列表,默认值:[-1, -1])和 vel_maxfloat 列表,默认值:[1, 1]

设置每个控制维度的最小和最大速度限制(例如线速度和角速度)。这些约束确保对象的运动保持在可行且安全的范围内。

accefloat 列表,默认值:[inf, inf]

定义加速度限制,即每个控制维度在每个时间步内的最大速度变化。此参数模拟对象运动能力的物理限制。

angle_rangefloat 列表,默认:[-pi, pi]

指定允许的朝向角范围 [min, max](弧度)。对象的朝向角 theta 会被归整到此范围内以保持一致性。

goal_thresholdfloat,默认:0.1

确定对象被认为已到达目标的距离阈值。一旦在此距离范围内,可能会触发到达行为或状态变化。

# Example usage
vel_min: [-1, -1]
vel_max: [1, 1]
acce: [0.5, 0.1]
angle_range: [-pi, pi]
goal_threshold: 0.1

警告

使用 acker 运动学模型时,请确保在 shape 配置中设置 wheelbase 参数。

object 形状
概述
  • circle — 圆形(radiuscenter

  • rectangle — 矩形(lengthwidthwheelbase

  • polygon — 自定义多边形(verticesis_convex

  • linestring — 线段(vertices

shapedict,默认 {name: circle}

Determines the geometric shape used for collision detection and visualization in the original state. If shape is omitted entirely, the object falls back to a circle of radius: 1 centered at [0, 0]; the radius: 0.2 below is the default only when a circle shape is given without an explicit radius.

支持的形状:

  • 'circle':圆形。

    • radiusfloat):圆半径,默认 0.2

    • center(列表):圆心 (x, y),默认 [0, 0]

    • random_shapebool):是否随机半径,默认 False

    • radius_rangelist):当 random_shapeTrue 时用于随机半径生成的范围 [min_radius, max_radius]。默认值为 [0.1, 1.0]

    • wheelbasefloat):阿克曼转向车辆的轴距,使用 'acker' 时必填,默认 None

    # Example usage
    shape: {name: 'circle', radius: 0.2, center: [0, 0]}
    
  • 'rectangle':矩形。

    • lengthfloat):x 轴方向长度,默认 1.0

    • widthfloat):y 轴方向宽度,默认 1.0

    • wheelbasefloat):阿克曼转向车辆的轴距,使用 'acker' 时必填,默认 None

    # Example usage
    shape: {name: 'rectangle', length: 1.0, width: 0.5}
    
  • 'polygon':由顶点列表定义的多边形。

    • vertices(列表):定义多边形的顶点列表,格式 [[x1, y1], ...]。若未提供则生成随机多边形。

    • random_shapebool):是否生成一系列随机多边形,默认 False

    • is_convexbool):是否生成一系列随机凸多边形,默认 False

    • 随机多边形生成的参数,更多细节参见 random_generate_polygon()。参数包括 number center_range avg_radius_range irregularity_range spikeyness_range num_vertices_range

    # Example usage
    shape:
      name: 'polygon'
      vertices: 
        - [4.5, 4.5]
        - [5.5, 4.5]
        - [5.5, 5.5]
        - [4.5, 5.5]
    
    # Example usage - random polygon
    shape:
      - {name: 'polygon', random_shape: true, center_range: [5, 10, 40, 30], avg_radius_range: [0.5, 2], irregularity_range: [0, 1], spikeyness_range: [0, 1], num_vertices_range: [4, 5]} 
    
  • 'linestring':由顶点列表定义的折线,类似多边形但生成的是一串线。

    • vertices(列表):定义线串的顶点列表,格式 [[x1, y1], ...]

    • random_shapebool):是否生成随机线串(多边形),默认 False

    • is_convexbool):是否生成随机凸线串(多边形),默认 True

    • 随机折线(多边形)生成的参数,更多细节参见 random_generate_polygon()。参数包括 number center_range avg_radius_range irregularity_range spikeyness_range num_vertices_range

    # Example usage
    shape:
      name: 'linestring'
      vertices: 
        - [4.5, 4.5]
        - [5.5, 4.5]
        - [5.5, 5.5]
        - [4.5, 5.5]
    
    # Example usage - random linestring
    shape:
      - {name: 'linestring', random_shape: true, center_range: [5, 10, 40, 30], avg_radius_range: [0.5, 2], irregularity_range: [0, 1], spikeyness_range: [0, 1], num_vertices_range: [4, 5]} 
    
object 行为
行为系统
  • behaviordash(直接朝目标移动)、rvo(碰撞避让算法)

  • group_behaviororca(最优互惠碰撞避免)

  • static — 静止对象(True/False

behaviordict,默认 None

配置对象的运动行为,可为简单或复杂策略,并可包含额外参数。

选项:

  • 'dash':以最大允许速度直接朝目标移动。

    • wander(bool/False):是否加入随机游走。若为 True,对象到达当前目标后会随机分配新目标。

    • loop(bool/False):是否循环导航路径点。若为 True,对象到达最后一个路径点后会从第一个路径点重新开始。

    • target_roles(str/all):仅对具有目标角色的对象应用该行为。当前可设为 robotobstacle

    • range_low(列表):随机游走下界,默认 [0, 0, -3.14]

    • range_high(列表):随机游走上界,默认 [10, 10, 3.14]

    • angle_tolerance(float):diffackeromni_angular 运动学的朝向校准容差,默认 0.1

    示例:

    behavior: {name: 'dash', wander: True, range_low: [0, 0, -3.14], range_high: [10, 10, 3.14], angle_tolerance: 0.1}
    
  • 'rvo':实现多动态体避碰的 RVO 算法,支持 diffomni 运动学。

    • wander(bool/False):是否加入随机游走。若为 True,对象到达当前目标后会随机分配新目标。

    • loop(bool/False):是否循环导航路径点。若为 True,对象到达最后一个路径点后会从第一个路径点重新开始。

    • target_roles(str/all):仅对具有目标角色的对象应用该行为。当前可设为 robotobstacle

    • range_low(列表):随机游走下界,默认 [0, 0, -3.14]

    • range_high(列表):随机游走上界,默认 [10, 10, 3.14]

    • vxmax(float):x 轴最大线速度,默认 1.5

    • vymax(float):y 轴最大线速度,默认 1.5

    • acce(float):最大加速度,默认 1.0

    • factor(float):RVO 算法因子,默认 1.0

    • mode(str):RVO 算法模式,可选 rvohrvovo,默认 rvo

      • rvo:互惠速度障碍法,用于多智能体避碰。

      • hrvo:混合 RVO,将 RVO 与 VO 结合以减少死锁。

      • vo:速度障碍,用于避障。

    • neighbor_threshold(float):筛选邻居的距离阈值,默认 3.0

    示例:

    behavior: {name: 'rvo', vxmax: 1.5, vymax: 1.5, acce: 1.0, factor: 1.0, mode: 'rvo', wander: False}
    
group_behaviordict,默认 None

同组内所有对象的群体行为。对于协同行为(如群体或人群仿真)更高效,因为它在单步中为所有成员计算动作。必须包含 name 及行为特定参数。

选项:

  • 'orca':用于多智能体导航的最优互惠碰撞避免(ORCA)。需要 pyrvo 包(pip install pyrvo)。仅在使用该行为时仿真才会尝试导入它。

    • wander(bool/False):是否加入随机游走。若为 True,对象到达当前目标后会随机分配新目标。

    • range_low(列表):随机游走下界,默认 [0, 0, -3.14]

    • range_high(列表):随机游走上界,默认 [10, 10, 3.14]

    • neighborDist(float/15.0):搜索邻居的最大距离。

    • maxNeighbors(int/10):考虑的邻居数量上限。

    • timeHorizon(float/20.0):相对于其他智能体计算安全速度的时间范围。

    • timeHorizonObst(float/10.0):相对于静态障碍物计算安全速度的时间范围。

    • safe_radius(float/0.1):额外的安全半径填充。

    • maxSpeed(float/None):智能体最大速度。若为 None,使用对象的 vel_max

    示例:

    group_behavior: 
      name: 'orca'
      neighborDist: 10.0
      maxNeighbors: 10
      timeHorizon: 10.0
      timeHorizonObst: 10.0
      safe_radius: 0.1
    

static:布尔值,表示对象是否静止。静止对象忽略运动学与行为,保持初始状态。

示例:

static: True
object 传感器
概述
  • lidar2d — 2D 激光雷达(range_min/maxangle_rangenoise

  • fmcw_lidar2d — 2D FMCW LiDAR (range/radial_velocity, motion_compensate, Doppler visualization)

  • fov — 视场角(弧度)

  • fov_radius — 最大探测距离

sensors:为对象挂载传感器以感知环境。每个传感器以字典形式描述其类型与参数,目前支持:

  • lidar2d:用于距离测量的 2D LiDAR,参数包括:

    • range_min(float):最小探测距离,默认 0.0

    • range_max(float):最大探测距离,默认 10.0

    • angle_range(float):传感器覆盖角度,默认 pi

    • number(int):激光束数量,默认 100

    • scan_time(float):完成一次扫描的时间,默认 0.1

    • noise(bool):测量是否加入噪声,默认 False

    • std(float):当 noise=True 时距离噪声的标准差,默认 0.2

    • angle_std(float):noise=True 时的角度噪声标准差,默认 0.02

    • offset(列表):传感器相对对象位置 (x, y, theta) 的偏移,默认 [0, 0, 0]

    • has_velocity(bool):是否测量点速度,默认 False

    Visualization options go under the sensor's plot: sub-dict (flat top-level keys are still accepted for backward compatibility):

    • alpha(float):绘图透明度,默认 0.3

    • color(str):传感器颜色,默认 r

    示例:

    sensors:
      - name: 'lidar2d'
        range_min: 0
        range_max: 5
        angle_range: 3.14 
        number: 200
        noise: False
        std: 0.2
        angle_std: 0.2
        offset: [0, 0, 0]
        plot:
          alpha: 0.3
    
  • fmcw_lidar2d: Simplified 2D FMCW LiDAR for range and radial Doppler measurements. It reuses the beam geometry of lidar2d and adds two functional parameters:

    • motion_compensate (bool/False): Whether to remove ego-motion from the measured radial velocity.

    • velocity_noise_std (float/0.0): Standard deviation of Gaussian noise on radial velocity.

    All visualization options go under the sensor's plot: sub-dict (same convention as lidar2d and object plot:). Flat top-level keys are still accepted for backward compatibility.

    • velocity_color (bool/True): Whether to color valid beams by radial velocity.

    • velocity_color_max (float/2.0): Velocity magnitude where the plotting color saturates.

    • velocity_linewidth (float/2.5): Plot line width for valid returns.

    • no_hit_linewidth (float/0.8): Plot line width for invalid beams.

    • no_hit_alpha (float/0.03): Plot transparency for invalid beams.

    • show_velocity_markers (bool/True): Whether to draw colored hit markers at valid endpoints.

    • velocity_marker_size (float/36): Plot marker size for valid endpoints.

    • velocity_marker_edge_color (str/black): Edge color of the endpoint markers.

    • velocity_marker_edge_width (float/0.6): Edge width of the endpoint markers.

    • zero_velocity_color (str/cyan): Plot color used for near-zero radial velocity.

    • positive_velocity_color (str/crimson): Plot color used for positive radial velocity.

    • negative_velocity_color (str/royalblue): Plot color used for negative radial velocity.

    • no_hit_color (str/lightgray): Plot color used for invalid beams.

    The scan output adds radial_velocity and valid arrays on top of the standard LiDAR angular metadata.

    示例:

    sensors:
      - type: 'fmcw_lidar2d'
        range_min: 0.0
        range_max: 8.0
        angle_range: 2.0944
        number: 121
        motion_compensate: False
        plot:
          velocity_color: True
          velocity_linewidth: 2.0
          velocity_marker_size: 45
    

fovfov_radius:定义对象传感器的视场(FOV)。FOV 是传感器可检测对象的角度范围。fov 参数以弧度指定角度范围,fov_radius 设置最大检测距离。

示例:

fov: 1.57
fov_radius: 5.0
object 模式
概述
  • arrive_mode — 目标判定方式(positionstate

  • unobstructed — 忽略碰撞(True/False

arrive_modestr,默认 'position'

选择判定对象是否到达目标的方法:

选项:

  • 'position':仅根据与目标位置 ([x, y]) 的距离判断。

  • 'state':同时考虑位置与朝向 ([x, y, theta])。

示例:

arrive_mode: 'position'
unobstructedbool,默认 False

当设为 True 时,该对象被视为无障碍,忽略与其他对象和障碍物的碰撞,适合测试或需要不被阻挡的对象。

示例:

unobstructed: True
object 可视化
概述
  • color — 对象颜色('r''blue''k' 等)

  • description — 图像文件(如 'car_blue.png''diff_robot0.png'

  • plot — 进阶显示选项

    • Object — 外观(obj_colorobj_alphaobj_linestyle

    • Goal — 目标标记(show_goalgoal_colorshow_goal_text

    • Trail — 轨迹点(show_trailkeep_trail_length

    • Trajectory — 路径线(show_trajectorykeep_traj_length

    • Sensors — 传感器显示(show_sensorshow_fov

colorstr,默认 'k' 黑色)

指定对象在可视化中的颜色以便于识别。详细的颜色选项见 matplotlib 颜色

示例:

color: 'r'
descriptionstr,默认 None

提供用于图形展示的图像,可使用 world/description 下的文件,或自定义绝对路径。

可用图像:

  • car_green.png:阿克曼车辆默认图。

  • car_blue.png

  • car_red.png

  • diff_robot0.png

  • diff_robot1.png

示例:

description: 'car_blue.png'

plot:包含控制对象显示的绘图选项。所有绘图元素初始创建在原点,并在动画更新时通过变换与数据更新定位。

对象可视化属性:

  • obj_linestyle(str):对象轮廓线型(如 '-', '--', ':', '-.'),默认 '-'.

  • obj_zorder(int):对象元素的绘制层级,机器人默认 3、障碍物默认 1。

  • obj_color(str):对象颜色,默认沿用 color

  • obj_alpha(float):对象透明度(0.0-1.0),默认 1.0。

  • obj_linewidth(float):轮廓线宽,默认随对象类型而定。

目标可视化:

  • show_goal(bool):是否显示目标位置,默认 False。

    • goal_color(str):目标标记颜色,默认与对象一致。

    • goal_alpha(float):目标透明度,默认 0.5。

    • goal_zorder(int):目标层级,默认 1。

  • show_goal_text(bool):是否显示目标位置的文本,默认 False。

文本标签可视化:

  • show_text(bool):是否显示文本信息,默认 False。默认显示对象缩写(如 r0o1)。可在运行时通过 object.set_text("自定义文本") 设置自定义文本。传入 None 可重置为默认缩写。

    • text_color(str):文本颜色,默认 'k'(黑)。

    • text_size(int):字体大小,默认 10。

    • text_alpha(float):文本透明度,默认 1.0。

    • text_zorder(int):文本层级,默认 2。

    • text_position(列表):相对对象中心的偏移 [dx, dy],默认 [-radius-0.1, radius+0.1]

同样,目标文本可通过 object.set_goal_text("自定义目标文本") 进行自定义。

速度箭头可视化:

  • show_arrow(bool):是否显示速度箭头,默认 False。

    • arrow_color(str):箭头颜色,默认 "gold"。

    • arrow_length(float):箭头长度,默认 0.4。

    • arrow_width(float):箭头宽度,默认 0.6。

    • arrow_alpha(float):箭头透明度,默认 1.0。

    • arrow_zorder(int):箭头层级,默认 4。

轨迹线可视化:

  • show_trajectory(bool):是否显示路径线,默认 False。

    • traj_color(str):路径颜色,默认继承对象颜色。

    • traj_style(str):路径线型(如 '-', '--', ':', '-.'),默认 "-"。

    • traj_width(float):路径线宽,默认为对象宽度。

    • traj_alpha(float):路径透明度,默认 0.5。

    • traj_zorder(int):路径层级,默认 0。

    • keep_traj_length(int):保留的尾段步数,默认 0(保留全部)。

对象轨迹点可视化:

  • show_trail(bool):是否显示轨迹点,默认 False。

    • trail_freq(int):轨迹显示频率(每 N 步),默认 2。

    • trail_type(str):轨迹形状类型,默认与对象形状相同。

    • trail_edgecolor(str):轨迹边缘颜色,默认为对象颜色。

    • trail_linewidth(float):轨迹线宽,默认 0.8。

    • trail_alpha(float):轨迹透明度,默认 0.7。

    • trail_fill(bool):是否填充轨迹形状,默认 False。

    • trail_color(str):轨迹填充色,默认为对象颜色。

    • trail_zorder(int):轨迹层级,默认 0。

    • keep_trail_length(int):保留的轨迹尾段步数,默认 0(保留全部)。

传感器可视化:

  • show_sensor(bool):是否显示传感器,默认 True。

视场可视化:

  • show_fov(bool):是否显示视场,默认 False。

    • fov_color(str):视场填充色,默认 "lightblue"。

    • fov_edge_color(str):视场边缘色,默认 "blue"。

    • fov_alpha(float):视场透明度,默认 0.5。

    • fov_zorder(int):视场层级,默认 1。

注意: 所有可视化元素在初始化时创建于原点,并在动画期间通过 matplotlib 的变换(patch)与 set_data(线)定位。

示例:

plot:
  # Object appearance
  obj_linestyle: '--'
  obj_zorder: 3
  obj_color: 'blue'
  obj_alpha: 0.8
  obj_linewidth: 2.0
  
  # Goal visualization
  show_goal: True
  goal_color: 'red'
  goal_alpha: 0.7
  goal_zorder: 2
  
  # Text labels
  show_text: True
  text_color: 'black'
  text_size: 12
  text_alpha: 0.9
  text_zorder: 5
  
  # Velocity arrows
  show_arrow: True
  arrow_color: 'gold'
  arrow_length: 0.5
  arrow_width: 0.8
  arrow_alpha: 0.9
  arrow_zorder: 4
  
  # Trajectory path
  show_trajectory: True
  traj_color: 'green'
  traj_style: '-'
  traj_width: 0.6
  traj_alpha: 0.6
  traj_zorder: 1
  
  # Object trails
  show_trail: True
  trail_freq: 3
  trail_edgecolor: 'purple'
  trail_linewidth: 1.0
  trail_alpha: 0.5
  trail_fill: False
  trail_color: 'purple'
  trail_zorder: 0
  
  # Sensors and FOV
  show_sensor: True
  show_fov: True
  fov_color: 'lightblue'
  fov_edge_color: 'blue'
  fov_alpha: 0.3
  fov_zorder: 1

GUI 配置#

GUI 参数表#

Parameter

类型

默认值

描述

keyboard

dict

{}

键盘控制选项(当 world.control_mode: keyboard 时生效)。

mouse

dict

{}

鼠标控制选项。

键盘控制

keyboarddict,默认值:{})配置键盘控制。选项由 KeyboardControl 读取。默认后端为 pynput。若 pynput 不可用,IR‑SIM 会自动回退到 Matplotlib 后端。

  • backendstr):键盘后端。

    • "pynput"(默认):全局键盘hook,但需 Matplotlib 窗口聚焦(依赖 pynput 包)。

    • "mpl":Matplotlib 图窗按键事件,仅在窗口聚焦时生效;无额外依赖,但对象数量多时可能有延迟。

  • global_hookbool/False):当 backend: 'pynput' 时,即使 Matplotlib 窗口未获得焦点也捕获按键。(仅在窗口获得焦点时生效)。

  • key_lv_maxfloat):最大线速度,默认 3.0。

  • key_ang_maxfloat):最大角速度,默认 1.0。

  • key_lvfloat):初始线速度,默认 0.0

  • key_angfloat):初始角速度,默认 0.0

  • key_rotfloat):初始旋转速度(omni_angular 运动学下的偏航角速度),默认 0.0

  • key_idint):初始机器人控制 ID,默认 0

# Example: enable keyboard control with GUI settings
world:
  control_mode: 'keyboard'

gui:
  keyboard:
    backend: 'pynput'     # or 'mpl'
    global_hook: true     # if your want to capture keys globally. Default is False.
    key_id: 0
    key_lv_max: 3.0
    key_ang_max: 1.0

键盘控制按键:

  • w — 前进

  • s — 后退

  • a — 左转(diff/acker)或左侧平移(omni/omni_angular

  • d — 右转(diff/acker)或右侧平移(omni/omni_angular

  • q — 左旋转(omni_angular 的偏航角速度)

  • e — 右旋转(omni_angular 的偏航角速度)

  • z / c — 降低 / 提高最大角速度(key_ang_max

  • shift+z / shift+c — 降低 / 提高最大线速度(key_lv_max

  • alt+num — 更改当前控制的机器人ID

  • r — 重置环境

  • space — 切换暂停/恢复环境

  • esc — 退出环境(设置退出标志)

  • x — 切换键盘/自动控制

  • l — 重新加载环境

  • F5 — 调试环境(Mac上使用fn+f5)

  • v — 保存当前图像

  • y — 切换显示渲染窗口

小技巧

调试模式可逐帧推进仿真以便检查:

  • F5 在当前帧进入调试模式,再次按下 F5 进入单步。

  • space 退出调试模式并恢复正常执行。

注意:

  • 在 macOS 笔记本上可能需要配合 fn 键(如 fn+F5)。alt 键对应 option

鼠标控制

mousedict,默认 {}):配置鼠标控制,由 MouseControl 读取。

  • zoom_factorfloat):缩放因子,默认 1.1

gui:
  mouse:
    zoom_factor: 1.1

备注

鼠标操作:

  • 鼠标移动 — 跟踪鼠标位置并更新显示坐标

  • 中键点击 — 重置缩放到默认视图

  • 滚轮向上 — 放大(以鼠标位置为中心)

  • 滚轮向下 — 缩小(以鼠标位置为中心)

鼠标位置属性:

  • left_click_postuple):左键点击位置 (x, y)。

  • right_click_postuple):右键点击位置 (x, y)。

  • mouse_postuple):当前鼠标位置 (x, y)。


配置示例#

下面通过多个配置示例展示 IR-SIM 的灵活性与能力:

robot:
  - number: 10
    distribution: {name: 'circle', radius: 4.0, center: [5, 5]}  
    kinematics: {name: 'diff'}
    shape: 
      - {name: 'circle', radius: 0.2}  
    behavior: {name: 'rvo', vxmax: 1.5, vymax: 1.5, acce: 1.0, factor: 1.0}
    vel_min: [-3, -3.0]
    vel_max: [3, 3.0]
    color: ['royalblue', 'red', 'green', 'orange', 'purple', 'yellow', 'cyan', 'magenta', 'lime', 'pink', 'brown'] 
    arrive_mode: position
    goal_threshold: 0.15
    plot:
      show_trail: true
      show_goal: true
      trail_fill: true
      trail_alpha: 0.2
      show_trajectory: false
robot:
  - number: 10
    distribution: {name: 'circle', radius: 4.0, center: [5, 5]}
    kinematics: {name: 'omni'}
    shape: {name: 'circle', radius: 0.2}
    group_behavior: 
      name: 'orca'
      neighborDist: 10.0
      maxNeighbors: 10
      timeHorizon: 10.0
      timeHorizonObst: 10.0
      safe_radius: 0.1
    vel_max: [2.0, 2.0]
    goal: [9, 9, 0]
    plot:
      show_trail: true
      trail_alpha: 0.5
obstacle:
  - shape: {name: 'circle', radius: 1.0}  # radius
    state: [5, 5, 0]  
  
  - shape: {name: 'rectangle', length: 1.5, width: 1.2}  # radius
    state: [6, 5, 1] 

  - shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] }  # vertices
    state: [0, 0, 0] 
    unobstructed: True

  - shape:
      name: 'polygon'
      vertices: 
        - [4.5, 4.5]
        - [5.5, 4.5]
        - [5.5, 5.5]
        - [4.5, 5.5]
robot:  
  - kinematics: {name: 'acker'}  
    shape: {name: 'rectangle', length: 4.6, width: 1.6, wheelbase: 3}
    state: [1, 1, 0, 0]
    goal: [40, 40, 0]
    vel_max: [4, 1]
    behavior: {name: 'dash'}
    plot:
      show_trajectory: True
robot:
  - kinematics: {name: 'omni_angular'}
    shape: {name: 'circle', radius: 0.2}
    state: [2, 2, 0]
    goal: [8, 8, 0]
    velocity: [0, 0, 0]
    vel_min: [-1, -1, -1]
    vel_max: [1, 1, 1]
    behavior: {name: 'dash'}
    plot:
      show_trajectory: True
robot:
  - kinematics: {name: 'diff'}
    shape: {name: 'circle', radius: 0.3}
    state: [2, 2, 0]
    goal: [8, 8, 0]
    behavior: {name: 'rvo'}
    sensors:
      - name: 'lidar2d'
        range_min: 0.1
        range_max: 8.0
        angle_range: 6.28  # Full 360 degrees
        number: 360
        noise: True
        std: 0.1
        offset: [0, 0, 0]
        color: 'red'
    plot:
      show_sensor: True
      show_fov: True
      fov_color: 'lightgreen'
      fov_alpha: 0.3

小技巧

配置最佳实践:

  • 多个对象:配置多个对象时,使用 numberdistribution 参数可高效地生成它们。例如,设置 number: 10 并使用 'random'distribution,可快速在仿真中随机放置大量对象。

  • 字典参数:所有字典类型的参数(如 distributionshapekinematicsbehavior)都必须包含 'name' 键以指定其类型。省略 'name' 键会导致使用默认值或报错。

  • 分组配置:同组对象默认共享配置。若需定制,请使用 - 添加子参数;未显式配置的对象会继承组内最后一个配置。

  • 运动学与速度:确保 velocityvel_max 的格式与运动学模型匹配,例如差速 ('diff') 使用 [v, omega],全向 ('omni') 使用机体坐标系 [forward, lateral]'omni_angular' 使用 [forward, lateral, yaw_rate]

  • 绘图选项:若 plot 位于对象配置内部,可为单个对象定制可视化;若位于对象配置的根级,则应用于所有对象。