首页 > 代码库 > movebase导航

movebase导航

利用turtlebot 的导航配置文件

由于movbase发的速度太不友好了所以使用了ros自带的滤波安装相应的包

apt-get install ros-indigo-yocs-velocity-smoother

我的配置文件 standalone.yaml

# Example configuration:
# - velocity limits are around a 10% above the physical limits
# - acceleration limits are just low enough to avoid jerking

# Mandatory parameters
speed_lim_v: 0.8
speed_lim_w: 5.4

accel_lim_v: 0.3
accel_lim_w: 3.5

# Optional parameters
frequency: 20.0
decel_factor: 1.0

# Robot velocity feedback type:
#  0 - none
#  1 - odometry
#  2 - end robot commands
robot_feedback: 2

 我机器人的启动文件

<launch>
    
    <param name="use_sim_time" value="http://www.mamicode.com/false" />
    
    <node name="link_laser" pkg="tf" type="static_transform_publisher" args="0.15 0 0.15 0 0 0 base_link laser 50"/> 
    <node name="link_footprint" pkg="tf" type="static_transform_publisher" args="0 0 0 0 0 0 base_link base_footprint 50"/>

    <node pkg="odom_tf_package" type="base_controller" name="serial_send_recevice" output="screen"/>

    <include file="$(find odom_tf_package)/launch/include/rplidar.launch" />
  
  

  <arg name="node_name"             value="http://www.mamicode.com/velocity_smoother"/>
  <arg name="nodelet_manager_name"  value="http://www.mamicode.com/nodelet_manager"/>
  <arg name="config_file"           value="http://www.mamicode.com/$(find odom_tf_package)/config/standalone.yaml"/>
  <arg name="raw_cmd_vel_topic"     value="http://www.mamicode.com/cmd_vel"/>
  <arg name="smooth_cmd_vel_topic"  value="http://www.mamicode.com/smoother_cmd_vel"/>
  <arg name="robot_cmd_vel_topic"   value="http://www.mamicode.com/robot_cmd_vel"/>
  <arg name="odom_topic"            value="http://www.mamicode.com/odom"/>
  
  <!-- nodelet manager -->
  <node pkg="nodelet" type="nodelet" name="$(arg nodelet_manager_name)" args="manager"/>
  
    
  <!-- velocity smoother -->
  <include file="$(find yocs_velocity_smoother)/launch/velocity_smoother.launch">
    <arg name="node_name"             value="http://www.mamicode.com/$(arg node_name)"/>
    <arg name="nodelet_manager_name"  value="http://www.mamicode.com/$(arg nodelet_manager_name)"/>
    <arg name="config_file"           value="http://www.mamicode.com/$(arg config_file)"/>
    <arg name="raw_cmd_vel_topic"     value="http://www.mamicode.com/$(arg raw_cmd_vel_topic)"/>
    <arg name="smooth_cmd_vel_topic"  value="http://www.mamicode.com/$(arg smooth_cmd_vel_topic)"/>
    <arg name="robot_cmd_vel_topic"   value="http://www.mamicode.com/$(arg robot_cmd_vel_topic)"/>
    <arg name="odom_topic"            value="http://www.mamicode.com/$(arg odom_topic)"/>
  </include>


</launch>

 建图的启动文件:gmapping.launch

