智能机器人(51):建图和定位

3. 建图功能 – gmapping

$ sudo apt-get install ros-indigo-gmapping
$ rosrun gmapping slam_gmapping scan:=scan

gmapping实现基于激光的SLAM, in fact usinf OpenSlam的Gmapping。
make a 名为slam_gmapping的node -> 创建2D的occupancy grid map。

Subs:
* scan (sensor_msgs/LaserScan)

Pubs:
* map (nav_msgs/OccupancyGrid)
Get the map data from this topic, which is latched, and updated periodically
Services:
* dynamic_map (nav_msgs/GetMap)
Call this service to get the map data

TF required:
* odom -> base_link
usually provided by the odometry system, e.g., the driver for the mobile base
* base_link -> laser_link (base_laser)
usually broadcast periodically by robot_state_publisher, or from a tf static_transform_publisher.

TF provided:
* map -> odom
the current estimate of the robot’s pose in the map frame
既然是建图,肯定给出了odom在map中的位置,也就是此处的map->odom的tf变换。

4. 地图服务器 – map_server

$ sudo apt-get install ros-indigo-map-server

map_server包提供一个服务map_server和一个应用map_saver:
* map_server , a ROS Node, which offers map data as a ROS Service.
* map_saver , a command-line utility, which allows dynamically generated maps to be saved to file.
前者map_server提供地图服务,例如导航时。
后者map_saver用于保存地图,例如建图时。

4.1 在导航或者定位场景,加载地图,可以在c或python的node。
$ roslaunch funbot r_mapserver.launch
$ vi r_mapserver.launch
$ rosrun map_server map_server /home/funbot/map/map2017.yaml

Pubs:
* map (nav_msgs/OccupancyGrid)
you can receive the map via this latched topic.

Services:
* static_map (nav_msgs/GetMap)
Retrieve the map via this service.

4.2 在mapping场景,可以随时保存地图。
这个通过command-line或者在code里面system()。
$ rosrun map_server map_saver -f /home/funstep/map/map2017 y
$ rosrun map_server map_saver -f _map_file:=/home/funstep/map/map.yaml x

Subs:
* map (nav_msgs/OccupancyGrid)
Map will be retrieved via this latched topic.

5. 定位功能 – amcl

$ sudo apt-get install ros-indigo-amcl
rosrun amcl amcl scan:=scan

amcl是2D的基于概率的定位的一个包。

Subs:
* map (nav_msgs/OccupancyGrid)
If amcl parameter “use_map_topic=true” ,then AMCL subscribes this topic to retrieve map,
otherwise using service call.
* scan (sensor_msgs/LaserScan)
Laser scans
* initialpose (geometry_msgs/PoseWithCovarianceStamped)
Mean and covariance with which to (re-)initialize the particle filter

Pubs:
* amcl_pose (geometry_msgs/PoseWithCovarianceStamped)
Robot’s estimated pose in the map with covariance.

TF required:
* tf (tf/tfMessage)
提供odom -> base_link

TF supported:
* tf (tf/tfMessage)
发布map -> odom(间接的机器人在地图的位置)
注意:
不能有另外的map->odom在同时发布,例如在跑mapping.
实际上,mapping和amcl同时跑的需求不存在。
如果有,也使用hector_slam.

Paras:
三种类型的参数用来配置AMCL节点:filter整体的,laser模型的,odom模型。例如
Odometry model parameters:
* ~tf_broadcast (bool, default: true)
Set to false to prevent amcl from publishing the transform map -> odom.
可以关闭上述map->odom的tf。

注意:
*1. initialpose这个topic的存在,主要方便于在amcl运行时对姿态进行复位。
*2. initial_pose这个topic上如果发布赋值,实际就是初始化一个高斯分布。这个分布的协方差越大,说明粒子在地图上撒开的面积越大,越难定位。
*3. 不 对initial_pose直接赋值,而通过操作amcl的parameter参数,可以同样效果。
或者通过呼叫global_localization service,也可以达到把颗粒均匀洒在地图的目的。
4. 如果不赋值,则位置是默认地图的(0.0.0,0,0,0),但是默认的协方差很小,也就是说默认为确认给出的位置信息相当的准确。这个需要注意。

0 回复

发表评论

Want to join the discussion?
Feel free to contribute!

发表评论