文章目录
我已经建好图之后需要进行定位,并且自主行驶。教程在此
roslaunch turtlebot_navigation amcl_demo.launch map_file:=/tmp/my_map.yaml
如果是之前我的rplidar+turtlebot2+kartoslam建图的话,之间运行显然是会报错的
报错如下:
[ INFO] [1578461816.522543748]: No matching device found.... waiting for devices. Reason: std::__cxx11::string openni2_wrapper::OpenNI2Driver::resolveDeviceURI(const string&) @ /tmp/binarydeb/ros-kinetic-openni2-camera-0.4.2/src/openni2_driver.cpp @ 737 : Invalid device number 1, there are 0 devices connected.
[ INFO] [1578461819.522868425]: No matching device found.... waiting for devices. Reason: std::__cxx11::string openni2_wrapper::OpenNI2Driver::resolveDeviceURI(const string&) @ /tmp/binarydeb/ros-kinetic-openni2-camera-0.4.2/src/openni2_driver.cpp @ 737 : Invalid device number 1, there are 0 devices connected.
OpenNI2Driver?
[ WARN] [1578461821.301283372]: Timed out waiting for transform from base_footprint to map to become available before running costmap, tf error: canTransform: target_frame map does not exist.. canTransform returned after 0.10052 timeout was 0.1
一开始没看launch文件内容还百度了很多
Timed out waiting for transform from base_footprint to map to become available before running costm:雷达前面20厘米以内放置障碍阻挡
[ WARN] [1555379888.006898613]: Timed out waiting for transform from base_footprint to map to become:
- 在应用中推荐把provide_odom_frame参数置为false。当该参数为true时,其发布的数据为map->odom的tf,而非机器人的位姿。当将provide_odom_frame参数置为false时,可以获得map->base_footprint的tf数据,即机器人相对于map的位姿
- 修改global和local_costmap_params.yaml中的transform_tolerance(坐标系间的转换可以忍受的最大延时),我的最初默认为1,我依次增加到8的时候不出现错误了,但8的话已经没有任何意义了。
- 雷达信息不正确
其实不是雷达信息不正确,首先我们看一下我们运行的launch文件是什么
rosed turtlebot_navigation amcl_demo.launch
<launch>
<!-- 3D sensor -->
<arg name="3d_sensor" default="$(env TURTLEBOT_3D_SENSOR)"/> <!-- r200, kinect, asus_xtion_pro -->
<!-- 这里的$(env估计是为了得到环境变量 但是我env |grep TURTKEBOT_3D_SENSOR 发现啥都没有
但是发现bashrc中有export TURTLEBOT_3D_SENSOR=kinect
-->
<include file="$(find turtlebot_bringup)/launch/3dsensor.launch">
<arg name="rgb_processing" value="false" />
<arg name="depth_registration" value="false" />
<arg name="depth_processing" value="false" />
<!-- We must specify an absolute topic name because if not it will be prefixed by "$(arg camera)".
Probably is a bug in the nodelet manager: https://github.com/ros/nodelet_core/issues/7 -->
<arg name="scan_topic" value="/scan" />
</include>
<!-- Map server,这里我env |grep TURTLEBOT_MAP_FILE出现
TURTLEBOT_MAP_FILE=/opt/ros/kinetic/share/turtlebot_navigation/maps/willow-2010-02-18-0.10.yaml 所以必须要在参数里面更改自己地图所在目录-->
<arg name="map_file" default="$(env TURTLEBOT_MAP_FILE)"/>
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />
<!-- AMCL -这里就更不可能了都不知道3d_sensor的arg是什么 -->
<arg name="custom_amcl_launch_file" default="$(find turtlebot_navigation)/launch/includes/amcl/$(arg 3d_sensor)_amcl.launch.xml"/>
<arg name="initial_pose_x" default="0.0"/> <!-- Use 17.0 for willow's map in simulation -->
<arg name="initial_pose_y" default="0.0"/> <!-- Use 17.0 for willow's map in simulation -->
<arg name="initial_pose_a" default="0.0"/>
<include file="$(arg custom_amcl_launch_file)">
<arg name="initial_pose_x" value="$(arg initial_pose_x)"/>
<arg name="initial_pose_y" value="$(arg initial_pose_y)"/>
<arg name="initial_pose_a" value="$(arg initial_pose_a)"/>
</include>
<!-- Move base -->
<!--
ls |grep _costmap
astra_costmap_params.yaml
asus_xtion_pro_costmap_params.yaml
asus_xtion_pro_offset_costmap_params.yaml
global_costmap_params.yaml
kinect_costmap_params.yaml
local_costmap_params.yaml
r200_costmap_params.yaml
你看 也没有与rplidar相关的costmap的存在
-->
<arg name="custom_param_file" default="$(find turtlebot_navigation)/param/$(arg 3d_sensor)_costmap_params.yaml"/>
<include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml">
<arg name="custom_param_file" value="$(arg custom_param_file)"/>
</include>
</launch>
换教程!
Turbot-SLAM入门教程-实现AMCL自主导航(Rplidar A2版)
其代码库,我们下下来看,看到
laser_amcl_demo.launch
<launch>
<!-- Define laser type-->
<arg name="laser_type" default="$(env TURTLEBOT_LASER_SENSOR)" />
<!-- laser driver -->
<include file="$(find turtlebot_navigation)/laser/driver/$(arg laser_type)_laser.launch" />
<!-- Map server -->
<arg name="map_file" default="$(env TURTLEBOT_MAP_FILE)"/>
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />
<!-- AMCL -->
<arg name="custom_amcl_launch_file" default="$(find turtlebot_navigation)/launch/includes/amcl/$(arg laser_type)_amcl.launch.xml"/>
<arg name="initial_pose_x" default="0.0"/> <!-- Use 17.0 for willow's map in simulation -->
<arg name="initial_pose_y" default="0.0"/> <!-- Use 17.0 for willow's map in simulation -->
<arg name="initial_pose_a" default="0.0"/>
<include file="$(arg custom_amcl_launch_file)">
<arg name="initial_pose_x" value="$(arg initial_pose_x)"/>
<arg name="initial_pose_y" value="