<launch>

  <arg name="scan_topic" default="scan" />  //laser的topic名称,与自己的激光的topic相对应
   <param name="odom_frame" value=http://www.mamicode.com/"odom"/>  //世界坐标
  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen" clear_params="true">   //启动slam的节点

    <param name="map_update_interval" value=http://www.mamicode.com/"2.0"/>
    <!-- Set maxUrange < actual maximum range of the Laser -->
    <param name="maxRange" value=http://www.mamicode.com/"5.0"/>
    <param name="maxUrange" value=http://www.mamicode.com/"4.5"/>
    <param name="sigma" value=http://www.mamicode.com/"0.05"/>
    <param name="kernelSize" value=http://www.mamicode.com/"1"/>
    <param name="lstep" value=http://www.mamicode.com/"0.05"/>  //optimize机器人移动的初始值(距离)
    <param name="astep" value=http://www.mamicode.com/"0.05"/>  //optimize机器人移动的初始值(角度)
    <param name="iterations" value=http://www.mamicode.com/"5"/>    //icp的迭代次数
    <param name="lsigma" value=http://www.mamicode.com/"0.075"/>
    <param name="ogain" value=http://www.mamicode.com/"3.0"/>
    <param name="lskip" value=http://www.mamicode.com/"0"/> //为0,表示所有的激光都处理,尽可能为零,如果计算压力过大,可以改成1

    <param name="srr" value=http://www.mamicode.com/"0.01"/>    //以下四个参数是运动模型的噪声参数
    <param name="srt" value=http://www.mamicode.com/"0.02"/>
    <param name="str" value=http://www.mamicode.com/"0.01"/>
    <param name="stt" value=http://www.mamicode.com/"0.02"/>
    <param name="linearUpdate" value=http://www.mamicode.com/"0.5"/>    //机器人移动linearUpdate距离,进行scanmatch
    <param name="angularUpdate" value=http://www.mamicode.com/"0.5"/>   //机器人选装angularUpdate角度,进行scanmatch
    <param name="temporalUpdate" value=http://www.mamicode.com/"-1.0"/>
    <param name="resampleThreshold" value=http://www.mamicode.com/"0.5"/>
    <param name="particles" value=http://www.mamicode.com/"80"/>        //很重要,粒子个数

<!--
    <param name="xmin" value=http://www.mamicode.com/"-50.0"/>
    <param name="ymin" value=http://www.mamicode.com/"-50.0"/>
    <param name="xmax" value=http://www.mamicode.com/"50.0"/>
    <param name="ymax" value=http://www.mamicode.com/"50.0"/>
  make the starting size small for the benefit of the Android clients memory...
  -->
    <param name="xmin" value=http://www.mamicode.com/"-1.0"/>   //map初始化的大小
    <param name="ymin" value=http://www.mamicode.com/"-1.0"/>
    <param name="xmax" value=http://www.mamicode.com/"1.0"/>
    <param name="ymax" value=http://www.mamicode.com/"1.0"/>

    <param name="delta" value=http://www.mamicode.com/"0.05"/>
    <param name="llsamplerange" value=http://www.mamicode.com/"0.01"/>
    <param name="llsamplestep" value=http://www.mamicode.com/"0.01"/>
    <param name="lasamplerange" value=http://www.mamicode.com/"0.005"/>
    <param name="lasamplestep" value=http://www.mamicode.com/"0.005"/>
    <remap from="scan" to="$(arg scan_topic)"/>
  </node>
</launch>

导航启动文件:tb_demo_amcl.launch

<launch>

  <param name="use_sim_time" value="http://www.mamicode.com/false" />
 
  <!-- EDIT THIS LINE TO REFLECT THE NAME OF YOUR OWN MAP FILE
       Can also be overridden on the command line -->
  <arg name="map" default="map.yaml" />

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

  <!-- Start move_base  -->
  <include file="$(find navigation_tutorials)/launch/tb_move_base.launch" />

  <!-- Fire up AMCL -->
  <include file="$(find navigation_tutorials)/launch/tb_amcl.launch" />
 
</launch>

 tb_move_base.launch

<launch>

  <node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen" clear_params="true">
    <rosparam file="$(find rbx1_nav)/config/turtlebot/costmap_common_params.yaml" command="load" ns="global_costmap" />
    <rosparam file="$(find rbx1_nav)/config/turtlebot/costmap_common_params.yaml" command="load" ns="local_costmap" />
    <rosparam file="$(find rbx1_nav)/config/turtlebot/local_costmap_params.yaml" command="load" />
    <rosparam file="$(find rbx1_nav)/config/turtlebot/global_costmap_params.yaml" command="load" />
    <rosparam file="$(find rbx1_nav)/config/turtlebot/base_local_planner_params.yaml" command="load" />
  </node>
  
</launch>

 tb_amcl.launch

