首先看了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自帶的,是以直接取根目錄下能找到對應的功能包
看看效果:
現在可以用
rostopic list
檢視下效果
可以看到運作.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搞明白了