参考: pedsim文件介绍
项目地址: pedsim_ros
具体的如何编译测试在github上都有介绍。下面介绍如何在自己建立的环境中增加动态行人。
修改.world文件
在自己的world文件下加入以下代码块
<plugin name="ActorPosesPlugin" filename="libActorPosesPlugin.so">
</plugin>
修改后为:
<plugin name="ActorPosesPlugin" filename="libActorPosesPlugin.so">
</plugin>
</world>
</sdf>
修改仿真启动文件
github中提到,运行 pedsim_simulator中simple_pedestrains.launch文件,可以展示效果。因此,可以在该文件中加入move_base, acml等与navigation有关的节点启动项。即可在rviz中实现添加行人仿真以及导航等功能。
如何修改动态行人的位置,数量,运动路径
在simple_pedestrains.launch文件中有提到 scene_file 的参数,找到该xml文件位置打开。可以看到,其中主要的标签有 obstacle, waypoint, agent, addwaypoint四个。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Agent in shops and the robot passes by as well -->
<scenario>
<!--Obstacles-->
<obstacle x1="-2" y1="0" x2="-2" y2="30"/>
<obstacle x1="-2" y1="0" x2="2" y2="0"/>
<obstacle x1="2" y1="0" x2="2" y2="30"/>
<obstacle x1="-2" y1="30" x2="2" y2="30"/>
<!--Waypoints (incl. WaitingQueues)-->
<waypoint id="enter_bookshop" x="0" y="7.5" r="3"/>
<waypoint id="enter_starbucksky" x="0" y="10" r="3"/>
<!-- <queue id="info_desk" x="20" y="15" direction="0"/> -->
<waypoint id="leave_bookshop" x="0" y="1" r="3"/>
<waypoint id="leave_starbucksky" x="0" y="5" r="3"/>
<waypoint id="robot_goal" x="0" y="5" r="5"/>
<waypoint id="robot_start" x="4" y="4" r="2"/>
<!--Attractions-->
<attraction id="Bookshop" x="17" y="12" width="10" height="15" strength="50.0"/>
<!-- <attraction id="starbucksky" x="3" y="15" width="5" height="10" strength="2"/> -->
<!--Agents-->
<agent x="4" y="4" n="1" dx="0" dy="0" type="2">
<addwaypoint id="robot_start"/>
<addwaypoint id="robot_goal"/>
</agent>
<!--AgentClusters-->
<agent x="0" y="3" n="4" dx="0.1" dy="0.5" type="1">
<!-- <addqueue id="info_desk"/> -->
<addwaypoint id="leave_bookshop"/>
<addwaypoint id="robot_goal"/>
<addwaypoint id="enter_starbucksky"/>
<addwaypoint id="leave_starbucksky"/>
<addwaypoint id="enter_bookshop"/>
</agent>
</scenario>
其中obstacle是添加障碍物,也就是在rviz里的红色虚拟墙,就是x1, y1到 x2, y2这条直线。
waypoint 是 航点,就是运动到的位置,其要包括 id ,x y r 分别就是 位置以及半径r。
agent表示的是在哪个点出现人群。
以
<agent x="0" y="3" n="4" dx="0.1" dy="0.5" type="1">
为例。就是在(0,3)位置出现4个行人,出现的位置范围是x方向0.1的误差,y方向 0,5的误差
同时type表示人群类型,0,1,3表示的是adult,child elder。如果想要行人能够躲避机器人,同时机器人能够利用move_base导航。这里的type就需要设置为2。x,y对应初始点即可。
addwaypoint,就是沿着这几个点依次走。例子中就是 leave_bookshop, robot_goal, enter_startbucksky, leave_startbucksky, enter_bookshop。