Ros学习——移动机器人Ros导航详解及源码解析

 

 

1 执行过程

  • 1.运行仿真机器人fake_turtlebot.launch:加载机器人模型——启动机器人仿真器——发布机器人状态
  • 2.运行amcl节点fake_amcl.launch:加载地图节点map_server——加载move_base节点——加载fake_localization节点(AMCL)
  • 3.运行rviz

 

 

2 机器人仿真

//fake_turtlebot.launch

<launch>
  <param name="/use_sim_time" value="false" />

  <!-- Load the URDF/Xacro model of our robot -->
  <arg name="urdf_file" default="$(find xacro)/xacro.py '$(find rbx1_description)/urdf/turtlebot.urdf.xacro'" />
   
  <param name="robot_description" command="$(arg urdf_file)" />
    
  <node name="arbotix" pkg="arbotix_python" type="arbotix_driver" output="screen" clear_params="true">
      <rosparam file="$(find rbx1_bringup)/config/fake_turtlebot_arbotix.yaml" command="load" />
      <param name="sim" value="true"/>
  </node>
  
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">
      <param name="publish_frequency" type="double" value="20.0" />
  </node>
  
</launch>
  • 2.1加载机器人模型turtlebot.urdf.xacro,包括:

    1.硬件模型turtlebot_hardware.urdf.xacro

    2.机器人本体模型turtlebot_body.urdf.xacro

    3.标定参数turtlebot_calibration.xacro

    4.运动学模型turtlebot_kinect.urdf.xacro

 

  • 2.2 加载arbotix模拟器,即arbotix节点(加载配置文件:fake_turtlebot_arbotix.yaml)  

port: /dev/ttyUSB0
baud: 115200
rate: 20
sync_write: True
sync_read: True
read_rate: 20
write_rate: 20

controllers: {
   #  Pololu motors: 1856 cpr = 0.3888105m travel = 4773 ticks per meter (empirical: 4100)
   base_controller: {type: diff_controller, base_frame_id: base_footprint, base_width: 0.26, ticks_meter: 4100, Kp: 12, Kd: 12, Ki: 0, Ko: 50, accel_limit: 1.0 }
}

  

  • 2.3 加载robot_state_publisher节点(设置频率publish_frequency:20)

 

 

 

3 机器人控制

//fake_amcl.launch

<launch>

  <param name="use_sim_time" value="false" />

  <!-- Set the name of the map yaml file: can be overridden on the command line. -->
  <arg name="map" default="test_map.yaml" />

  <!-- Run the map server with the desired map -->
  <node name="map_server" pkg="map_server" type="map_server" args="$(find rbx1_nav)/maps/$(arg map)"/>

  <!-- The move_base node -->
  <include file="$(find rbx1_nav)/launch/fake_move_base_amcl.launch" />
  
  <!-- Run fake localization compatible with AMCL output -->
  <node pkg="fake_localization" type="fake_localization" name="fake_localization" clear_params="true" output="screen">
     <remap from="base_pose_ground_truth" to="odom" />
     <param name="global_frame_id" value="map" />
     <param name="base_frame_id" value="base_footprint" />
  </node>

</launch>

  

  • 3.1加载地图服务器节点map_server,配置地图文件:test_map.yaml
image: test_map.pgm                              //包含占用数据的图像文件的路径; 可以是绝对的,或相对于YAML文件的位置
resolution: 0.050000                              //地图的分辨率,米/像素
origin: [-13.800000, -12.200000, 0.000000]                //地图中左下像素的2-D姿态为(x,y,yaw),偏航为逆时针旋转(yaw = 0表示无旋转)。系统的许多部分目前忽略偏航。
negate: 0                                    //白/黑自由/占用语义是否应该被反转(阈值的解释不受影响)     
occupied_thresh: 0.9                             //占据概率大于该阈值的像素被认为完全占用
free_thresh: 0.196                               //占有概率小于该阈值的像素被认为是完全自由的

  

  • 3.2加载movebase节点:fake_move_base_amcl.launch——>运行成本、机器人半径、到达目标位置的距离,机器人移动的速度

    1.costmap_common_params.yaml:配置基本的参数,这些参数会被用于local_costmap和global_costmap.      

