天天看点

ROS Stage学习

首先看了wiki上的文档http://wiki.ros.org/stage_ros

介绍:

stageros 是一个2D的机器人模拟器,主要通过.world文件来定义这个仿真世界。包括机器人,lidar,camera和障碍物等等。

Stage在设计中就考虑到了多智能体系统的问题,可以提供对多机器人系统的测试仿真。需要了解的是Stage只提供了真正简单,可计算的廉价的设备模式,而无法非常精密地仿真任何具体的设备终端。

Uasge

rosrun stage_ros stageros [-g runs headless] < world > [standard ROS args]

world : 要加载的.world文件

-g : 如果设置,此选项将以“headless”运行模拟器,不显示任何GUIsgare

还有其他选项:usage/option

上面的的是wiki上说的用法

我自己使用的

rosrun stage_ros stageros < world >

world:要加载的.world文件路径

ex:

$ rosrun stage_ros stageros /opt/ros/kinetic/share/stage_ros/world/willow-erratic.world 
           

stage是ros自带的,所以直接取根目录下能找到对应的功能包

看看效果:

ROS Stage学习

现在可以用

rostopic list

查看下效果

ROS Stage学习

可以看到运行.world文件抛出了cmd_vel话题,那么我们可以订阅相关话题来跑slam导航算法。

那么可以知道ros stage中最重要的是.world文件

.world文件语法:ROS-Stage

World

Stage仿真出的"world"是由"model"组成的,在‘wroldfile’中定义

world
(
   //the name of the world, as displayed in the window title bar. Defaults to the worldfile file name.
   name            "[filename of worldfile]"

	//the length of each simulation update cycle in milliseconds.
   interval_real   100

	//the amount of real-world (wall-clock) time the siulator will attempt to spend on each simulation cycle.
   interval_sim    100
	
	//the amount of real-world time between GUI updates
   gui_interval    100

   //specifies the resolution of the underlying bitmap model. Larger values speed up raytracing at the expense of fidelity in collision detection and sensing.
   resolution      0.0

)
           

Window

模拟器的窗口包含了 菜单栏、状态栏和仿真出的"world"

window
(
  # gui properties
  center [0 0]
  size [700 740]    	//窗口大小
  scale 1.0

  # model properties do not apply to the gui window
)
           

Model

仿真出的model有一些基础属性: 位置,大小,速度,颜色,各种传感器的可见性等,一些基础模型是由可以由其他模型对象来实现

model
(
  pose [0 0 0]			//specify the pose of the model in its parent's coordinate system
  size [1.0 1.0]		//specify the size of the model
  origin [0 0 0]		//specify the position of the object's center, relative to its pose
  velocity [0 0 0]		//specify the initial velocity of the model. Not that if the model hits an obstacle, its velocity will be set to zero.

  # body color
  color "red" 

  # determine how the model appears in various sensors

  obstacle_return 1		//if 1, this model can collide with other models that have this property set
  laser_return 1		//if 0, this model is not detected by laser sensors. if 1, the model shows up in a laser sensor with normal (0) reflectance. If 2, it shows up with high (1) reflectance.
  ranger_return 1		//if 1, this model can be detected by ranger sensors
  blobfinder_return 1	//if 1, this model can be detected in the blob_finder (depending on its color)
  fiducial_return 1		//fiducial_return [fiducial_id:int]  if non-zero, this model is detected by fiducialfinder sensors. The value is used as the fiducial ID.
  gripper_return 0		//iff 1, this model can be gripped by a gripper and can be pushed around by collisions with anything that has a non-zero obstacle_return.
  audio_return 0		//if 1, this model will be an obstacle to audio and will be used to precalculate the audio paths. warning: don't use this for moving objects

  fiducial_key 0

  # GUI properties
  gui_nose 0		//if 1, draw a nose on the model showing its heading (positive X axis)
  gui_grid 0		//if 1, draw a scaling grid over the model
  gui_boundary 0	//if 1, draw a bounding box around the model, indicating its size
  gui_movemask ?	//gui_movemask[int]   define how the model can be moved by the mouse in the GUI window

  # unit square body shape
  polygons 1
  polygon[0].points 4
  polygon[0].point[0] [0 0]
  polygon[0].point[1] [0 1]
  polygon[0].point[2] [1 1]
  polygon[0].point[3] [1 0]

  bitmap ""
)
           

提供了几种模型

1.Postion model

postion model 仿真了一个移动机器人底盘

position(
#position propertise
drive "diff"
velocity[0.0 0.0 0.0 0.0]

localization "gps"
localization_origin[<default to model's srart pose>]

#odometry error model parameters,only used if localization is set to "odom"
odom_error [0.03 0.03 0.00 0.05]

#only used if drive is set to "car"
wheelbase 1.0

#[xmin xmax ymin ymax zmin zmax zmin amax ] 
velocity_bounds [-1 1 -1 1 -1 1 -90 90 ]
acceleration_bounds [-1 1 -1 1 -1 1 -90 90]

#model properties
)
           

PS: 在1.6.5版本之后,odom这一项被删除类,取而代之的是localization_origin

1.使用“gps”可以得到准确的位置信息,使用odom会产生误差,如果非要使用odom则代码中会使用odom_erro这个向量

2.localization_origin[x y z theta]

3.velocaity [x:< float > y z heading ]

4.velocaity[xmin xmax ymin ymax zmin zmax amin amax] xyz线速度范围,a角速度范围

5.wheelbase 将小车的速度预设为1m/s

2.Ranger传感器模型

ranger
(
  # ranger properties
  scount 16
  spose[0] [? ? ?]
  spose[1] [? ? ?]
  spose[2] [? ? ?]
  spose[3] [? ? ?]
  spose[4] [? ? ?]
  spose[5] [? ? ?]
  spose[6] [? ? ?]
  spose[7] [? ? ?]
  spose[8] [? ? ?]
  spose[9] [? ? ?]
  spose[10] [? ? ?]
  spose[11] [? ? ?]
  spose[12] [? ? ?]
  spose[13] [? ? ?]
  spose[14] [? ? ?]
  spose[15] [? ? ?]
   
  ssize [0.01 0.03]
  sview [0.0 5.0 5.0]

  # model properties
  watts 2.0
)
           

Note:

The ranger model allows configuration of the pose, size and view parameters of each transducer seperately (using spose[index], ssize[index] and sview[index]). However, most users will set a common size and view (using ssize and sview), and just specify individual transducer poses.

3.Laser Model

laser
(
  # laser properties
  samples 180    //每次扫描180个样本点
  range_min 0.0
  range_max 8.0
  fov 180.0   //扫描角度

  # model properties
  size [0.15 0.15]
  color "blue"
  watts 17.5 # approximately correct for SICK LMS200
)
           

定义一个移动机器人跑slam

define kinetic ranger(
sensor(
		range[0.05 10 ] //激光范围
		fov 180.0 //角度
		samples 700 //激光束
)
#generic model properties
color “black”
size [ 0.4 0.4 0.1]
)

define block model(
size [0.4 0.4 0.1]
gui_nose 0 //是否有箭头指示
)

define turtlebot position model(
pose [0 0 0 0]
odom_error [0.00 0.00 1111 0.02]

size [1.3 0.8 0.4]
origin [0.0 0.0 0.0 0.0]
gui_nose 1
drive "onmi"
color "gray"
block(pose [0.7000 0.000 0.000 0.000] color "red")
kinect(pose [ 0.065 0.0 0.3 0.0])
)
           

花了几天时间还是把ros stage搞明白了

ros