<launch>

  <arg name="use_map_topic" default="false"/>
  <arg name="scan_topic" default="scan"/>

  <node pkg="amcl" type="amcl" name="amcl" clear_params="true">
    <param name="use_map_topic" value="http://www.mamicode.com/$(arg use_map_topic)"/>
    <!-- Publish scans from best pose at a max of 10 Hz -->
    <param name="odom_model_type" value="http://www.mamicode.com/diff"/>
    <param name="odom_alpha5" value="http://www.mamicode.com/0.1"/>
    <param name="gui_publish_rate" value="http://www.mamicode.com/10.0"/>
    <param name="laser_max_beams" value="http://www.mamicode.com/60"/>
    <param name="laser_max_range" value="http://www.mamicode.com/12.0"/>
    <param name="min_particles" value="http://www.mamicode.com/500"/>
    <param name="max_particles" value="http://www.mamicode.com/2000"/>
    <param name="kld_err" value="http://www.mamicode.com/0.05"/>
    <param name="kld_z" value="http://www.mamicode.com/0.99"/>
    <param name="odom_alpha1" value="http://www.mamicode.com/0.2"/>
    <param name="odom_alpha2" value="http://www.mamicode.com/0.2"/>
    <!-- translation std dev, m -->
    <param name="odom_alpha3" value="http://www.mamicode.com/0.2"/>
    <param name="odom_alpha4" value="http://www.mamicode.com/0.2"/>
    <param name="laser_z_hit" value="http://www.mamicode.com/0.5"/>
    <param name="laser_z_short" value="http://www.mamicode.com/0.05"/>
    <param name="laser_z_max" value="http://www.mamicode.com/0.05"/>
    <param name="laser_z_rand" value="http://www.mamicode.com/0.5"/>
    <param name="laser_sigma_hit" value="http://www.mamicode.com/0.2"/>
    <param name="laser_lambda_short" value="http://www.mamicode.com/0.1"/>
    <param name="laser_model_type" value="http://www.mamicode.com/likelihood_field"/>
    <!-- <param name="laser_model_type" value="http://www.mamicode.com/beam"/> -->
    <param name="laser_likelihood_max_dist" value="http://www.mamicode.com/2.0"/>
    <param name="update_min_d" value="http://www.mamicode.com/0.25"/>
    <param name="update_min_a" value="http://www.mamicode.com/0.2"/>
    <param name="odom_frame_id" value="http://www.mamicode.com/odom"/>
    <param name="resample_interval" value="http://www.mamicode.com/1"/>
    <!-- Increase tolerance because the computer can get quite busy -->
    <param name="transform_tolerance" value="http://www.mamicode.com/1.0"/>
    <param name="recovery_alpha_slow" value="http://www.mamicode.com/0.0"/>
    <param name="recovery_alpha_fast" value="http://www.mamicode.com/0.0"/>
    <remap from="scan" to="$(arg scan_topic)"/>
  </node>
</launch>

 base_local_planner_params.yaml

controller_frequency: 3.0
recovery_behavior_enabled: false
clearing_rotation_allowed: false

TrajectoryPlannerROS:
   max_vel_x: 0.3
   min_vel_x: 0.05
   max_vel_y: 0.0  # zero for a differential drive robot
   min_vel_y: 0.0
   min_in_place_vel_theta: 0.5
   escape_vel: -0.1
   acc_lim_x: 2.5
   acc_lim_y: 0.0 # zero for a differential drive robot
   acc_lim_theta: 3.2

   holonomic_robot: false
   yaw_goal_tolerance: 0.1 # about 6 degrees
   xy_goal_tolerance: 0.15  # 10 cm
   latch_xy_goal_tolerance: false
   pdist_scale: 0.8
   gdist_scale: 0.6
   meter_scoring: true

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

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

costmap_common_params.yaml

obstacle_range: 2.5
raytrace_range: 3.0
robot_radius: 0.165
inflation_radius: 0.3
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}

global_costmap_params.yaml

global_costmap:
   global_frame: /map
   robot_base_frame: /base_footprint
   update_frequency: 1.0
   publish_frequency: 0
   static_map: true
   rolling_window: false
   resolution: 0.01
   transform_tolerance: 1.0
   map_type: costmap

 local_costmap_params.yaml

local_costmap:
   global_frame: /odom
   robot_base_frame: /base_footprint
   update_frequency: 5.0
   publish_frequency: 1.0
   static_map: false
   rolling_window: true
   width: 6.0
   height: 6.0
   resolution: 0.01
   transform_tolerance: 1.0
   map_type: costmap

 把原先建好的图map.pgm  map.yaml 放在功能包/maps/下

roslaunch odom_tf_package  start.launch         机器人启动文件
roscat navigation_tutorials tb_demo_amcl.launch    导航文件
roslaunch navigation_tutorials rviz.launc            rviz启动文件

 

技术分享

技术分享

movebase导航