cartographer support web
https://google-cartographer-ros.readthedocs.io/en/latest/configuration.html
安装步骤,参考:
http://www.cnblogs.com/hitcm/p/5939507.html
安装ceres-solver 你可能会出错, 到github 下载最新版
https://github.com/ceres-solver/ceres-solver
如果make -j 司机,还是用make把, 用不了多久
还是先从2d仿真做起把,可以使用imu数据,还是先不使用把
#运行
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=~/Downloads/cartographer_paper_deutsches_museum.bag
具体界面
发现这个2d,使用的是pointcloud2数据(scan_matched_points2),而非laserscan
看看这个launch文件demo_backpack_2d.launch写了什么
<launch>
<param name="robot_description"
textfile="$(find cartographer_ros)/urdf/backpack_2d.urdf" />
<node name="robot_state_publisher" pkg="robot_state_publisher"
type="robot_state_publisher" />
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename backpack_2d.lua"
output="screen">
<remap from="echoes" to="horizontal_laser_2d" />
</node>
</launch>
-- 只有caartographher_node 一个节点启动, 接受话题默认是echoes,类型是
-- rostopic type /horizontal_laser_2d
sensor_msgs/MultiEchoLaserScan
-- 这个配置文件不全,查看了github别人的配置文件和该包所支持的传感器后,看如下参数
^ use_laser_scan = true,使用2d激光
^ use_horizontal_laser = true, horizontal_laser_min_range = 0.1, horizontal_laser_max_range = 30.,
^ use_multi_echo_laser_scan = false, 使用多回波激光数据
^ use_horizontal_multi_echo_laser = true,使用水平多回波激光
^ 貌似3d的lua配置文件中不使用以上3个use变量值,
3d的launch文件中cartographer_node 的话题映射为
<remap from="points2" to="/camera/depth/points" />
lidar的demo_lidar_2d.launch文件中cartographer_ros的节点映射为
<remap from="scan" to="/laser_scan" />
此外还有配置文件backpack_2d.lua:
include "map_builder.lua"
options = {
map_builder = MAP_BUILDER,
map_frame = "map",
tracking_frame = "base_link",
published_frame = "base_link",
odom_frame = "odom",
provide_odom_frame = true,
use_odometry_data = false,
use_constant_odometry_variance = false,
constant_odometry_translational_variance = 0.,
constant_odometry_rotational_variance = 0.,
use_horizontal_laser = false,
use_horizontal_multi_echo_laser = true,
horizontal_laser_min_range = 0.,
horizontal_laser_max_range = 30.,
horizontal_laser_missing_echo_ray_length = 5.,
num_lasers_3d = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
}
MAP_BUILDER.use_trajectory_builder_2d = true
return options
看看这个节点的具体信息
robot@robot:~$ rosnode info /cartographer_node
--------------------------------------------------------------------------------
Node [/cartographer_node]
Publications:
* /submap_list [cartographer_ros_msgs/SubmapList]
* /scan_matched_points2 [sensor_msgs/PointCloud2]
* /rosout [rosgraph_msgs/Log]
* /tf [tf2_msgs/TFMessage]
* /map [nav_msgs/OccupancyGrid]
Subscriptions:
* /horizontal_laser_2d [sensor_msgs/MultiEchoLaserScan]
* /tf [tf2_msgs/TFMessage]
* /tf_static [tf2_msgs/TFMessage]
* /clock [rosgraph_msgs/Clock]
* /imu [sensor_msgs/Imu]
Services:
* /cartographer_node/get_loggers
* /cartographer_node/set_logger_level
* /submap_query
* /finish_trajectory
contacting node http://robot:34348/ ...
Pid: 25431
Connections:
* topic: /rosout
* to: /rosout
* direction: outbound
* transport: TCPROS
* topic: /tf
* to: /cartographer_node
* direction: outbound
* transport: INTRAPROCESS
* topic: /tf
* to: /rviz
* direction: outbound
* transport: TCPROS
* topic: /submap_list
* to: /rviz
* direction: outbound
* transport: TCPROS
* topic: /scan_matched_points2
* to: /rviz
* direction: outbound
* transport: TCPROS
* topic: /clock
* to: /playbag (http://robot:33119/)
* direction: inbound
* transport: TCPROS
* topic: /tf
* to: /cartographer_node (http://robot:34348/)
* direction: inbound
* transport: INTRAPROCESS
* topic: /tf
* to: /robot_state_publisher (http://robot:34988/)
* direction: inbound
* transport: TCPROS
* topic: /tf_static
* to: /robot_state_publisher (http://robot:34988/)
* direction: inbound
* transport: TCPROS
* topic: /horizontal_laser_2d
* to: /playbag (http://robot:33119/)
* direction: inbound
* transport: TCPROS
* topic: /imu
* to: /playbag (http://robot:33119/)
* direction: inbound
* transport: TCPROS
-- 第一行include,你可能疑惑文件在哪儿,在/usr/local/share/cartographer/configuration_files
-- 不使用imu 和 里程计数据,所以设置 tracking_frame/published_frame 都是base_link,use_odometry 为false,provide_odom_frame为true
一个收集的使用lidar的配置文件和launch文件
demo.lua
include "map_builder.lua"
include "trajectory_builder.lua"
options = {
map_builder = MAP_BUILDER,
map_frame = "map",
tracking_frame = "base_link",
published_frame = "base_link",
odom_frame = "odom",
provide_odom_frame = true,
use_odometry_data = false,
use_constant_odometry_variance = false,
constant_odometry_translational_variance = 0.,
constant_odometry_rotational_variance = 0.,
use_horizontal_laser = true,
use_horizontal_multi_echo_laser = false,
horizontal_laser_min_range = 0.3,
horizontal_laser_max_range = 25.,
horizontal_laser_missing_echo_ray_length = 1.,
num_lasers_3d = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
}
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
return options
demo.launch
<launch>
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename demo.lua"
output="screen">
<remap from="scan" to="lidar/scan" />
</node>
</launch>
接下来用clearpath jackal gazebo仿真器来实现一下把
roslaunch jackal_gazebo jackal_world.launch config:=front_laser
#rostopic list
注意话题的消息是front/scan
#遥控
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
#接下来要修改cartographer的launch和lua,按照上面模板来.
上图