obstacle_range: 2.5                //障碍物探测,引入地图
raytrace_range: 3.0               //用于机器人运动过程中,实时清除代价地图中的障碍物
#footprint: [[0.175, 0.175], [0.175, -0.175], [-0.175, -0.175], [-0.175, 0.175]]          //将机器人的几何参数告诉导航功能包集,机器人和障碍物之间保持一个合理的距离
#footprint_inflation: 0.01
robot_radius: 0.175
inflation_radius: 0.2            //机器人与障碍物之间必须要保持的最小距离
max_obstacle_height: 0.6
min_obstacle_height: 0.0
observation_sources: scan   //设定导航包所使用的传感器
scan: {data_type: LaserScan, topic: /scan, marking: true, clearing: true, expected_update_rate: 0}    

  

    2.local_costmap_params.yaml;

local_costmap:
   global_frame: map
   robot_base_frame: base_footprint
   update_frequency: 3.0            //发布信息的频率,也就是costmap可视化信息发布的频率
   publish_frequency: 1.0
   static_map: true
   rolling_window: false            //true:在机器人运动过程中,代价地图始终以机器人为中心
   width: 6.0
   height: 6.0
   resolution: 0.01                 //这三个是代价地图的的尺寸和分辨率,单位都是m
   transform_tolerance: 1.0

  

    3.global_costmap_params.yaml;

global_costmap:
   global_frame: map                          //定义机器人和地图之间的坐标变换,建立全局代价地图必须使用这个变换。
   robot_base_frame: base_footprint
   update_frequency: 1.0                  //地图更新的频率
   publish_frequency: 1.0
   static_map: true                            //是否使用一个地图或者地图服务器来初始化全局代价地图
   rolling_window: false
   resolution: 0.01
   transform_tolerance: 1.0
   map_type: costmap        

  

    4.base_local_planner_params.yaml;

controller_frequency: 3.0
recovery_behavior_enabled: false
clearing_rotation_allowed: false

TrajectoryPlannerROS:          //机器人的最大和最小速度限制值,也设定了加速度的限值
   max_vel_x: 0.5
   min_vel_x: 0.1
   max_vel_y: 0.0  # zero for a differential drive robot
   min_vel_y: 0.0
   max_vel_theta: 1.0
   min_vel_theta: -1.0
   min_in_place_vel_theta: 0.4
   escape_vel: -0.1
   acc_lim_x: 1.5
   acc_lim_y: 0.0  # zero for a differential drive robot
   acc_lim_theta: 1.2

   holonomic_robot: false                     //全向移动机器人那么此值为true
   yaw_goal_tolerance: 0.1 # about 6 degrees
   xy_goal_tolerance: 0.05  # 5 cm
   latch_xy_goal_tolerance: false
   pdist_scale: 0.4
   gdist_scale: 0.8
   meter_scoring: true

   heading_lookahead: 0.325
   heading_scoring: false
   heading_scoring_timestep: 0.8
   occdist_scale: 0.05
   oscillation_reset_dist: 0.05
   publish_cost_grid_pc: false
   prune_plan: true

   sim_time: 1.0
   sim_granularity: 0.05
   angular_sim_granularity: 0.1
   vx_samples: 8
   vy_samples: 0  # zero for a differential drive robot
   vtheta_samples: 20
   dwa: true
   simple_attractor: false

  

    5.nav_test_params.yaml

TrajectoryPlannerROS:
  yaw_goal_tolerance: 6.28 # We don't care about orientation
  xy_goal_tolerance: 0.1   # 10 cm
  pdist_scale: 0.8
  gdist_scale: 0.4
  occdist_scale: 0.1

  

  • 3.3加载fake_localization节点:ACML

 

3 Rviz显示

 

posted @ 2019-01-17 18:38  寒江小筑  阅读(3871)  评论(0编辑  收藏  举报