编码器推算里程计是可以,但是会有很多因素影响里程计的准确性,比如机械误差、定位累计误差等等,目前想到比较理想的解决办法是用激光里程计。便宜的陀螺仪用卡尔曼滤波来算角度也未必有想象中那么靠谱,弄得不好还会引入误差。所以用一个好的激光雷达来推算里程计能够解决目前比较多的扎心问题。
视觉里程计参考:http://wiki.ros.org/rf2o_laser_odometry
自行看wiki安装配置好环境,然后看launch文件,由于时间关系,我暂时没有实际机器人测试激光里程计的效果:
<launch>
<node pkg="rf2o_laser_odometry" type="rf2o_laser_odometry_node" name="rf2o_laser_odometry">
<param name="laser_scan_topic" value="/laser_scan"/> <!-- topic where the lidar scans are being published -->
<param name="base_frame_id" value="/base_link"/> <!-- frame_id (tf) of the mobile robot base. A tf transform from the laser_frame to the base_frame is mandatory -->
<param name="odom_frame_id" value="/odom" /> <!-- frame_id (tf) to publish the odometry estimations -->
<param name="freq" value="6.0"/> <!-- Execution frequency. See "Planar Odometry from a Radial Laser Scanner. A Range Flow-based Approach. ICRA'16"-->
</node>
</launch>