datetime:2025/12/21 16:00
author:nzb

配置机器人与障碍物

本节内容

  • 配置机器人与障碍物
    • 机器人配置参数
    • 障碍物配置参数
    • 多机器人/障碍物的高级配置

Python 脚本与 YAML 配置文件

import irsim

env = irsim.make('obstacles.yaml')

for i in range(1000):

    env.step()
    env.render(0.05)

    if env.done():
        break

env.end()
world:
  height: 10 
  width: 10   

robot:
  kinematics: {name: 'diff'}  
  shape: {name: 'circle', radius: 0.2}  
  state: [1, 1, 0]  
  goal: [9, 9, 0] 
  color: 'g'
  behavior: {name: 'dash'} # move toward the goal directly 
  plot:
    show_trajectory: True
    show_goal: True

obstacle:
  - shape: {name: 'circle', radius: 1.0}  # radius
    state: [5, 5, 0]  

  - shape: {name: 'rectangle', length: 1.5, width: 1.2}  # length, width
    state: [6, 5, 1] 

  - shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] }  # vertices
    state: [0, 0, 0] 
    unobstructed: True # 设为 True 时,该对象不参与碰撞检测。

  - shape:
      name: 'polygon'
      vertices: 
        - [4.5, 4.5]
        - [5.5, 4.5]
        - [5.5, 5.5]
        - [4.5, 5.5]
  • 多机器人/障碍物的高级配置
world:
  height: 10  # the height of the world
  width: 10   # the width of the world

robot:
  - number: 2
    distribution: {name: 'manual'}  # 参数用于控制机器人和障碍物的布局,可选 'manual' 或 'random' 或 'circle'。
    kinematics: {name: 'diff'}
    behavior: {name: 'dash'} # move toward the goal directly 
    shape: 
      - {name: 'circle', radius: 0.2}  # radius
    state: 
      - [1, 1, 0]  
      - [2, 1, 0]
    goal:
      - [9, 9, 0] 
      - [9, 2, 0]
    color: 
      - 'royalblue'
      - 'red'

  - number: 4
    distribution: {name: 'random'}
    kinematics: {name: 'diff'}
    behavior: {name: 'dash'} # move toward the goal directly 
    shape: 
      - {name: 'circle', radius: 0.2}  # radius
    color: 
      - 'pink'


obstacle:
  - number: 4
    distribution: {name: 'manual'}
    state: [[4, 8], [1, 3], [1, 0], [5, 2]]
    shape:
      - {name: 'circle', radius: 0.2}  # radius
      - {name: 'circle', radius: 0.1}  # radius
    color: 'k'

results matching ""

    No results matching ""