目录
3、turtlebot_in_stage.launch 文件内容
源码位于:turtlebot_simulator/turtlebot_stage
1、stage介绍
Stage是Player/Stage项目的一个软件,是一种用于移动机器人和智能传感系统研究的仿真工具。
Stage在一个二维的位图环境下模拟移动机器人、传感器和障碍物等对象。
Stage在设计中就考虑到了多智能体系统的问题,可以提供对多机器人系统的测试仿真。需要了解的是Stage只提供了真正简单,可计算的廉价的设备模式,而无法非常精密地仿真任何具体的设备终端。
Stage 还允许你利用目前还没有的虚拟机器人设备进行实验。
Stage提供了多种传感器和执行器,包括声纳,激光扫描测距仪,色斑显示器,里程计,抓斗,防撞器/触须器以及移动机器人基坐等。
2、启动turtlebot stage仿真程序
(indigo版本支持,kinetic版本没有跑通)
打开命令终端,输入一下命令:
roslaunch turtlebot_stage turtlebot_in_stage.launch
turtlebot_stage 导航仿真分别启动了以下ros包:
- stage 仿真世界环境发布各种TF坐标关系,odom、base_scan等仿真数据
- map_server 地图服务,加载其提供的仿真世界的地图
- move_base 导航功能包,接收其他包的数据实现导航功能,调用A*、DWA实现路径规划
- static map 静态地图
- amcl 激光定位程序,通过粒子滤波算法实现机器人的实时定位
- rviz view Rviz可视化显示机器人状态、传感器数据、导航路线、costmap、设定导航目标点
启动的窗口包括:
I、Stage的仿真世界:(相当于真实世界)
II、Rviz环境:(地图、turtlebot模型、算法运行的数据可视化)
III、左右轮TF连接状态:
3、turtlebot_in_stage.launch 文件内容
<!--
Turtlebot navigation simulation:
- stage
- map_server
- move_base
- static map
- amcl
- rviz view
-->
<launch>
<arg name="base" default="$(optenv TURTLEBOT_BASE kobuki)"/> <!-- create, rhoomba -->
<arg name="stacks" default="$(optenv TURTLEBOT_STACKS hexagons)"/> <!-- circles, hexagons -->
<arg name="3d_sensor" default="$(optenv TURTLEBOT_3D_SENSOR kinect)"/> <!-- kinect, asus_xtion_pro -->
<!-- Name of the map to use (without path nor extension) and initial position -->
<arg name="map_file" default=" $(env TURTLEBOT_STAGE_MAP_FILE)"/> <!-- robopark_plan -->
<arg name="world_file" default=" $(env TURTLEBOT_STAGE_WORLD_FILE)"/>
<arg name="initial_pose_x" default="2.0"/>
<arg name="initial_pose_y" default="2.0"/>
<arg name="initial_pose_a" default="0.0"/>
<param name="/use_sim_time" value="true"/>
<!-- ******************** Stage ******************** -->
<!--
Publishes transforms:
/base_link -> /base_laser
/base_footprint -> /base_link (identity)
/odom -> base_footprint
Publishes topics:
/odom : odometry data from the simulated odometry
/base_scan : laser data from the simulated laser
/base_pose_ground_truth : the ground truth pose
Parameters:
base_watchdog_timeout : time (s) after receiving the last command on cmd_vel before stopping the robot
Args:
-g : run in headless mode.
-->
<node pkg="stage_ros" type="stageros" name="stageros" args="$(arg world_file)">
<param name="base_watchdog_timeout" value="0.5"/>
<remap from="odom" to="odom"/>
<remap from="base_pose_ground_truth" to="base_pose_ground_truth"/>
<remap from="cmd_vel" to="mobile_base/commands/velocity"/>
<remap from="base_scan" to="scan"/>
</node>
<!-- ***************** Robot Model ***************** -->
<include file="$(find turtlebot_bringup)/launch/includes/robot.launch.xml">
<arg name="base" value="$(arg base)" />
<arg name="stacks" value="$(arg stacks)" />
<arg name="3d_sensor" value="$(arg 3d_sensor)" />
</include>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="use_gui" value="true"/>
</node>
<!-- Command Velocity multiplexer -->
<node pkg="nodelet" type="nodelet" name="mobile_base_nodelet_manager" args="manager"/>
<node pkg="nodelet" type="nodelet" name="cmd_vel_mux" args="load yocs_cmd_vel_mux/CmdVelMuxNodelet mobile_base_nodelet_manager">
<param name="yaml_cfg_file" value="$(find turtlebot_bringup)/param/mux.yaml"/>
<remap from="cmd_vel_mux/output" to="mobile_base/commands/velocity"/>
</node>
<!-- ************** Navigation *************** -->
<include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml"/>
<!-- ****** Maps ***** -->
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)">
<param name="frame_id" value="/map"/>
</node>
<include file="$(find turtlebot_navigation)/launch/includes/amcl/amcl.launch.xml">
<arg name="scan_topic" value="scan"/>
<arg name="use_map_topic" value="true"/>
<arg name="initial_pose_x" value="$(arg initial_pose_x)"/>
<arg name="initial_pose_y" value="$(arg initial_pose_y)"/>
<arg name="initial_pose_a" value="$(arg initial_pose_a)"/>
</include>
<!-- **************** Visualisation **************** -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find turtlebot_stage)/rviz/robot_navigation.rviz"/>
</launch>
4、设定目标位置,观看机器人自主导航过程
在rviz界面,点击菜单栏的【2D Nav Goal】 然后在图书中选择一个位置点击鼠标左键并拖到鼠标设定方向终点机器人的方向。
会发现机器人自动设定了全局路径,并启用DWA算法自动导航到设定的目标位置。