• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

TX2+rplidar+cartographer

人工智能 宗孝鹏 2327次浏览 0个评论

第一步:TX2安装ROS kinetic   http://www.ncnynl.com/archives/201706/1750.html   第二步:安装激光雷达驱动(测试过rplidar、F4)   首先必须给TX2编译内核,才可读取出雷达,编译方法参考 http://m.blog.csdn.net/gzj2013/article/details/77069803   注意要选择CP210x驱动,而不是例子中的CH341   必须保证TX2中有足够的空间(大于5G)才可正常安装(我不会说试过N遍才知道)   然后安装雷达驱动,参考 http://www.ncnynl.com/archives/201704/1516.html   第三步:TX2安装cartographer(官方安装方法)   来源:http://www.ncnynl.com/archives/201702/1369.html  

# Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
 
# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src
 
# Merge the cartographer_turtlebot.rosinstall file and fetch code for dependencies.
 
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_turtlebot/master/cartographer_turtlebot.rosinstall
 
#vim src/.rosinstall 该文件默认是隐形状态,进入到src文件夹后ctrl+h 即可显示出来
#更改ceres-solver中地址改为下面的地址:
#>>uri: https://github.com/ceres-solver/ceres-solver.git
 
wstool update -t src
 
# Install deb dependencies.
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
 
# Build and install.
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash

 

  • 安装完成即Cartographer, Cartographer ROS, and Cartographer ROS’s TurtleBot都已经安装。可通过下载运行官方的例子来检验安装是否正确

 

# Download the example bag.(下载例子)
wget -P ~/Downloads https://storage.useso.com/cartographer-public-data/bags/turtlebot/cartographer_turtlebot_demo.bag
 
# Launch the 2D LIDAR demo.(2D雷达DEMO)
roslaunch cartographer_turtlebot demo_lidar_2d.launch bag_filename:=${HOME}/Downloads/cartographer_turtlebot_demo.bag

 

  • 刚开始使用ROS的同学运行下面两句是无法工作的,可能出现的错误如下。

 

[demo_backpack_2d.launch] is neither a launch file in package [cartographer_ros] nor is [cartographer_ros] a launch file name
The traceback for the exception was written to the log file

 

  • 这种错误的主要原因是ros的catkin_ws配置问题,
  • 解决方法:在~bashrc文件最后一行添加 source ~/catkin_ws/install_isolated/setup.bash,
  • 然后在终端运行rospack profile,观察是否包含新包的路径。

 
TX2+rplidar+cartographer   第四步:cartographer和激光雷达相匹配,构建地图   F4激光雷达的配置方法参考创客教程: http://www.ncnynl.com/archives/201702/1371.html

  • 增加turtlebot_lidar.launch

 

cd ~/carto_ws/install_isolated/share/cartographer_turtlebot/launch
touch turtlebot_lidar.launch 
vim turtlebot_lidar.launch 

 

  • 代码如下:

 

<launch>
  <arg name="configuration_basename"/>
 
  <include file="$(find turtlebot_bringup)/launch/minimal.launch" />
 
  <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory
              $(find cartographer_turtlebot)/configuration_files
          -configuration_basename $(arg configuration_basename)"
      output="screen">
    <remap from="scan" to="/scan" />
  </node>
 
  <node name="flat_world_imu_node" pkg="cartographer_turtlebot"
      type="cartographer_flat_world_imu_node" output="screen">
    <remap from="imu_in" to="/mobile_base/sensors/imu_data_raw" />
    <remap from="imu_out" to="/imu" />
  </node>
 
  <node name="rviz" pkg="rviz" type="rviz" required="true"
      args="-d $(find cartographer_turtlebot
          )/configuration_files/demo_turtlebot.rviz" />
 
</launch>

 

  • 在turtlebot_navigation包(laser-driver)中增加rplidar雷达启动文件,代码如下(与原启动文件相比添加了TF转换,必不可少):

 

<launch>
  <node name="rplidarNode"          pkg="rplidar_ros"  type="rplidarNode" output="screen">
    <param name="serial_port"         type="string" value="/dev/rplidar"/>
    <param name="serial_baudrate"     type="int"    value="115200"/>
    <param name="frame_id"            type="string" value="laser"/>
    <param name="angle_compensate"    type="bool"   value="true"/>
    <param name="ignore_array"        type="string" value="" />
    <param name="ignore_value"        type="double"  value="0" />
  </node>
 
  <node pkg="tf" type="static_transform_publisher" name="base_to_laser" args="0.0 0.0 0.18 3.14 3.14 0.0 base_link laser 200"/>
</launch>

 

  • 新增启动文件turtlebot_lidar_2d.launch:

 

cd ~/carto_ws/install_isolated/share/cartographer_turtlebot/launch
touch turtlebot_lidar_2d.launch
vim turtlebot_lidar_2d.launch

 

  • 代码如下:

 

<launch>
 
  <include file="$(find cartographer_turtlebot)/launch/turtlebot_lidar.launch">
    <arg name="configuration_basename" value="turtlebot_urg_lidar_2d.lua" />
  </include>
</launch>

 

  • 新终端,启动雷达:

 

$ roslaunch turtlebot_navigation rplidar_laser.launch

 

  • 新终端,启动建图:

 

$ roslaunch cartographer_turtlebot turtlebot_lidar_2d.launch

 

  • 会自动打开RViz查看实时情况。
  • 移动建图,移动turtlebot走圈完成建图,也可以远程控制
  • 新终端,完成建图后保存地图,实际路径是:/home/user/map/

 

$ mkdir -p ~/map
$ rosrun map_server map_saver -f ~/map/lidar_2d_carto
$ ls ~/map   #查看内容,包含lidar_2d_carto.pgm  lidar_2d_carto.yaml

  第五步:cartographer和激光雷达相匹配,导航  

  • (1)增加rplidar_amcl_demo.launch

 

cd ~/catkin_ws/src/turtlebot_apps/turtlebot_navigation/launch
mkdir laser_amcl
cd laser_amcl
touch rplidar_amcl_demo.launch
gedit rplidar_amcl_demo.launch

 

  • 代码如下:

 

<launch>
  <!-- Define laser type-->
  <arg name="laser_type" default="rplidar" />
 
  <!-- 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="$(arg initial_pose_y)"/>
    <arg name="initial_pose_a" value="$(arg initial_pose_a)"/>
  </include>
 
  <!-- Move base -->
  <arg name="custom_param_file" default="$(find turtlebot_navigation)/param/$(arg laser_type)_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>

  (2)增加rplidar_amcl.launch.xml文件 位于turtlebot_navigation / launch / includes /amcl下,直接复制r200_amcl.launch.xml文件并改名即可   (3)增加rplidar_costmap_params.yaml文件 位于turtlebot_navigation / param 下,直接复制r200_costmap_params.yaml文件并改名即可


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明TX2+rplidar+cartographer
喜欢 (0)

您必须 登录 才能发表评论!

加载中……